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.
Dependencies: mbed
Snake/Snake.cpp@5:b3ad78d527c7, 2018-04-30 (annotated)
- Committer:
- weiway
- Date:
- Mon Apr 30 23:37:41 2018 +0000
- Revision:
- 5:b3ad78d527c7
- Parent:
- 4:5b1c3b7cd894
- Child:
- 6:53c1fda99a3a
initial size of snake is 5 pixel so set to i = 0; i < _point ; i ++ _point = 6;the xold, yold , xnew and ynew are the positions of the snake pixel on x and y aixs respectively. The snake has initial pos as it has not started eating. Max array is 100.
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| weiway | 1:6bcf09972c0d | 1 | #include "Snake.h" |
| weiway | 1:6bcf09972c0d | 2 | |
| weiway | 1:6bcf09972c0d | 3 | |
| weiway | 1:6bcf09972c0d | 4 | Snake::Snake(){ |
| weiway | 1:6bcf09972c0d | 5 | |
| weiway | 1:6bcf09972c0d | 6 | } |
| weiway | 1:6bcf09972c0d | 7 | |
| weiway | 1:6bcf09972c0d | 8 | |
| weiway | 1:6bcf09972c0d | 9 | Snake::~Snake(){ |
| weiway | 1:6bcf09972c0d | 10 | |
| weiway | 1:6bcf09972c0d | 11 | } |
| weiway | 1:6bcf09972c0d | 12 | |
| weiway | 5:b3ad78d527c7 | 13 | void snake::init(){ |
| weiway | 5:b3ad78d527c7 | 14 | for (int i = 0; i <_point ; i++) { |
| weiway | 5:b3ad78d527c7 | 15 | _xoldpos[i] = 15; |
| weiway | 5:b3ad78d527c7 | 16 | _yoldpos[i] = 23; |
| weiway | 5:b3ad78d527c7 | 17 | _xnewpos[i] = 15 ; |
| weiway | 5:b3ad78d527c7 | 18 | _ynewpos[i] = 23; |
| weiway | 5:b3ad78d527c7 | 19 | } |
| weiway | 5:b3ad78d527c7 | 20 | dir = 0; |
| weiway | 4:5b1c3b7cd894 | 21 | _array = 100; |
| weiway | 5:b3ad78d527c7 | 22 | _point = 6; |
| weiway | 5:b3ad78d527c7 | 23 | } |
| weiway | 3:60df0fd90787 | 24 | |
| weiway | 1:6bcf09972c0d | 25 | |
| weiway | 1:6bcf09972c0d | 26 | |
| weiway | 1:6bcf09972c0d | 27 | |
| weiway | 1:6bcf09972c0d | 28 | |
| weiway | 1:6bcf09972c0d | 29 | |
| weiway | 1:6bcf09972c0d | 30 | |
| weiway | 1:6bcf09972c0d | 31 | |
| weiway | 1:6bcf09972c0d | 32 | |
| weiway | 1:6bcf09972c0d | 33 | |
| weiway | 1:6bcf09972c0d | 34 | |
| weiway | 1:6bcf09972c0d | 35 | |
| weiway | 1:6bcf09972c0d | 36 | |
| weiway | 1:6bcf09972c0d | 37 | |
| weiway | 1:6bcf09972c0d | 38 | |
| weiway | 1:6bcf09972c0d | 39 |