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.
game.cpp@1:fae551b1bd58, 2012-10-11 (annotated)
- Committer:
- lucoby
- Date:
- Thu Oct 11 20:23:38 2012 +0000
- Revision:
- 1:fae551b1bd58
- Parent:
- 0:3668e8f103be
fixed wall bug
Who changed what in which revision?
User | Revision | Line number | New 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 | 1:fae551b1bd58 | 19 | if(head->row < 0 || head->row > ROW || head-> col < 0 || head->col > COL){ |
lucoby | 0:3668e8f103be | 20 | return 0; |
lucoby | 0:3668e8f103be | 21 | } |
lucoby | 0:3668e8f103be | 22 | return 1; |
lucoby | 0:3668e8f103be | 23 | } |
lucoby | 0:3668e8f103be | 24 |