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
SnakeEngine/SnakeEngine.h@8:32825d724856, 2020-06-05 (annotated)
- Committer:
- Psy1990
- Date:
- Fri Jun 05 06:29:17 2020 +0000
- Revision:
- 8:32825d724856
- Parent:
- 7:9bd49beccdd1
- Child:
- 9:25597bc0cecc
Moved everything into classes, still trying to get everything to work. So far the snake object and apple can spawn but not in the right place :(
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| Psy1990 | 7:9bd49beccdd1 | 1 | #ifndef SNAKEENGINE_H |
| Psy1990 | 7:9bd49beccdd1 | 2 | #define SNAKEENGINE_H |
| Psy1990 | 7:9bd49beccdd1 | 3 | |
| Psy1990 | 7:9bd49beccdd1 | 4 | #include "mbed.h" |
| Psy1990 | 7:9bd49beccdd1 | 5 | #include "N5110.h" |
| Psy1990 | 7:9bd49beccdd1 | 6 | #include "Gamepad.h" |
| Psy1990 | 8:32825d724856 | 7 | #include "Apple.h" |
| Psy1990 | 8:32825d724856 | 8 | #include "Snake.h" |
| Psy1990 | 8:32825d724856 | 9 | #include "Bitmap.h" |
| Psy1990 | 7:9bd49beccdd1 | 10 | |
| Psy1990 | 8:32825d724856 | 11 | // gap from edge of screen |
| Psy1990 | 8:32825d724856 | 12 | #define GAP 2 |
| Psy1990 | 7:9bd49beccdd1 | 13 | |
| Psy1990 | 7:9bd49beccdd1 | 14 | |
| Psy1990 | 7:9bd49beccdd1 | 15 | class SnakeEngine |
| Psy1990 | 7:9bd49beccdd1 | 16 | { |
| Psy1990 | 7:9bd49beccdd1 | 17 | |
| Psy1990 | 7:9bd49beccdd1 | 18 | public: |
| Psy1990 | 7:9bd49beccdd1 | 19 | SnakeEngine(); |
| Psy1990 | 7:9bd49beccdd1 | 20 | ~SnakeEngine(); |
| Psy1990 | 7:9bd49beccdd1 | 21 | |
| Psy1990 | 8:32825d724856 | 22 | void init(int apple_size, int snake_speed); |
| Psy1990 | 8:32825d724856 | 23 | void read_input(Gamepad &pad); |
| Psy1990 | 7:9bd49beccdd1 | 24 | void update(Gamepad &pad); |
| Psy1990 | 7:9bd49beccdd1 | 25 | void draw(N5110 &lcd); |
| Psy1990 | 7:9bd49beccdd1 | 26 | |
| Psy1990 | 7:9bd49beccdd1 | 27 | private: |
| Psy1990 | 7:9bd49beccdd1 | 28 | |
| Psy1990 | 7:9bd49beccdd1 | 29 | void print_score(N5110 &lcd); |
| Psy1990 | 7:9bd49beccdd1 | 30 | |
| Psy1990 | 8:32825d724856 | 31 | int sx; |
| Psy1990 | 8:32825d724856 | 32 | int sy; |
| Psy1990 | 8:32825d724856 | 33 | int ax; |
| Psy1990 | 8:32825d724856 | 34 | int ay; |
| Psy1990 | 8:32825d724856 | 35 | int _snake_h; |
| Psy1990 | 8:32825d724856 | 36 | int _snake_w; |
| Psy1990 | 8:32825d724856 | 37 | int _apple_size; |
| Psy1990 | 8:32825d724856 | 38 | int _snake_speed; |
| Psy1990 | 7:9bd49beccdd1 | 39 | |
| Psy1990 | 8:32825d724856 | 40 | Snake _s; |
| Psy1990 | 8:32825d724856 | 41 | Apple _a; |
| Psy1990 | 7:9bd49beccdd1 | 42 | Direction _dir; |
| Psy1990 | 7:9bd49beccdd1 | 43 | float _mag; |
| Psy1990 | 7:9bd49beccdd1 | 44 | |
| Psy1990 | 7:9bd49beccdd1 | 45 | }; |
| Psy1990 | 7:9bd49beccdd1 | 46 | |
| Psy1990 | 7:9bd49beccdd1 | 47 | #endif |