diff --git a/game.h b/game.h index 305d37b..5a025e8 100644 --- a/game.h +++ b/game.h @@ -3,4 +3,48 @@ #include "map.h" +#define LCR_KEY_UP 0x00 +#define LCR_KEY_RIGHT 0x01 +#define LCR_KEY_DOWN 0x02 +#define LCR_KEY_LEFT 0x03 +#define LCR_KEY_A 0x04 ///< confirm, restart race +#define LCR_KEY_B 0x05 ///< cancel, open menu + +uint8_t LCR_keyPressed(uint8_t key); + +void LCR_sleep(uint16_t timeMs); + +void LCR_drawPixel(unsigned int x, unsigned int y, uint_fast16_t color); + +/** + Call at the start of the program. +*/ +void LCR_gameInit(void); + +/** + Call right before program end. +*/ +void LCR_gameEnd(void); + +/** + Call this repeatedly in your main loop, pass the current time as the number + of milliseconds since program start. Returns 0 if program should end, + otherwise 1. +*/ +uint8_t LCR_gameStep(uint32_t timeMs); + +//------------------------------------------------------------------------------ + +void LCR_gameInit(void) +{ +} + +void LCR_gameEnd(void) +{ +} + +uint8_t LCR_gameStep(uint32_t time) +{ +} + #endif // guard diff --git a/main.c b/main.c deleted file mode 100644 index 008dc05..0000000 --- a/main.c +++ /dev/null @@ -1,21 +0,0 @@ -#include - -#include "game.h" -#include "debug.h" - -int main(void) -{ - LCR_mapLoad(LCR_map0); - - LCR_debugPrintCurrentMap(); - - - uint8_t *b = LCR_getMapBlockAtCoordNumber(0); - - if (!b) - printf("NO!\n"); - else - printf("%d\n",(b - LCR_currentMap.blocks) / 4); - - return 0; -} diff --git a/main_sdl.c b/main_sdl.c new file mode 100644 index 0000000..0f37e11 --- /dev/null +++ b/main_sdl.c @@ -0,0 +1,51 @@ +#include + +#include "game.h" +#include "debug.h" + +SDL_Window *window; +SDL_Renderer *renderer; +SDL_Texture *texture; +SDL_Surface *screenSurface; + +const uint8_t *sdlKeyboardState; + +int main(int argc, char *argv[]) +{ + uint8_t running = 1; + LCR_gameInit(); + + SDL_Init(SDL_INIT_AUDIO | SDL_INIT_JOYSTICK); + + window = + SDL_CreateWindow("Licar", 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); + + sdlKeyboardState = SDL_GetKeyboardState(NULL); + + //SDL_ShowCursor(0); + + SDL_PumpEvents(); + + while (running) + { + running = sdlKeyboardState[SDL_SCANCODE_Q]; + } + + SDL_DestroyTexture(texture); + SDL_DestroyRenderer(renderer); + SDL_DestroyWindow(window); + + LCR_gameEnd(); + + return 0; +}