ELEC2645 (2019/20)
/
ELEC2645_Project_el17oc1
Owen Cavender 201159294
snake.h@8:997f90c88246, 2020-05-28 (annotated)
- Committer:
- el17oc
- Date:
- Thu May 28 18:50:56 2020 +0000
- Revision:
- 8:997f90c88246
- Parent:
- 6:bf90044188d0
- Child:
- 9:a69a6a06dddf
GG
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
el17oc | 1:897160a1a3ae | 1 | |
el17oc | 1:897160a1a3ae | 2 | #ifndef SNAKE_H |
el17oc | 1:897160a1a3ae | 3 | #define SNAKE_H |
el17oc | 1:897160a1a3ae | 4 | |
el17oc | 1:897160a1a3ae | 5 | #include "mbed.h" |
el17oc | 1:897160a1a3ae | 6 | #include "N5110.h" |
el17oc | 1:897160a1a3ae | 7 | #include "Gamepad.h" |
el17oc | 1:897160a1a3ae | 8 | |
el17oc | 1:897160a1a3ae | 9 | |
el17oc | 1:897160a1a3ae | 10 | class Snake |
el17oc | 1:897160a1a3ae | 11 | { |
el17oc | 1:897160a1a3ae | 12 | |
el17oc | 1:897160a1a3ae | 13 | |
el17oc | 1:897160a1a3ae | 14 | public: |
el17oc | 1:897160a1a3ae | 15 | Snake(); |
el17oc | 1:897160a1a3ae | 16 | ~Snake(); |
el17oc | 1:897160a1a3ae | 17 | |
el17oc | 1:897160a1a3ae | 18 | enum Directions { |
el17oc | 1:897160a1a3ae | 19 | up, |
el17oc | 1:897160a1a3ae | 20 | down, |
el17oc | 1:897160a1a3ae | 21 | left, |
el17oc | 1:897160a1a3ae | 22 | right, |
el17oc | 1:897160a1a3ae | 23 | null |
el17oc | 1:897160a1a3ae | 24 | }; |
el17oc | 1:897160a1a3ae | 25 | |
el17oc | 6:bf90044188d0 | 26 | void init(); |
el17oc | 6:bf90044188d0 | 27 | |
el17oc | 6:bf90044188d0 | 28 | |
el17oc | 6:bf90044188d0 | 29 | void check_collisions(); |
el17oc | 8:997f90c88246 | 30 | void apple_collected(N5110 &lcd, Gamepad &pad, Timer &timer); |
el17oc | 6:bf90044188d0 | 31 | |
el17oc | 6:bf90044188d0 | 32 | |
el17oc | 6:bf90044188d0 | 33 | |
el17oc | 8:997f90c88246 | 34 | void render_clear_tail(); |
el17oc | 8:997f90c88246 | 35 | void get_direction(Gamepad &pad); |
el17oc | 8:997f90c88246 | 36 | void move_snake(); |
el17oc | 8:997f90c88246 | 37 | void get_time(Timer &timer); |
el17oc | 8:997f90c88246 | 38 | void render(N5110 &lcd); |
el17oc | 8:997f90c88246 | 39 | |
el17oc | 8:997f90c88246 | 40 | |
el17oc | 6:bf90044188d0 | 41 | bool get_gameover(); |
el17oc | 6:bf90044188d0 | 42 | int get_score(); |
el17oc | 8:997f90c88246 | 43 | Vector2D get_Snakehead(); |
el17oc | 1:897160a1a3ae | 44 | |
el17oc | 1:897160a1a3ae | 45 | |
el17oc | 1:897160a1a3ae | 46 | |
el17oc | 1:897160a1a3ae | 47 | private: |
el17oc | 8:997f90c88246 | 48 | void get_Apple_position(N5110 &lcd); |
el17oc | 1:897160a1a3ae | 49 | |
el17oc | 1:897160a1a3ae | 50 | bool _gameover; |
el17oc | 1:897160a1a3ae | 51 | Directions _direction; |
el17oc | 1:897160a1a3ae | 52 | int _score; |
el17oc | 6:bf90044188d0 | 53 | float _realtime; |
el17oc | 8:997f90c88246 | 54 | float _display_time; |
el17oc | 6:bf90044188d0 | 55 | int Reset_value; |
el17oc | 6:bf90044188d0 | 56 | |
el17oc | 6:bf90044188d0 | 57 | |
el17oc | 6:bf90044188d0 | 58 | int _x0; |
el17oc | 6:bf90044188d0 | 59 | int _x1; |
el17oc | 6:bf90044188d0 | 60 | int _x2; |
el17oc | 6:bf90044188d0 | 61 | int _x3; |
el17oc | 6:bf90044188d0 | 62 | |
el17oc | 6:bf90044188d0 | 63 | int _y0; |
el17oc | 6:bf90044188d0 | 64 | int _y1; |
el17oc | 6:bf90044188d0 | 65 | int _y2; |
el17oc | 6:bf90044188d0 | 66 | int _y3; |
el17oc | 6:bf90044188d0 | 67 | |
el17oc | 6:bf90044188d0 | 68 | //Vector2D SK0; |
el17oc | 6:bf90044188d0 | 69 | //Vector2D SK1; |
el17oc | 6:bf90044188d0 | 70 | //Vector2D SK2; |
el17oc | 6:bf90044188d0 | 71 | //Vector2D SK3; |
el17oc | 1:897160a1a3ae | 72 | |
el17oc | 1:897160a1a3ae | 73 | }; |
el17oc | 1:897160a1a3ae | 74 | |
el17oc | 1:897160a1a3ae | 75 | |
el17oc | 1:897160a1a3ae | 76 | #endif |