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