diff options
| author | Preston Pan <preston@nullring.xyz> | 2023-02-06 15:15:06 -0800 |
|---|---|---|
| committer | Preston Pan <preston@nullring.xyz> | 2023-02-06 15:15:06 -0800 |
| commit | b0ae48bbc3761820021db07cfec8e06776f0b639 (patch) | |
| tree | 09d7b8a3a0121c02a26f849bd00529e13170aa13 | |
| parent | 88e2805ed74df0ec8b41c4bdd1978a15396674c3 (diff) | |
obstacles work now
| -rw-r--r-- | Makefile | 1 | ||||
| -rw-r--r-- | snake.c | 4 |
2 files changed, 3 insertions, 2 deletions
@@ -1,6 +1,7 @@ CFLAGS=-I. -pthread -Wall -Wextra -Wpedantic -std=c99 -march=native -O3 -lm CFLAGS+= -Wshadow -Wstrict-prototypes -Wundef -Wpointer-arith -Wcast-align -Wstrict-overflow=5 -Wswitch-default CFLAGS+= -Wunreachable-code -Wswitch-enum -Wformat=2 +CFLAGS+= -fsanitize=address PREFIX ?= /usr BINDIR ?= ${PREFIX}/bin MANDIR = ${PREFIX}/share/man/ @@ -48,7 +48,7 @@ int main(int argc, char **argv) { return 0; } else if(strcmp("--help", argv[i]) == 0) { - printf("usage: snake3 [--version] [--help] [--size board_size] [--speed speed]\n"); + printf("usage: snake3 [--version] [--help] [--size board_size] [--speed speed] [--obstacles obstacles]\n"); return 0; } else if(strcmp("--size", argv[i]) == 0 || strcmp("--speed", argv[i]) == 0 || strcmp("--obstacles", argv[i]) == 0) { @@ -114,7 +114,7 @@ int main(int argc, char **argv) { snakePositions.vectors[4] = init_vector(3, 3); foodPos = init_vector(7, 9); lastMoveDir = init_vector(0, 1); - int opc = (obstacleSize ^ 2) * obstacles; + int opc = (int)pow(obstacleSize, 2) * obstacles; obstaclePositions = init_vectorp(malloc(opc * sizeof(vector_t)), opc); srand(time(NULL)); /* place the obstacles */ |
