mirror of
https://gitlab.com/drummyfish/anarch.git
synced 2024-12-21 23:08:49 -05:00
Change architecture
This commit is contained in:
parent
4970eecdfb
commit
c2a9de42e2
@ -157,15 +157,15 @@ assets/ asset sources (textures, sprites, maps, sounds, ...)
|
||||
*.py scripts for converting assets to C structs/arrays
|
||||
media/ media presenting the game (screenshots, logo, ...)
|
||||
constants.h game constants that aren't considered settings
|
||||
game.h main game logic
|
||||
images.h images (textures, sprites) from assets folder converted to C
|
||||
levels.h levels from assets folder converted to C
|
||||
main_*.* fronted implement. for various platforms, passed to compiler
|
||||
palette.h game 256 color palette
|
||||
platform_*.png fronted implementation for various platforms
|
||||
raycastlib.h raycasting library
|
||||
settings.h game settings that users can change (FPS, resolution, ...)
|
||||
sounds.h sounds from assets folder converted to C
|
||||
texts.h game texts
|
||||
main.c main game logic, this file is passed to the compiler
|
||||
make.sh compiling script constaining compiler settings
|
||||
HTMLshell.html HTML shell for emscripten (browser) version
|
||||
index.html game website
|
||||
|
5
TODO.txt
5
TODO.txt
@ -2,6 +2,7 @@ general:
|
||||
|
||||
- Architecture change: make platform files compilable and move main.c to game.h
|
||||
(so that pokitto is .cpp, GB is .ino etc.).
|
||||
- Rewrite python scripts to C (faster, less bloat).
|
||||
- Try to recolor textures and give them a bit more of variety.
|
||||
- Make monsters die when squeezed?
|
||||
- On Win$hit builds display an anti-windshit text, by macro.
|
||||
@ -83,7 +84,7 @@ level ideas:
|
||||
- wall made of elevators (or squeezers), serving as a big auto-opening gate DONE
|
||||
- a key spot to which the player can only get by jumping from a distant high
|
||||
elevated place
|
||||
- player has to jump from one elevator to another, which can only be done when
|
||||
- player has to jump from one elevator to another, which can only be done when kinda
|
||||
they're both moving down
|
||||
- multiple doors in a row (can look interesting) DONE
|
||||
- narrow (1 square wide) corridor filled with enemies blocking it
|
||||
@ -112,7 +113,7 @@ level ideas:
|
||||
- teleports placed so that the player can shoot himself with a rocket or plasma DONE
|
||||
(for fun)
|
||||
- exploders in a maze, hiding behind corners
|
||||
- teleport leading to a center of big room full of enemies
|
||||
- teleport leading to a center of big room full of enemies kinda
|
||||
- easter egg -- a level that looks funny on the map, e.g. forms a text or a DONE
|
||||
picture
|
||||
- squeezers with low-elevated base (a hole), on a side of a corridor -- if the
|
||||
|
2
levels.h
2
levels.h
@ -1051,7 +1051,7 @@ SFG_PROGRAM_MEMORY SFG_Level SFG_levels[SFG_NUMBER_OF_LEVELS] =
|
||||
}
|
||||
},
|
||||
|
||||
#include "/home/tastyfish/Git/sucklessFPS/assets/tmp.txt"
|
||||
#include "/home/tastyfish/git/anarch/assets/tmp.txt"
|
||||
,
|
||||
|
||||
{ // level 6
|
||||
|
168
main_pokitto.cpp
Normal file
168
main_pokitto.cpp
Normal file
@ -0,0 +1,168 @@
|
||||
/**
|
||||
@file main_pokitto.cpp
|
||||
|
||||
This is Pokitto implementation of the game front end, using the official
|
||||
PokittoLib.
|
||||
|
||||
by Miloslav Ciz (drummyfish), 2019
|
||||
|
||||
Released under CC0 1.0 (https://creativecommons.org/publicdomain/zero/1.0/)
|
||||
plus a waiver of all other intellectual property. The goal of this work is
|
||||
be and remain completely in the public domain forever, available for any use
|
||||
whatsoever.
|
||||
*/
|
||||
|
||||
//#define SFG_LOG(str) printf("game: %s\n",str); // for debug only
|
||||
|
||||
#define SFG_FPS 30
|
||||
#define SFG_TEXTURE_DISTANCE 5000
|
||||
#define SFG_SCREEN_RESOLUTION_X 110
|
||||
#define SFG_SCREEN_RESOLUTION_Y 88
|
||||
#define SFG_RESOLUTION_SCALEDOWN 1
|
||||
#define SFG_DITHERED_SHADOW 0
|
||||
#define SFG_FOG_DIMINISH_STEP 2048
|
||||
#define SFG_RAYCASTING_MAX_STEPS 20
|
||||
#define SFG_RAYCASTING_MAX_HITS 6
|
||||
#define SFG_RAYCASTING_SUBSAMPLE 2
|
||||
|
||||
#include "Pokitto.h"
|
||||
#include "clock_11u6x.h"
|
||||
#include "timer_11u6x.h"
|
||||
#include "palette.h"
|
||||
|
||||
#include "game.h"
|
||||
#include "sounds.h"
|
||||
|
||||
Pokitto::Core pokitto;
|
||||
|
||||
uint8_t *pokittoScreen;
|
||||
|
||||
void SFG_setPixel(uint16_t x, uint16_t y, uint8_t colorIndex)
|
||||
{
|
||||
pokittoScreen[y * SFG_SCREEN_RESOLUTION_X + x] = colorIndex;
|
||||
}
|
||||
|
||||
uint32_t SFG_getTimeMs()
|
||||
{
|
||||
return pokitto.getTime();
|
||||
}
|
||||
|
||||
void SFG_sleepMs(uint16_t timeMs)
|
||||
{
|
||||
}
|
||||
|
||||
int8_t SFG_keyPressed(uint8_t key)
|
||||
{
|
||||
switch (key)
|
||||
{
|
||||
case SFG_KEY_UP: return pokitto.upBtn(); break;
|
||||
case SFG_KEY_RIGHT: return pokitto.rightBtn(); break;
|
||||
case SFG_KEY_DOWN: return pokitto.downBtn(); break;
|
||||
case SFG_KEY_LEFT: return pokitto.leftBtn(); break;
|
||||
case SFG_KEY_A: return pokitto.aBtn(); break;
|
||||
case SFG_KEY_B: return pokitto.bBtn(); break;
|
||||
case SFG_KEY_C: return pokitto.cBtn(); break;
|
||||
default: return 0; break;
|
||||
}
|
||||
}
|
||||
|
||||
void SFG_getMouseOffset(int16_t *x, int16_t *y)
|
||||
{
|
||||
*x = 0;
|
||||
*y = 0;
|
||||
}
|
||||
|
||||
uint8_t audioBuff[SFG_SFX_SAMPLE_COUNT];
|
||||
uint16_t audioPos = 0;
|
||||
|
||||
uint8_t musicOn = 1;
|
||||
|
||||
void SFG_enableMusic(uint8_t enable)
|
||||
{
|
||||
musicOn = enable;
|
||||
}
|
||||
|
||||
static inline uint8_t mixSamples(uint8_t sample1, uint8_t sample2)
|
||||
{
|
||||
return (sample1 >> 1) + (sample2 >> 1);
|
||||
}
|
||||
|
||||
void onTimer() // for sound
|
||||
{
|
||||
if (Chip_TIMER_MatchPending(LPC_TIMER32_0, 1))
|
||||
{
|
||||
Chip_TIMER_ClearMatch(LPC_TIMER32_0, 1);
|
||||
|
||||
Pokitto::dac_write(
|
||||
musicOn ?
|
||||
mixSamples(audioBuff[audioPos],SFG_getNextMusicSample() / 2) :
|
||||
audioBuff[audioPos]
|
||||
);
|
||||
|
||||
audioBuff[audioPos] = 127;
|
||||
|
||||
audioPos = (audioPos + 1) % SFG_SFX_SAMPLE_COUNT;
|
||||
}
|
||||
}
|
||||
|
||||
void timerInit(uint32_t samplingRate)
|
||||
{
|
||||
Chip_TIMER_Init(LPC_TIMER32_0);
|
||||
Chip_TIMER_Reset(LPC_TIMER32_0);
|
||||
Chip_TIMER_MatchEnableInt(LPC_TIMER32_0, 1);
|
||||
Chip_TIMER_SetMatch(LPC_TIMER32_0, 1,
|
||||
(Chip_Clock_GetSystemClockRate() / samplingRate));
|
||||
Chip_TIMER_ResetOnMatchEnable(LPC_TIMER32_0, 1);
|
||||
Chip_TIMER_Enable(LPC_TIMER32_0);
|
||||
|
||||
#define weirdNumber ((IRQn_Type) 18)
|
||||
NVIC_ClearPendingIRQ(weirdNumber);
|
||||
NVIC_SetVector(weirdNumber, (uint32_t) &onTimer);
|
||||
NVIC_EnableIRQ(weirdNumber);
|
||||
#undef weirdNumber
|
||||
}
|
||||
|
||||
void SFG_playSound(uint8_t soundIndex, uint8_t volume)
|
||||
{
|
||||
uint8_t volumeStep = volume / 16;
|
||||
|
||||
uint16_t pos = audioPos;
|
||||
|
||||
for (int i = 0; i < SFG_SFX_SAMPLE_COUNT; ++i)
|
||||
{
|
||||
audioBuff[pos] =
|
||||
mixSamples(audioBuff[pos],SFG_GET_SFX_SAMPLE(soundIndex,i) * volumeStep);
|
||||
|
||||
pos = (pos < SFG_SFX_SAMPLE_COUNT - 1) ? (pos + 1) : 0;
|
||||
}
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
pokitto.begin();
|
||||
timerInit(8000);
|
||||
|
||||
for (uint16_t i = 0; i < SFG_SFX_SAMPLE_COUNT; ++i)
|
||||
audioBuff[i] = 127;
|
||||
|
||||
pokitto.setFrameRate(255);
|
||||
pokitto.display.setFont(fontTiny);
|
||||
pokitto.display.persistence = 1;
|
||||
pokitto.display.setInvisibleColor(-1);
|
||||
pokitto.display.load565Palette(paletteRGB565);
|
||||
|
||||
pokittoScreen = pokitto.display.screenbuffer;
|
||||
|
||||
SFG_init();
|
||||
|
||||
while (pokitto.isRunning())
|
||||
{
|
||||
if (pokitto.update())
|
||||
{
|
||||
SFG_mainLoopBody();
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
347
main_sdl.c
Normal file
347
main_sdl.c
Normal file
@ -0,0 +1,347 @@
|
||||
/**
|
||||
@file main_sdl.c
|
||||
|
||||
This is an SDL2 implementation of the game front end. It can be used to
|
||||
compile a native executable or a transpiled JS browser version with
|
||||
emscripten.
|
||||
|
||||
To compile with emscripten run:
|
||||
|
||||
emcc ./main_sdl.c -s USE_SDL=2 -O3 --shell-file HTMLshell.html -o game.html
|
||||
|
||||
by Miloslav Ciz (drummyfish), 2019
|
||||
|
||||
Released under CC0 1.0 (https://creativecommons.org/publicdomain/zero/1.0/)
|
||||
plus a waiver of all other intellectual property. The goal of this work is
|
||||
be and remain completely in the public domain forever, available for any use
|
||||
whatsoever.
|
||||
*/
|
||||
|
||||
#if defined(_WIN32) || defined(WIN32) || defined(__WIN32__) || defined(__NT__) || defined(__APPLE__)
|
||||
#define SFG_OS_IS_MALWARE 1
|
||||
#endif
|
||||
|
||||
#define SFG_BACKGROUND_BLUR 1
|
||||
|
||||
#define SFG_LOG(str) puts(str);
|
||||
|
||||
#include <stdio.h>
|
||||
#include <SDL2/SDL.h>
|
||||
|
||||
#include "game.h"
|
||||
#include "sounds.h"
|
||||
|
||||
const uint8_t *sdlKeyboardState;
|
||||
uint8_t sdlMouseButtonState = 0;
|
||||
int8_t sdlMouseWheelState = 0;
|
||||
|
||||
uint16_t screen[SFG_SCREEN_RESOLUTION_X * SFG_SCREEN_RESOLUTION_Y]; // RGB565 format
|
||||
|
||||
SDL_Window *window;
|
||||
SDL_Renderer *renderer;
|
||||
SDL_Texture *texture;
|
||||
SDL_Surface *screenSurface;
|
||||
|
||||
void SFG_setPixel(uint16_t x, uint16_t y, uint8_t colorIndex)
|
||||
{
|
||||
screen[y * SFG_SCREEN_RESOLUTION_X + x] = paletteRGB565[colorIndex];
|
||||
}
|
||||
|
||||
uint32_t SFG_getTimeMs()
|
||||
{
|
||||
return SDL_GetTicks();
|
||||
}
|
||||
|
||||
void SFG_sleepMs(uint16_t timeMs)
|
||||
{
|
||||
#ifndef __EMSCRIPTEN__
|
||||
usleep(timeMs * 1000);
|
||||
#endif
|
||||
}
|
||||
|
||||
void SFG_getMouseOffset(int16_t *x, int16_t *y)
|
||||
{
|
||||
int mX, mY;
|
||||
|
||||
SDL_GetMouseState(&mX,&mY);
|
||||
|
||||
*x = mX - SFG_SCREEN_RESOLUTION_X / 2;
|
||||
*y = mY - SFG_SCREEN_RESOLUTION_Y / 2;
|
||||
|
||||
SDL_WarpMouseInWindow(window,
|
||||
SFG_SCREEN_RESOLUTION_X / 2, SFG_SCREEN_RESOLUTION_Y / 2);
|
||||
}
|
||||
|
||||
int8_t SFG_keyPressed(uint8_t key)
|
||||
{
|
||||
switch (key)
|
||||
{
|
||||
case SFG_KEY_UP:
|
||||
return sdlKeyboardState[SDL_SCANCODE_UP] ||
|
||||
sdlKeyboardState[SDL_SCANCODE_W] ||
|
||||
sdlKeyboardState[SDL_SCANCODE_KP_8];
|
||||
break;
|
||||
|
||||
case SFG_KEY_RIGHT:
|
||||
return sdlKeyboardState[SDL_SCANCODE_RIGHT] ||
|
||||
sdlKeyboardState[SDL_SCANCODE_E] ||
|
||||
sdlKeyboardState[SDL_SCANCODE_KP_6];
|
||||
break;
|
||||
|
||||
case SFG_KEY_DOWN:
|
||||
return sdlKeyboardState[SDL_SCANCODE_DOWN] ||
|
||||
sdlKeyboardState[SDL_SCANCODE_S] ||
|
||||
sdlKeyboardState[SDL_SCANCODE_KP_5] ||
|
||||
sdlKeyboardState[SDL_SCANCODE_KP_2];
|
||||
break;
|
||||
|
||||
case SFG_KEY_LEFT:
|
||||
return sdlKeyboardState[SDL_SCANCODE_LEFT] ||
|
||||
sdlKeyboardState[SDL_SCANCODE_Q] ||
|
||||
sdlKeyboardState[SDL_SCANCODE_KP_4];
|
||||
break;
|
||||
|
||||
case SFG_KEY_A:
|
||||
return sdlKeyboardState[SDL_SCANCODE_G];
|
||||
break;
|
||||
|
||||
case SFG_KEY_B:
|
||||
return sdlKeyboardState[SDL_SCANCODE_H] || (sdlMouseButtonState & SDL_BUTTON_LMASK);
|
||||
break;
|
||||
|
||||
case SFG_KEY_C:
|
||||
return sdlKeyboardState[SDL_SCANCODE_J];
|
||||
break;
|
||||
|
||||
case SFG_KEY_JUMP:
|
||||
return sdlKeyboardState[SDL_SCANCODE_SPACE];
|
||||
break;
|
||||
|
||||
case SFG_KEY_STRAFE_LEFT:
|
||||
return sdlKeyboardState[SDL_SCANCODE_A] ||
|
||||
sdlKeyboardState[SDL_SCANCODE_KP_7];
|
||||
break;
|
||||
|
||||
case SFG_KEY_STRAFE_RIGHT:
|
||||
return sdlKeyboardState[SDL_SCANCODE_D] ||
|
||||
sdlKeyboardState[SDL_SCANCODE_KP_9];
|
||||
break;
|
||||
|
||||
case SFG_KEY_MAP:
|
||||
return sdlKeyboardState[SDL_SCANCODE_TAB];
|
||||
break;
|
||||
|
||||
case SFG_KEY_TOGGLE_FREELOOK:
|
||||
return sdlMouseButtonState & SDL_BUTTON_RMASK;
|
||||
break;
|
||||
|
||||
case SFG_KEY_NEXT_WEAPON:
|
||||
if (sdlMouseWheelState > 0)
|
||||
{
|
||||
sdlMouseWheelState--;
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
break;
|
||||
|
||||
case SFG_KEY_PREVIOUS_WEAPON:
|
||||
if (sdlMouseWheelState < 0)
|
||||
{
|
||||
sdlMouseWheelState++;
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
break;
|
||||
|
||||
case SFG_KEY_MENU:
|
||||
return sdlKeyboardState[SDL_SCANCODE_X];
|
||||
break;
|
||||
|
||||
default: return 0; break;
|
||||
}
|
||||
}
|
||||
|
||||
int running;
|
||||
|
||||
void mainLoopIteration()
|
||||
{
|
||||
SDL_Event event;
|
||||
|
||||
while (SDL_PollEvent(&event)) // also automatically updates sdlKeyboardState
|
||||
{
|
||||
if(event.type == SDL_MOUSEWHEEL)
|
||||
{
|
||||
if (event.wheel.y > 0) // scroll up
|
||||
sdlMouseWheelState++;
|
||||
else if (event.wheel.y < 0) // scroll down
|
||||
sdlMouseWheelState--;
|
||||
}
|
||||
}
|
||||
|
||||
sdlMouseButtonState = SDL_GetMouseState(NULL,NULL);
|
||||
|
||||
if (sdlKeyboardState[SDL_SCANCODE_ESCAPE])
|
||||
running = 0;
|
||||
|
||||
SFG_mainLoopBody();
|
||||
|
||||
SDL_UpdateTexture(texture,NULL,screen,SFG_SCREEN_RESOLUTION_X * sizeof(uint16_t));
|
||||
|
||||
SDL_RenderClear(renderer);
|
||||
SDL_RenderCopy(renderer,texture,NULL,NULL);
|
||||
SDL_RenderPresent(renderer);
|
||||
}
|
||||
|
||||
#ifdef __EMSCRIPTEN__
|
||||
typedef void (*em_callback_func)(void);
|
||||
void emscripten_set_main_loop(em_callback_func func, int fps, int simulate_infinite_loop);
|
||||
#endif
|
||||
|
||||
uint8_t audioBuff[SFG_SFX_SAMPLE_COUNT];
|
||||
uint16_t audioPos = 0;
|
||||
|
||||
static inline uint8_t mixSamples(uint8_t sample1, uint8_t sample2)
|
||||
{
|
||||
return (sample1 >> 1) + (sample2 >> 1);
|
||||
}
|
||||
|
||||
uint8_t musicOn = 1;
|
||||
|
||||
void audioFillCallback(void *userdata, uint8_t *s, int l)
|
||||
{
|
||||
for (int i = 0; i < l; ++i)
|
||||
{
|
||||
s[i] = musicOn ?
|
||||
mixSamples(audioBuff[audioPos],SFG_getNextMusicSample() / 2) :
|
||||
audioBuff[audioPos];
|
||||
|
||||
audioBuff[audioPos] = 127;
|
||||
audioPos = (audioPos < SFG_SFX_SAMPLE_COUNT - 1) ? (audioPos + 1) : 0;
|
||||
}
|
||||
}
|
||||
|
||||
void SFG_enableMusic(uint8_t enable)
|
||||
{
|
||||
musicOn = enable;
|
||||
}
|
||||
|
||||
void SFG_playSound(uint8_t soundIndex, uint8_t volume)
|
||||
{
|
||||
uint8_t volumeStep = volume / 16;
|
||||
|
||||
uint16_t pos = audioPos;
|
||||
|
||||
for (int i = 0; i < SFG_SFX_SAMPLE_COUNT; ++i)
|
||||
{
|
||||
audioBuff[pos] =
|
||||
mixSamples(audioBuff[pos],SFG_GET_SFX_SAMPLE(soundIndex,i) * volumeStep);
|
||||
|
||||
pos = (pos < SFG_SFX_SAMPLE_COUNT - 1) ? (pos + 1) : 0;
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
uint8_t argHelp = 0;
|
||||
uint8_t argForceWindow = 0;
|
||||
uint8_t argForceFullscreen = 0;
|
||||
|
||||
for (uint8_t i = 1; i < argc; ++i)
|
||||
{
|
||||
if (argv[i][0] == '-' && argv[i][1] == 'h' && argv[i][2] == 0)
|
||||
argHelp = 1;
|
||||
else if (argv[i][0] == '-' && argv[i][1] == 'w' && argv[i][2] == 0)
|
||||
argForceWindow = 1;
|
||||
else if (argv[i][0] == '-' && argv[i][1] == 'f' && argv[i][2] == 0)
|
||||
argForceFullscreen = 1;
|
||||
else
|
||||
puts("SDL: unknown argument");
|
||||
}
|
||||
|
||||
if (argHelp)
|
||||
{
|
||||
puts("TODOGAME, a suckless first person shooter game (SDL2 frontend)\n");
|
||||
puts("version TODO, by Miloslav Ciz, released under CC0 1.0 + waiver of all IP");
|
||||
puts("possible arguments:\n");
|
||||
puts("-h print this help and end");
|
||||
puts("-w force run in window");
|
||||
puts("-f force run fullscreen\n");
|
||||
puts("controls:");
|
||||
puts("TODO");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
puts("SDL: starting");
|
||||
|
||||
puts("SDL: initializing SDL");
|
||||
|
||||
window =
|
||||
SDL_CreateWindow("raycasting", SDL_WINDOWPOS_UNDEFINED,
|
||||
SDL_WINDOWPOS_UNDEFINED, SFG_SCREEN_RESOLUTION_X, SFG_SCREEN_RESOLUTION_Y,
|
||||
SDL_WINDOW_SHOWN);
|
||||
|
||||
renderer = SDL_CreateRenderer(window,-1,0);
|
||||
|
||||
texture =
|
||||
SDL_CreateTexture(renderer,SDL_PIXELFORMAT_RGB565,SDL_TEXTUREACCESS_STATIC,
|
||||
SFG_SCREEN_RESOLUTION_X,SFG_SCREEN_RESOLUTION_Y);
|
||||
|
||||
screenSurface = SDL_GetWindowSurface(window);
|
||||
|
||||
#if SFG_FULLSCREEN
|
||||
argForceFullscreen = 1;
|
||||
#endif
|
||||
|
||||
if (!argForceWindow && argForceFullscreen)
|
||||
{
|
||||
puts("SDL: setting fullscreen");
|
||||
SDL_SetWindowFullscreen(window,SDL_WINDOW_FULLSCREEN_DESKTOP);
|
||||
}
|
||||
|
||||
sdlKeyboardState = SDL_GetKeyboardState(NULL);
|
||||
|
||||
SDL_ShowCursor(0);
|
||||
|
||||
SFG_init(SDL_INIT_AUDIO);
|
||||
|
||||
SDL_AudioSpec audioSpec;
|
||||
|
||||
audioSpec.callback = audioFillCallback;
|
||||
audioSpec.userdata = 0;
|
||||
audioSpec.freq = 8000;
|
||||
audioSpec.format = AUDIO_U8;
|
||||
audioSpec.channels = 1;
|
||||
audioSpec.samples = 128;
|
||||
|
||||
if (SDL_OpenAudio(&audioSpec,0) < 0)
|
||||
puts("SDL: could not initialize audio");
|
||||
|
||||
for (int i = 0; i < SFG_SFX_SAMPLE_COUNT; ++i)
|
||||
audioBuff[i] = 127;
|
||||
|
||||
SDL_PauseAudio(0);
|
||||
|
||||
running = 1;
|
||||
|
||||
#ifdef __EMSCRIPTEN__
|
||||
emscripten_set_main_loop(mainLoopIteration,0,1);
|
||||
#else
|
||||
while (running)
|
||||
mainLoopIteration();
|
||||
#endif
|
||||
|
||||
puts("SDL: freeing SDL");
|
||||
|
||||
SDL_PauseAudio(1);
|
||||
SDL_DestroyTexture(texture);
|
||||
SDL_DestroyRenderer(renderer);
|
||||
SDL_DestroyWindow(window);
|
||||
SDL_CloseAudio();
|
||||
|
||||
puts("SDL: ending");
|
||||
|
||||
return 0;
|
||||
}
|
175
settings.h
175
settings.h
@ -32,30 +32,35 @@
|
||||
On platforms with mouse this sets its horizontal sensitivity. 128 means 1
|
||||
RCL_Unit per mouse pixel travelled.
|
||||
*/
|
||||
#define SFG_MOUSE_SENSITIVITY_HORIZONTAL 32
|
||||
#ifndef SFG_MOUSE_SENSITIVITY_HORIZONTAL
|
||||
#define SFG_MOUSE_SENSITIVITY_HORIZONTAL 32
|
||||
#endif
|
||||
|
||||
/**
|
||||
Like SFG_MOUSE_SENSITIVITY_HORIZONTAL but for vertical look. 128 means 1
|
||||
shear pixel per mouse pixel travelled.
|
||||
*/
|
||||
#define SFG_MOUSE_SENSITIVITY_VERTICAL 64
|
||||
#ifndef SFG_MOUSE_SENSITIVITY_VERTICAL
|
||||
#define SFG_MOUSE_SENSITIVITY_VERTICAL 64
|
||||
#endif
|
||||
|
||||
/**
|
||||
Width of the screen in pixels. Set this to ACTUAL resolution. If you want the
|
||||
game to run at smaller resolution (with bigger pixels), do his using
|
||||
SFG_RESOLUTION_SCALEDOWN;
|
||||
*/
|
||||
#define SFG_SCREEN_RESOLUTION_X 1024
|
||||
#ifndef SFG_SCREEN_RESOLUTION_X
|
||||
#define SFG_SCREEN_RESOLUTION_X 800
|
||||
#endif
|
||||
|
||||
/**
|
||||
Height of the screen in pixels. Set this to ACTUAL resolution. If you want the
|
||||
game to run at smaller resolution (with bigger pixels), do his using
|
||||
SFG_RESOLUTION_SCALEDOWN;
|
||||
*/
|
||||
#define SFG_SCREEN_RESOLUTION_Y 768
|
||||
|
||||
|
||||
#define SFG_Z_BUFFER_BAND
|
||||
#ifndef SFG_SCREEN_RESOLUTION_Y
|
||||
#define SFG_SCREEN_RESOLUTION_Y 600
|
||||
#endif
|
||||
|
||||
/**
|
||||
Distance, in RCL_Units, to which textures will be drawn. Textures behind this
|
||||
@ -64,162 +69,224 @@
|
||||
having just a low value, values >= 65535 activate texturing completely, which
|
||||
can be a little faster than setting having a high value lower than this limit.
|
||||
*/
|
||||
#define SFG_TEXTURE_DISTANCE 100000
|
||||
#ifndef SFG_TEXTURE_DISTANCE
|
||||
#define SFG_TEXTURE_DISTANCE 100000
|
||||
#endif
|
||||
|
||||
/**
|
||||
How many times the screen resolution will be divided (how many times a game
|
||||
pixel will be bigger than the screen pixel).
|
||||
*/
|
||||
#define SFG_RESOLUTION_SCALEDOWN 1
|
||||
#ifndef SFG_RESOLUTION_SCALEDOWN
|
||||
#define SFG_RESOLUTION_SCALEDOWN 1
|
||||
#endif
|
||||
|
||||
/**
|
||||
Hint as to whether run in fullscreen, if the platform allows it.
|
||||
*/
|
||||
#define SFG_FULLSCREEN 0
|
||||
#ifndef SFG_FULLSCREEN
|
||||
#define SFG_FULLSCREEN 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
Whether shadows (fog) should be dithered, i.e. more smooth (needs a bit more
|
||||
CPU performance and memory).
|
||||
*/
|
||||
#define SFG_DITHERED_SHADOW 1
|
||||
#ifndef SFG_DITHERED_SHADOW
|
||||
#define SFG_DITHERED_SHADOW 1
|
||||
#endif
|
||||
|
||||
/**
|
||||
Depth step (in RCL_Units) after which fog diminishes a color by one value
|
||||
point. For performance reasons this number should be kept a power of two!
|
||||
*/
|
||||
#define SFG_FOG_DIMINISH_STEP 2048
|
||||
#ifndef SFG_FOG_DIMINISH_STEP
|
||||
#define SFG_FOG_DIMINISH_STEP 2048
|
||||
#endif
|
||||
|
||||
/**
|
||||
Maximum number of squares that will be traversed by any cast ray. Smaller
|
||||
number is faster but can cause visual artifacts.
|
||||
*/
|
||||
#define SFG_RAYCASTING_MAX_STEPS 30
|
||||
#ifndef SFG_RAYCASTING_MAX_STEPS
|
||||
#define SFG_RAYCASTING_MAX_STEPS 30
|
||||
#endif
|
||||
|
||||
/**
|
||||
Maximum number of hits any cast ray will register. Smaller number is faster
|
||||
but can cause visual artifacts.
|
||||
*/
|
||||
#define SFG_RAYCASTING_MAX_HITS 10
|
||||
#ifndef SFG_RAYCASTING_MAX_HITS
|
||||
#define SFG_RAYCASTING_MAX_HITS 10
|
||||
#endif
|
||||
|
||||
/**
|
||||
How many times rendering should be subsampled horizontally. Bigger number
|
||||
can significantly improve performance (by casting fewer rays), but can look
|
||||
a little worse.
|
||||
*/
|
||||
#define SFG_RAYCASTING_SUBSAMPLE 1
|
||||
#ifndef SFG_RAYCASTING_SUBSAMPLE
|
||||
#define SFG_RAYCASTING_SUBSAMPLE 1
|
||||
#endif
|
||||
|
||||
/**
|
||||
Enables or disables fog (darkness) due to distance. Recommended to keep on
|
||||
for good look, but can be turned off for performance.
|
||||
*/
|
||||
#define SFG_ENABLE_FOG 1
|
||||
#ifndef SFG_ENABLE_FOG
|
||||
#define SFG_ENABLE_FOG 1
|
||||
#endif
|
||||
|
||||
/**
|
||||
Says whether sprites should diminish in fog. This takes more performance but
|
||||
looks better.
|
||||
*/
|
||||
#define SFG_DIMINISH_SPRITES 1
|
||||
#ifndef SFG_DIMINISH_SPRITES
|
||||
#define SFG_DIMINISH_SPRITES 1
|
||||
#endif
|
||||
|
||||
/**
|
||||
How quick player head bob is, 1024 meaning once per second. 0 Means turn off
|
||||
head bob.
|
||||
*/
|
||||
#define SFG_HEADBOB_SPEED 900
|
||||
#ifndef SFG_HEADBOB_SPEED
|
||||
#define SFG_HEADBOB_SPEED 900
|
||||
#endif
|
||||
|
||||
/**
|
||||
Sets head bob offset, in RCL_UNITS_PER_SQUARE. 0 Means turn off head bob.
|
||||
*/
|
||||
#define SFG_HEADBOB_OFFSET 200
|
||||
#ifndef SFG_HEADBOB_OFFSET
|
||||
#define SFG_HEADBOB_OFFSET 200
|
||||
#endif
|
||||
|
||||
/**
|
||||
Weapon bobbing offset in weapon image pixels.
|
||||
*/
|
||||
#define SFG_WEAPONBOB_OFFSET 4
|
||||
#ifndef SFG_WEAPONBOB_OFFSET
|
||||
#define SFG_WEAPONBOB_OFFSET 4
|
||||
#endif
|
||||
|
||||
/**
|
||||
Camera shearing (looking up/down) speed, in vertical resolutions per second.
|
||||
*/
|
||||
#define SFG_CAMERA_SHEAR_SPEED 3
|
||||
#ifndef SFG_CAMERA_SHEAR_SPEED
|
||||
#define SFG_CAMERA_SHEAR_SPEED 3
|
||||
#endif
|
||||
|
||||
/**
|
||||
Maximum camera shear (vertical angle). 1024 means 1.0 * vertical resolution.
|
||||
*/
|
||||
#define SFG_CAMERA_MAX_SHEAR 1024
|
||||
#ifndef SFG_CAMERA_MAX_SHEAR
|
||||
#define SFG_CAMERA_MAX_SHEAR 1024
|
||||
#endif
|
||||
|
||||
/**
|
||||
Specifies how quick some sprite animations are, in frames per second.
|
||||
*/
|
||||
#define SFG_SPRITE_ANIMATION_SPEED 4
|
||||
#ifndef SFG_SPRITE_ANIMATION_SPEED
|
||||
#define SFG_SPRITE_ANIMATION_SPEED 4
|
||||
#endif
|
||||
|
||||
/**
|
||||
How wide the border indicator is, in fractions of screen width.
|
||||
*/
|
||||
#define SFG_HUD_BORDER_INDICATOR_WIDTH 32
|
||||
#ifndef SFG_HUD_BORDER_INDICATOR_WIDTH
|
||||
#define SFG_HUD_BORDER_INDICATOR_WIDTH 32
|
||||
#endif
|
||||
|
||||
/**
|
||||
For how long border indication (being hurt etc.) stays shown, in ms.
|
||||
*/
|
||||
#define SFG_HUD_BORDER_INDICATOR_DURATION 500
|
||||
#ifndef SFG_HUD_BORDER_INDICATOR_DURATION
|
||||
#define SFG_HUD_BORDER_INDICATOR_DURATION 500
|
||||
#endif
|
||||
|
||||
/**
|
||||
Color (palette index) by which being hurt is indicated.
|
||||
*/
|
||||
#define SFG_HUD_HURT_INDICATION_COLOR 175
|
||||
#ifndef SFG_HUD_HURT_INDICATION_COLOR
|
||||
#define SFG_HUD_HURT_INDICATION_COLOR 175
|
||||
#endif
|
||||
|
||||
/**
|
||||
Color (palette index) by which taking an item is indicated.
|
||||
*/
|
||||
#define SFG_HUD_ITEM_TAKEN_INDICATION_COLOR 207
|
||||
#ifndef SFG_HUD_ITEM_TAKEN_INDICATION_COLOR
|
||||
#define SFG_HUD_ITEM_TAKEN_INDICATION_COLOR 207
|
||||
#endif
|
||||
|
||||
/**
|
||||
How many element (items, monsters, ...) distances will be checked per frame
|
||||
for distance. Higher value may decrease performance a tiny bit, but things
|
||||
will react more quickly and appear less "out of thin air".
|
||||
*/
|
||||
#define SFG_ELEMENT_DISTANCES_CHECKED_PER_FRAME 8
|
||||
#ifndef SFG_ELEMENT_DISTANCES_CHECKED_PER_FRAME
|
||||
#define SFG_ELEMENT_DISTANCES_CHECKED_PER_FRAME 8
|
||||
#endif
|
||||
|
||||
/**
|
||||
Maximum distance at which sound effects (SFX) will be played. The SFX volume
|
||||
will gradually drop towards this distance.
|
||||
*/
|
||||
#define SFG_SFX_MAX_DISTANCE (1024 * 20)
|
||||
#ifndef SFG_SFX_MAX_DISTANCE
|
||||
#define SFG_SFX_MAX_DISTANCE (1024 * 20)
|
||||
#endif
|
||||
|
||||
/**
|
||||
Says the intensity of background image blur. 0 means no blur, improves
|
||||
performance and lowers memory usage.
|
||||
*/
|
||||
#define SFG_BACKGROUND_BLUR 0
|
||||
#ifndef SFG_BACKGROUND_BLUR
|
||||
#define SFG_BACKGROUND_BLUR 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
Defines the period, in ms, of things that blink, such as text.
|
||||
*/
|
||||
#define SFG_BLINK_PERIOD 500
|
||||
#ifndef SFG_BLINK_PERIOD
|
||||
#define SFG_BLINK_PERIOD 500
|
||||
#endif
|
||||
|
||||
/**
|
||||
Probability (0 - 255) of how often a monster makes sound during movement.
|
||||
*/
|
||||
#define SFG_MONSTER_SOUND_PROBABILITY 64
|
||||
#ifndef SFG_MONSTER_SOUND_PROBABILITY
|
||||
#define SFG_MONSTER_SOUND_PROBABILITY 64
|
||||
#endif
|
||||
|
||||
/**
|
||||
Affects how precise monsters are in aiming, specify random range in
|
||||
fourths of a game square. Should be power of 2 for performance.
|
||||
*/
|
||||
#define SFG_MONSTER_AIM_RANDOMNESS 4
|
||||
#ifndef SFG_MONSTER_AIM_RANDOMNESS
|
||||
#define SFG_MONSTER_AIM_RANDOMNESS 4
|
||||
#endif
|
||||
|
||||
/// Color 1 index of player on map.
|
||||
#define SFG_MAP_PLAYER_COLOR1 93
|
||||
#ifndef SFG_MAP_PLAYER_COLOR1
|
||||
#define SFG_MAP_PLAYER_COLOR1 93
|
||||
#endif
|
||||
|
||||
/// Color 2 index of player on map.
|
||||
#define SFG_MAP_PLAYER_COLOR2 111
|
||||
#ifndef SFG_MAP_PLAYER_COLOR2
|
||||
#define SFG_MAP_PLAYER_COLOR2 111
|
||||
#endif
|
||||
|
||||
/// Color index of elevators on map.
|
||||
#define SFG_MAP_ELEVATOR_COLOR 214
|
||||
#ifndef SFG_MAP_ELEVATOR_COLOR
|
||||
#define SFG_MAP_ELEVATOR_COLOR 214
|
||||
#endif
|
||||
|
||||
/// Color index of squeezers on map.
|
||||
#define SFG_MAP_SQUEEZER_COLOR 246
|
||||
#ifndef SFG_MAP_SQUEEZER_COLOR
|
||||
#define SFG_MAP_SQUEEZER_COLOR 246
|
||||
#endif
|
||||
|
||||
/// Color index of door on map.
|
||||
#define SFG_MAP_DOOR_COLOR 188
|
||||
#ifndef SFG_MAP_DOOR_COLOR
|
||||
#define SFG_MAP_DOOR_COLOR 188
|
||||
#endif
|
||||
|
||||
/**
|
||||
Boolean value indicating whether current OS is malware.
|
||||
@ -233,44 +300,60 @@
|
||||
/**
|
||||
Developer cheat for having infinite ammo in all weapons.
|
||||
*/
|
||||
#define SFG_INFINITE_AMMO 1
|
||||
#ifndef SFG_INFINITE_AMMO
|
||||
#define SFG_INFINITE_AMMO 1
|
||||
#endif
|
||||
|
||||
/**
|
||||
Developer cheat for immortality.
|
||||
*/
|
||||
#define SFG_IMMORTAL 1
|
||||
#ifndef SFG_IMMORTAL
|
||||
#define SFG_IMMORTAL 1
|
||||
#endif
|
||||
|
||||
/**
|
||||
Turn on for previes mode for map editing (flying, noclip, fast movement etc.).
|
||||
*/
|
||||
#define SFG_PREVIEW_MODE 0
|
||||
#ifndef SFG_PREVIEW_MODE
|
||||
#define SFG_PREVIEW_MODE 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
How much faster movement is in the preview mode.
|
||||
*/
|
||||
#define SFG_PREVIEW_MODE_SPEED_MULTIPLIER 2
|
||||
#ifndef SFG_PREVIEW_MODE_SPEED_MULTIPLIER
|
||||
#define SFG_PREVIEW_MODE_SPEED_MULTIPLIER 2
|
||||
#endif
|
||||
|
||||
/**
|
||||
Skips menu and starts given level immediatelly, for development. 0 means this
|
||||
options is ignored, 1 means load level 1 etc.
|
||||
*/
|
||||
#define SFG_START_LEVEL 6
|
||||
#ifndef SFG_START_LEVEL
|
||||
#define SFG_START_LEVEL 6
|
||||
#endif
|
||||
|
||||
/**
|
||||
Reveals whole level map from start.
|
||||
*/
|
||||
#define SFG_REVEAL_MAP 1
|
||||
#ifndef SFG_REVEAL_MAP
|
||||
#define SFG_REVEAL_MAP 1
|
||||
#endif
|
||||
|
||||
/**
|
||||
Gives player all keys from start.
|
||||
*/
|
||||
#define SFG_UNLOCK_DOOR 0
|
||||
#ifndef SFG_UNLOCK_DOOR
|
||||
#define SFG_UNLOCK_DOOR 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
Whether levels background (in distance or transparent wall textures) should
|
||||
be drawn. If turned off, the background will be constant color, which can
|
||||
noticably increase performance.
|
||||
*/
|
||||
#define SFG_DRAW_LEVEL_BACKGROUND 1
|
||||
#ifndef SFG_DRAW_LEVEL_BACKGROUND
|
||||
#define SFG_DRAW_LEVEL_BACKGROUND 1
|
||||
#endif
|
||||
|
||||
#endif // guard
|
||||
|
Loading…
Reference in New Issue
Block a user