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 Gamepad N5110
snake/snake.h@2:934daa65f73d, 2019-04-13 (annotated)
- Committer:
- 694617778
- Date:
- Sat Apr 13 15:45:03 2019 +0000
- Revision:
- 2:934daa65f73d
- Parent:
- 1:b49c36604125
- Child:
- 9:18b059e5abb9
t3
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| 694617778 | 1:b49c36604125 | 1 | #ifndef SNAKE_H |
| 694617778 | 1:b49c36604125 | 2 | #define SNAKE_H |
| 694617778 | 1:b49c36604125 | 3 | |
| 694617778 | 1:b49c36604125 | 4 | |
| 694617778 | 0:b67614a0c4cf | 5 | #include "mbed.h" |
| 694617778 | 0:b67614a0c4cf | 6 | #include "N5110.h" |
| 694617778 | 0:b67614a0c4cf | 7 | #include "Gamepad.h" |
| 694617778 | 0:b67614a0c4cf | 8 | |
| 694617778 | 0:b67614a0c4cf | 9 | class snake |
| 694617778 | 0:b67614a0c4cf | 10 | { |
| 694617778 | 0:b67614a0c4cf | 11 | |
| 694617778 | 0:b67614a0c4cf | 12 | public: |
| 694617778 | 0:b67614a0c4cf | 13 | snake(); |
| 694617778 | 1:b49c36604125 | 14 | ~snake(); |
| 694617778 | 1:b49c36604125 | 15 | void init(int size,int length); |
| 694617778 | 1:b49c36604125 | 16 | void update(int direction, int length); |
| 694617778 | 1:b49c36604125 | 17 | void draw(N5110 &lcd, int length); |
| 694617778 | 0:b67614a0c4cf | 18 | void add_score(); |
| 694617778 | 0:b67614a0c4cf | 19 | int get_score(); |
| 694617778 | 1:b49c36604125 | 20 | int get_length(); |
| 694617778 | 2:934daa65f73d | 21 | void check_eat(Gamepad &pad); |
| 694617778 | 2:934daa65f73d | 22 | void check_over(N5110 &lcd); |
| 694617778 | 2:934daa65f73d | 23 | int over; |
| 694617778 | 2:934daa65f73d | 24 | |
| 694617778 | 0:b67614a0c4cf | 25 | private: |
| 694617778 | 0:b67614a0c4cf | 26 | int _size; |
| 694617778 | 2:934daa65f73d | 27 | int _x [100]; |
| 694617778 | 2:934daa65f73d | 28 | int _y [100]; |
| 694617778 | 0:b67614a0c4cf | 29 | int _score; |
| 694617778 | 1:b49c36604125 | 30 | int _length; |
| 694617778 | 2:934daa65f73d | 31 | int ball_x; |
| 694617778 | 2:934daa65f73d | 32 | int ball_y; |
| 694617778 | 2:934daa65f73d | 33 | void ball(int length); |
| 694617778 | 0:b67614a0c4cf | 34 | |
| 694617778 | 1:b49c36604125 | 35 | }; |
| 694617778 | 1:b49c36604125 | 36 | #endif |