mirror of
https://gitlab.com/drummyfish/anarch.git
synced 2024-12-21 23:08:49 -05:00
Add logging
This commit is contained in:
parent
1defd298e4
commit
727fdc3a90
8
main.c
8
main.c
@ -23,6 +23,8 @@
|
||||
needs.
|
||||
*/
|
||||
|
||||
#define SFG_LOG(str) ; ///< Can be redefined to log messages for better debug.
|
||||
|
||||
/** Return 1 (0) if given key is pressed (not pressed). */
|
||||
int8_t SFG_keyPressed(uint8_t key);
|
||||
|
||||
@ -259,6 +261,8 @@ void SFG_recompurePLayerDirection()
|
||||
|
||||
void SFG_setLevel(const SFG_Level *level)
|
||||
{
|
||||
SFG_LOG("setting and initializing level");
|
||||
|
||||
SFG_currentLevel.levelPointer = level;
|
||||
|
||||
for (uint8_t i = 0; i < 7; ++i)
|
||||
@ -272,6 +276,8 @@ void SFG_setLevel(const SFG_Level *level)
|
||||
|
||||
void SFG_init()
|
||||
{
|
||||
SFG_LOG("initializing game")
|
||||
|
||||
SFG_frame = 0;
|
||||
SFG_lastFrameTimeMs = 0;
|
||||
|
||||
@ -366,4 +372,6 @@ void SFG_mainLoopBody()
|
||||
|
||||
if (timeNextFrame > timeNow)
|
||||
SFG_sleepMs((timeNextFrame - timeNow) / 2); // wait, relieve CPU
|
||||
else
|
||||
SFG_LOG("failed to reach target FPS!")
|
||||
}
|
||||
|
@ -10,6 +10,9 @@
|
||||
|
||||
#include "palette.h"
|
||||
|
||||
#undef SFG_LOG
|
||||
#define SFG_LOG(str) printf("game: %s\n",str);
|
||||
|
||||
const uint8_t *sdlKeyboardState;
|
||||
|
||||
uint16_t screen[SFG_RESOLUTION_X * SFG_RESOLUTION_Y]; // RGB565 format
|
||||
@ -46,11 +49,9 @@ int8_t SFG_keyPressed(uint8_t key)
|
||||
|
||||
int main()
|
||||
{
|
||||
printf("starting\n");
|
||||
printf("SDL: starting\n");
|
||||
|
||||
SFG_init();
|
||||
|
||||
printf("initializing SDL\n");
|
||||
printf("SDL: initializing SDL\n");
|
||||
|
||||
SDL_Window *window =
|
||||
SDL_CreateWindow("raycasting", SDL_WINDOWPOS_UNDEFINED,
|
||||
@ -67,6 +68,8 @@ int main()
|
||||
|
||||
sdlKeyboardState = SDL_GetKeyboardState(NULL);
|
||||
|
||||
SFG_init();
|
||||
|
||||
int running = 1;
|
||||
|
||||
while (running)
|
||||
@ -85,13 +88,13 @@ int main()
|
||||
SDL_RenderPresent(renderer);
|
||||
}
|
||||
|
||||
printf("freeing SDL\n");
|
||||
printf("SDL: freeing SDL\n");
|
||||
|
||||
SDL_DestroyTexture(texture);
|
||||
SDL_DestroyRenderer(renderer);
|
||||
SDL_DestroyWindow(window);
|
||||
|
||||
printf("ending\n");
|
||||
printf("SDL: ending\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user