Coby Lu / game

Dependents:   snake

Committer:
lucoby
Date:
Thu Oct 11 18:54:54 2012 +0000
Revision:
0:3668e8f103be
Child:
1:fae551b1bd58
initial

Who changed what in which revision?

UserRevisionLine numberNew contents of line
lucoby 0:3668e8f103be 1 #include "game.h"
lucoby 0:3668e8f103be 2 #include "list.h"
lucoby 0:3668e8f103be 3
lucoby 0:3668e8f103be 4 void score(Apple* apple, int* points) {
lucoby 0:3668e8f103be 5 *points += 10;
lucoby 0:3668e8f103be 6 apple->row = rand() % ROW;
lucoby 0:3668e8f103be 7 apple->col = rand() % COL;
lucoby 0:3668e8f103be 8 }
lucoby 0:3668e8f103be 9
lucoby 0:3668e8f103be 10 int checkGameOver(List* snake) {
lucoby 0:3668e8f103be 11 Lnode* head = snake->head;
lucoby 0:3668e8f103be 12 Lnode* phere = head->next;
lucoby 0:3668e8f103be 13 while(phere != NULL) {
lucoby 0:3668e8f103be 14 if(phere->row == head->row && phere->col == head->col) {
lucoby 0:3668e8f103be 15 return 0;
lucoby 0:3668e8f103be 16 }
lucoby 0:3668e8f103be 17 phere = phere->next;
lucoby 0:3668e8f103be 18 }
lucoby 0:3668e8f103be 19 if(head->row < 0 || head->row > ROW-1 || head-> col < 0 || head->col > COL-1){
lucoby 0:3668e8f103be 20 return 0;
lucoby 0:3668e8f103be 21 }
lucoby 0:3668e8f103be 22 return 1;
lucoby 0:3668e8f103be 23 }
lucoby 0:3668e8f103be 24