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.
Level/Level.h@9:96969b1c6bde, 2019-04-24 (annotated)
- Committer:
- joshdavy
- Date:
- Wed Apr 24 10:18:45 2019 +0000
- Revision:
- 9:96969b1c6bde
- Parent:
- 8:21b6d4dbce44
- Child:
- 11:db27d3838514
Added win screen aswell as multiple levels.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
joshdavy | 6:2ca1516ec1e2 | 1 | #ifndef LEVEL_H |
joshdavy | 6:2ca1516ec1e2 | 2 | #define LEVEL_H |
joshdavy | 6:2ca1516ec1e2 | 3 | |
joshdavy | 6:2ca1516ec1e2 | 4 | #include "mbed.h" |
joshdavy | 6:2ca1516ec1e2 | 5 | #include "N5110.h" |
joshdavy | 6:2ca1516ec1e2 | 6 | #include "Gamepad.h" |
joshdavy | 6:2ca1516ec1e2 | 7 | #include "Bitmap.h" |
joshdavy | 6:2ca1516ec1e2 | 8 | |
joshdavy | 7:68e06dda79f7 | 9 | |
joshdavy | 7:68e06dda79f7 | 10 | struct Block { |
joshdavy | 7:68e06dda79f7 | 11 | Vector2D first; |
joshdavy | 7:68e06dda79f7 | 12 | Vector2D second; |
joshdavy | 7:68e06dda79f7 | 13 | }; |
joshdavy | 7:68e06dda79f7 | 14 | |
joshdavy | 8:21b6d4dbce44 | 15 | struct MovingBlock { |
joshdavy | 9:96969b1c6bde | 16 | int index; |
joshdavy | 9:96969b1c6bde | 17 | int distance; |
joshdavy | 9:96969b1c6bde | 18 | |
joshdavy | 9:96969b1c6bde | 19 | int initial_pos; |
joshdavy | 9:96969b1c6bde | 20 | bool extending; |
joshdavy | 9:96969b1c6bde | 21 | |
joshdavy | 9:96969b1c6bde | 22 | |
joshdavy | 8:21b6d4dbce44 | 23 | }; |
joshdavy | 8:21b6d4dbce44 | 24 | |
joshdavy | 8:21b6d4dbce44 | 25 | const int goalMap[11][6] = { |
joshdavy | 8:21b6d4dbce44 | 26 | {0,1,0,0,0,0}, |
joshdavy | 8:21b6d4dbce44 | 27 | {0,1,0,0,0,0}, |
joshdavy | 8:21b6d4dbce44 | 28 | {0,1,1,0,0,0}, |
joshdavy | 8:21b6d4dbce44 | 29 | {0,1,1,1,1,0}, |
joshdavy | 8:21b6d4dbce44 | 30 | {0,1,1,1,1,1}, |
joshdavy | 8:21b6d4dbce44 | 31 | {0,1,1,1,1,0}, |
joshdavy | 8:21b6d4dbce44 | 32 | {0,1,1,0,0,0}, |
joshdavy | 8:21b6d4dbce44 | 33 | {0,1,0,0,0,0}, |
joshdavy | 8:21b6d4dbce44 | 34 | {0,1,0,0,0,0}, |
joshdavy | 8:21b6d4dbce44 | 35 | {0,1,0,0,0,0}, |
joshdavy | 8:21b6d4dbce44 | 36 | {1,1,1,1,0,0} |
joshdavy | 8:21b6d4dbce44 | 37 | }; |
joshdavy | 8:21b6d4dbce44 | 38 | |
joshdavy | 6:2ca1516ec1e2 | 39 | /*Level Class*/ |
joshdavy | 6:2ca1516ec1e2 | 40 | |
joshdavy | 6:2ca1516ec1e2 | 41 | |
joshdavy | 6:2ca1516ec1e2 | 42 | class Level { |
joshdavy | 6:2ca1516ec1e2 | 43 | |
joshdavy | 6:2ca1516ec1e2 | 44 | public: |
joshdavy | 6:2ca1516ec1e2 | 45 | Level(); |
joshdavy | 6:2ca1516ec1e2 | 46 | ~Level(); |
joshdavy | 9:96969b1c6bde | 47 | void init(Block blocks [], |
joshdavy | 8:21b6d4dbce44 | 48 | int number_of_blocks, |
joshdavy | 8:21b6d4dbce44 | 49 | Vector2D goal); |
joshdavy | 9:96969b1c6bde | 50 | void update_moving_blocks(); |
joshdavy | 6:2ca1516ec1e2 | 51 | void render(N5110 &lcd); |
joshdavy | 9:96969b1c6bde | 52 | void declare_moving_block(int index,bool extending,int distance); |
joshdavy | 9:96969b1c6bde | 53 | Block * get_blocks(); |
joshdavy | 9:96969b1c6bde | 54 | int get_number_of_blocks(); |
joshdavy | 9:96969b1c6bde | 55 | Vector2D get_goal(); |
joshdavy | 6:2ca1516ec1e2 | 56 | |
joshdavy | 6:2ca1516ec1e2 | 57 | |
joshdavy | 6:2ca1516ec1e2 | 58 | |
joshdavy | 6:2ca1516ec1e2 | 59 | private: |
joshdavy | 8:21b6d4dbce44 | 60 | Block _blocks [20] ; |
joshdavy | 6:2ca1516ec1e2 | 61 | int _number_of_blocks; |
joshdavy | 8:21b6d4dbce44 | 62 | int _number_of_moving_blocks; |
joshdavy | 8:21b6d4dbce44 | 63 | Vector2D _goal; |
joshdavy | 8:21b6d4dbce44 | 64 | MovingBlock _moving_blocks [10]; |
joshdavy | 6:2ca1516ec1e2 | 65 | }; |
joshdavy | 6:2ca1516ec1e2 | 66 | |
joshdavy | 6:2ca1516ec1e2 | 67 | #endif |