Now you can configurate sleep time

fix-mingw
Nakidai 2023-11-30 18:05:51 +03:00
parent 4b208ab1c4
commit 50c7f9d632
4 changed files with 9 additions and 3 deletions

View File

@ -23,5 +23,6 @@ target_include_directories(csnake PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include)
set(SIZE 10 CACHE STRING "Size of game field") set(SIZE 10 CACHE STRING "Size of game field")
set(DEFX 0 CACHE STRING "Start x") set(DEFX 0 CACHE STRING "Start x")
set(DEFY 0 CACHE STRING "Start y") set(DEFY 0 CACHE STRING "Start y")
set(SLEEP 1000 CACHE STRING "Sleep between frames (ms)")
configure_file(include/config.h.in ${CMAKE_CURRENT_SOURCE_DIR}/include/config.h) configure_file(include/config.h.in ${CMAKE_CURRENT_SOURCE_DIR}/include/config.h)

8
configure vendored
View File

@ -9,7 +9,8 @@ usage()
OUT - out file (default: csnake OUT - out file (default: csnake
SIZE - size of game field SIZE - size of game field
DEFX - start x DEFX - start x
DEFY - start y" DEFY - start y
SLEEP - sleep between frames (ms)"
exit 1 exit 1
} }
@ -30,6 +31,7 @@ OUT=${OUT:-csnake}
SIZE=${SIZE:-10} SIZE=${SIZE:-10}
DEFX=${DEFX:-0} DEFX=${DEFX:-0}
DEFY=${DEFY:-0} DEFY=${DEFY:-0}
SLEEP=${SLEEP:-1000}
echo "Makefile configuration:" echo "Makefile configuration:"
echo "Compiler: $CC" echo "Compiler: $CC"
@ -41,6 +43,7 @@ echo "Code configuration:"
echo "Size: $SIZE" echo "Size: $SIZE"
echo "Start x: $DEFX" echo "Start x: $DEFX"
echo "Start y: $DEFY" echo "Start y: $DEFY"
echo "Sleep: $SLEEP"
echo "CC = $CC echo "CC = $CC
CFLAGS = $CFLAGS CFLAGS = $CFLAGS
@ -49,4 +52,5 @@ OUT = $OUT" > config.mk
echo "#define SIZE $SIZE echo "#define SIZE $SIZE
#define DEFX $DEFX #define DEFX $DEFX
#define DEFY $DEFY" > include/config.h #define DEFY $DEFY
#define SLEEP $SLEEP" > include/config.h

View File

@ -1,3 +1,4 @@
#define SIZE ${SIZE} #define SIZE ${SIZE}
#define DEFX ${DEFX} #define DEFX ${DEFX}
#define DEFY ${DEFY} #define DEFY ${DEFY}
#define SLEEP ${SLEEP}

View File

@ -53,7 +53,7 @@ int main(int argc, char **argv)
for (i = 0; i < SIZE*2; ++i) putchar('-'); for (i = 0; i < SIZE*2; ++i) putchar('-');
printf("\nScore: %d\n", player->score); printf("\nScore: %d\n", player->score);
sleepMS(1000); sleepMS(SLEEP);
switch (*key) switch (*key)
{ {
case 'q': case 'q':