Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: game.cpp
- Revision:
- 0:3668e8f103be
- Child:
- 1:fae551b1bd58
diff -r 000000000000 -r 3668e8f103be game.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/game.cpp Thu Oct 11 18:54:54 2012 +0000 @@ -0,0 +1,24 @@ +#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-1 || head-> col < 0 || head->col > COL-1){ + return 0; + } + return 1; +} + \ No newline at end of file