Simple fish eat program
Dependencies: mbed mbed-rtos N5110 ShiftReg Tone
classes/Game.h@10:e221bd1ce3ec, 2021-04-20 (annotated)
- Committer:
- el18a2k
- Date:
- Tue Apr 20 15:35:00 2021 +0000
- Revision:
- 10:e221bd1ce3ec
- Parent:
- 9:d52c4df02493
- Child:
- 11:7c1e2a9303d3
gameplay implemented
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
el18a2k | 10:e221bd1ce3ec | 1 | #ifndef GAME_H |
el18a2k | 10:e221bd1ce3ec | 2 | #define GAME_H |
el18a2k | 10:e221bd1ce3ec | 3 | |
el18a2k | 10:e221bd1ce3ec | 4 | #include "mbed.h" |
el18a2k | 10:e221bd1ce3ec | 5 | #include "N5110.h" |
el18a2k | 10:e221bd1ce3ec | 6 | #include "Joystick.h" |
el18a2k | 10:e221bd1ce3ec | 7 | #include "ShiftReg.h" |
el18a2k | 10:e221bd1ce3ec | 8 | |
el18a2k | 10:e221bd1ce3ec | 9 | #include "Graphics.h" |
el18a2k | 10:e221bd1ce3ec | 10 | |
el18a2k | 10:e221bd1ce3ec | 11 | struct DIRECTION { |
el18a2k | 10:e221bd1ce3ec | 12 | Direction joy; |
el18a2k | 10:e221bd1ce3ec | 13 | }; |
el18a2k | 10:e221bd1ce3ec | 14 | |
el18a2k | 10:e221bd1ce3ec | 15 | class Game { |
el18a2k | 10:e221bd1ce3ec | 16 | |
el18a2k | 10:e221bd1ce3ec | 17 | public: |
el18a2k | 10:e221bd1ce3ec | 18 | |
el18a2k | 10:e221bd1ce3ec | 19 | //plays the game |
el18a2k | 10:e221bd1ce3ec | 20 | void gamePlay(N5110 &lcd, DIRECTION direction); |
el18a2k | 10:e221bd1ce3ec | 21 | |
el18a2k | 10:e221bd1ce3ec | 22 | //draws the playing area |
el18a2k | 10:e221bd1ce3ec | 23 | void init(N5110 &lcd, int x, int y, int Fish_size); |
el18a2k | 10:e221bd1ce3ec | 24 | |
el18a2k | 10:e221bd1ce3ec | 25 | //draws fish |
el18a2k | 10:e221bd1ce3ec | 26 | void drawFish(N5110 &lcd); |
el18a2k | 10:e221bd1ce3ec | 27 | |
el18a2k | 10:e221bd1ce3ec | 28 | //updates fish position |
el18a2k | 10:e221bd1ce3ec | 29 | void fishPos(DIRECTION direction); |
el18a2k | 10:e221bd1ce3ec | 30 | |
el18a2k | 10:e221bd1ce3ec | 31 | //Keeps score |
el18a2k | 10:e221bd1ce3ec | 32 | int Score(N5110 &lcd); |
el18a2k | 10:e221bd1ce3ec | 33 | |
el18a2k | 10:e221bd1ce3ec | 34 | //keeps track of lives |
el18a2k | 10:e221bd1ce3ec | 35 | int Lives(); |
el18a2k | 10:e221bd1ce3ec | 36 | |
el18a2k | 10:e221bd1ce3ec | 37 | //check for collision with other fish |
el18a2k | 10:e221bd1ce3ec | 38 | int Collision(); |
el18a2k | 10:e221bd1ce3ec | 39 | |
el18a2k | 10:e221bd1ce3ec | 40 | //generate enemy fish |
el18a2k | 10:e221bd1ce3ec | 41 | void enemyFish(N5110 &lcd); |
el18a2k | 10:e221bd1ce3ec | 42 | |
el18a2k | 10:e221bd1ce3ec | 43 | private: |
el18a2k | 10:e221bd1ce3ec | 44 | int _x; |
el18a2k | 10:e221bd1ce3ec | 45 | int _y; |
el18a2k | 10:e221bd1ce3ec | 46 | int X; |
el18a2k | 10:e221bd1ce3ec | 47 | int Y; |
el18a2k | 10:e221bd1ce3ec | 48 | int lives; |
el18a2k | 10:e221bd1ce3ec | 49 | int check_width; |
el18a2k | 10:e221bd1ce3ec | 50 | int rect_width; |
el18a2k | 10:e221bd1ce3ec | 51 | int barIncrement; |
el18a2k | 10:e221bd1ce3ec | 52 | int FISH_SIZE; |
el18a2k | 10:e221bd1ce3ec | 53 | int FISH_HEIGHT; |
el18a2k | 10:e221bd1ce3ec | 54 | int FISH_WIDTH; |
el18a2k | 10:e221bd1ce3ec | 55 | float CENTRE_X; |
el18a2k | 10:e221bd1ce3ec | 56 | float CENTRE_Y; |
el18a2k | 10:e221bd1ce3ec | 57 | int E_FISH_HEIGHT; |
el18a2k | 10:e221bd1ce3ec | 58 | int E_FISH_WIDTH; |
el18a2k | 10:e221bd1ce3ec | 59 | int E_FISH; |
el18a2k | 10:e221bd1ce3ec | 60 | float E_CENTRE_X; |
el18a2k | 10:e221bd1ce3ec | 61 | float E_CENTRE_Y; |
el18a2k | 10:e221bd1ce3ec | 62 | int collision; |
el18a2k | 10:e221bd1ce3ec | 63 | int x_bound; |
el18a2k | 10:e221bd1ce3ec | 64 | int y_bound; |
el18a2k | 10:e221bd1ce3ec | 65 | |
el18a2k | 10:e221bd1ce3ec | 66 | float centre_xpos; |
el18a2k | 10:e221bd1ce3ec | 67 | float centre_ypos; |
el18a2k | 10:e221bd1ce3ec | 68 | |
el18a2k | 10:e221bd1ce3ec | 69 | int check_score; |
el18a2k | 10:e221bd1ce3ec | 70 | int SCORE; |
el18a2k | 10:e221bd1ce3ec | 71 | char _score[14]; |
el18a2k | 10:e221bd1ce3ec | 72 | int s_length; |
el18a2k | 10:e221bd1ce3ec | 73 | |
el18a2k | 10:e221bd1ce3ec | 74 | }; |
el18a2k | 10:e221bd1ce3ec | 75 | |
el18a2k | 10:e221bd1ce3ec | 76 | #endif |