diff --git a/CMakeLists.txt b/CMakeLists.txt index bd923c2..9292c45 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,5 +23,6 @@ target_include_directories(csnake PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include) set(SIZE 10 CACHE STRING "Size of game field") set(DEFX 0 CACHE STRING "Start x") 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) diff --git a/configure b/configure index 71ed007..58daf1f 100755 --- a/configure +++ b/configure @@ -9,7 +9,8 @@ usage() OUT - out file (default: csnake SIZE - size of game field DEFX - start x - DEFY - start y" + DEFY - start y + SLEEP - sleep between frames (ms)" exit 1 } @@ -30,6 +31,7 @@ OUT=${OUT:-csnake} SIZE=${SIZE:-10} DEFX=${DEFX:-0} DEFY=${DEFY:-0} +SLEEP=${SLEEP:-1000} echo "Makefile configuration:" echo "Compiler: $CC" @@ -41,6 +43,7 @@ echo "Code configuration:" echo "Size: $SIZE" echo "Start x: $DEFX" echo "Start y: $DEFY" +echo "Sleep: $SLEEP" echo "CC = $CC CFLAGS = $CFLAGS @@ -49,4 +52,5 @@ OUT = $OUT" > config.mk echo "#define SIZE $SIZE #define DEFX $DEFX -#define DEFY $DEFY" > include/config.h +#define DEFY $DEFY +#define SLEEP $SLEEP" > include/config.h diff --git a/include/config.h.in b/include/config.h.in index 06a7e35..6e8c841 100644 --- a/include/config.h.in +++ b/include/config.h.in @@ -1,3 +1,4 @@ #define SIZE ${SIZE} #define DEFX ${DEFX} #define DEFY ${DEFY} +#define SLEEP ${SLEEP} diff --git a/src/main.c b/src/main.c index 31e047f..9a22049 100644 --- a/src/main.c +++ b/src/main.c @@ -53,7 +53,7 @@ int main(int argc, char **argv) for (i = 0; i < SIZE*2; ++i) putchar('-'); printf("\nScore: %d\n", player->score); - sleepMS(1000); + sleepMS(SLEEP); switch (*key) { case 'q':