examples/snake: Fix up build.

This commit is contained in:
Ryan C. Gordon 2024-07-30 13:39:35 -04:00
parent dbb4e05c28
commit bc8b768b9a
No known key found for this signature in database
GPG Key ID: FA148B892AB48044
3 changed files with 4 additions and 4 deletions

View File

@ -186,7 +186,7 @@ add_sdl_example_executable(renderer-primitives SOURCES renderer/02-primitives/re
add_sdl_example_executable(audio-simple-playback SOURCES audio/01-simple-playback/simple-playback.c)
add_sdl_example_executable(audio-simple-playback-callback SOURCES audio/02-simple-playback-callback/simple-playback-callback.c)
add_sdl_example_executable(audio-load-wav SOURCES audio/03-load-wav/load-wav.c DATAFILES ${CMAKE_CURRENT_SOURCE_DIR}/../test/sample.wav)
add_sdl_example_executable(snake SOURCES game/01-snake/main.c game/01-snake/snake.c)
add_sdl_example_executable(game-snake SOURCES game/01-snake/main.c game/01-snake/snake.c)
if(PSP)

View File

@ -34,8 +34,8 @@ static void new_food_pos_(SnakeContext *ctx, RandFunc rand)
char x;
char y;
for (;;) {
x = rand(SNAKE_GAME_WIDTH);
y = rand(SNAKE_GAME_HEIGHT);
x = (char) rand(SNAKE_GAME_WIDTH);
y = (char) rand(SNAKE_GAME_HEIGHT);
if (snake_cell_at(ctx, x, y) == SNAKE_CELL_NOTHING) {
put_cell_at_(ctx, x, y, SNAKE_CELL_FOOD);
break;

View File

@ -41,7 +41,7 @@ typedef struct
unsigned occupied_cells;
} SnakeContext;
typedef int (*RandFunc)(int n);
typedef Sint32 SDLCALL (*RandFunc)(Sint32 n);
void snake_initialize(SnakeContext *ctx, RandFunc rand);
void snake_redir(SnakeContext *ctx, SnakeDirection dir);