![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
project for 2035
Dependencies: mbed wave_player 4DGL-uLCD-SE MMA8452
snake.h@1:10330bce85cb, 2020-10-23 (annotated)
- Committer:
- DCchico
- Date:
- Fri Oct 23 16:18:39 2020 -0400
- Revision:
- 1:10330bce85cb
- Child:
- 2:4947d6a82971
shell-code
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
DCchico | 1:10330bce85cb | 1 | #define SNAKE_MAX_LENGTH 50 |
DCchico | 1:10330bce85cb | 2 | |
DCchico | 1:10330bce85cb | 3 | // Structure for holding detailed information about the snake |
DCchico | 1:10330bce85cb | 4 | typedef struct{ |
DCchico | 1:10330bce85cb | 5 | int speed; |
DCchico | 1:10330bce85cb | 6 | int speed_up_duration; |
DCchico | 1:10330bce85cb | 7 | bool go_through_wall; |
DCchico | 1:10330bce85cb | 8 | } Status; |
DCchico | 1:10330bce85cb | 9 | |
DCchico | 1:10330bce85cb | 10 | // Structure of coordinates in the map |
DCchico | 1:10330bce85cb | 11 | typedef struct{ |
DCchico | 1:10330bce85cb | 12 | int x; |
DCchico | 1:10330bce85cb | 13 | int y; |
DCchico | 1:10330bce85cb | 14 | } Coordinate; |
DCchico | 1:10330bce85cb | 15 | |
DCchico | 1:10330bce85cb | 16 | // Snake Structure |
DCchico | 1:10330bce85cb | 17 | typedef struct { |
DCchico | 1:10330bce85cb | 18 | int head_x, head_y, head_px, head_py; // Location of the head of the snake |
DCchico | 1:10330bce85cb | 19 | int length; // length of the snake |
DCchico | 1:10330bce85cb | 20 | Coordinate locations[SNAKE_MAX_LENGTH]; // Snake body locations |
DCchico | 1:10330bce85cb | 21 | Status snake_status; // Stauts of the snake |
DCchico | 1:10330bce85cb | 22 | int score; //Current score of the snake |
DCchico | 1:10330bce85cb | 23 | } Snake; |
DCchico | 1:10330bce85cb | 24 | |
DCchico | 1:10330bce85cb | 25 | // Initialize a snake structure |
DCchico | 1:10330bce85cb | 26 | // You want to assign initial values to each of the variables defined above |
DCchico | 1:10330bce85cb | 27 | // in the snake structure. |
DCchico | 1:10330bce85cb | 28 | void snake_init (Snake * snake); |