api for dealing with game logic for snake
game.cpp
- Committer:
- lucoby
- Date:
- 2012-10-11
- Revision:
- 1:fae551b1bd58
- Parent:
- 0:3668e8f103be
File content as of revision 1:fae551b1bd58:
#include "game.h" #include "list.h" void score(Apple* apple, int* points) { *points += 10; apple->row = rand() % ROW; apple->col = rand() % COL; } int checkGameOver(List* snake) { Lnode* head = snake->head; Lnode* phere = head->next; while(phere != NULL) { if(phere->row == head->row && phere->col == head->col) { return 0; } phere = phere->next; } if(head->row < 0 || head->row > ROW || head-> col < 0 || head->col > COL){ return 0; } return 1; }