Simple fish eat program

Dependencies:   mbed mbed-rtos N5110 ShiftReg Tone

Committer:
el18a2k
Date:
Wed Apr 21 15:24:31 2021 +0000
Revision:
12:20ac766b3175
Parent:
11:7c1e2a9303d3
Child:
13:183bd19f3d7d
lots of bugs

Who changed what in which revision?

UserRevisionLine numberNew 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 12:20ac766b3175 6 #include "ShiftReg.h"
el18a2k 10:e221bd1ce3ec 7 #include "Joystick.h"
el18a2k 10:e221bd1ce3ec 8
el18a2k 10:e221bd1ce3ec 9 #include "Graphics.h"
el18a2k 12:20ac766b3175 10 #include "Sound.h"
el18a2k 10:e221bd1ce3ec 11
el18a2k 10:e221bd1ce3ec 12 struct DIRECTION {
el18a2k 10:e221bd1ce3ec 13 Direction joy;
el18a2k 10:e221bd1ce3ec 14 };
el18a2k 10:e221bd1ce3ec 15
el18a2k 10:e221bd1ce3ec 16 class Game {
el18a2k 10:e221bd1ce3ec 17
el18a2k 10:e221bd1ce3ec 18 public:
el18a2k 10:e221bd1ce3ec 19
el18a2k 10:e221bd1ce3ec 20 //plays the game
el18a2k 12:20ac766b3175 21 void gamePlay(N5110 &lcd, Tone &dac, DIRECTION direction);
el18a2k 10:e221bd1ce3ec 22
el18a2k 10:e221bd1ce3ec 23 //draws the playing area
el18a2k 10:e221bd1ce3ec 24 void init(N5110 &lcd, int x, int y, int Fish_size);
el18a2k 10:e221bd1ce3ec 25
el18a2k 10:e221bd1ce3ec 26 //draws fish
el18a2k 10:e221bd1ce3ec 27 void drawFish(N5110 &lcd);
el18a2k 10:e221bd1ce3ec 28
el18a2k 10:e221bd1ce3ec 29 //updates fish position
el18a2k 10:e221bd1ce3ec 30 void fishPos(DIRECTION direction);
el18a2k 10:e221bd1ce3ec 31
el18a2k 10:e221bd1ce3ec 32 //Keeps score
el18a2k 10:e221bd1ce3ec 33 int Score(N5110 &lcd);
el18a2k 10:e221bd1ce3ec 34
el18a2k 10:e221bd1ce3ec 35 //keeps track of lives
el18a2k 10:e221bd1ce3ec 36 int Lives();
el18a2k 10:e221bd1ce3ec 37
el18a2k 10:e221bd1ce3ec 38 //check for collision with other fish
el18a2k 12:20ac766b3175 39 int Collision(Tone &dac);
el18a2k 10:e221bd1ce3ec 40
el18a2k 10:e221bd1ce3ec 41 //generate enemy fish
el18a2k 10:e221bd1ce3ec 42 void enemyFish(N5110 &lcd);
el18a2k 10:e221bd1ce3ec 43
el18a2k 10:e221bd1ce3ec 44 private:
el18a2k 10:e221bd1ce3ec 45 int _x;
el18a2k 10:e221bd1ce3ec 46 int _y;
el18a2k 10:e221bd1ce3ec 47 int X;
el18a2k 10:e221bd1ce3ec 48 int Y;
el18a2k 11:7c1e2a9303d3 49 int i;
el18a2k 11:7c1e2a9303d3 50 int colour;
el18a2k 10:e221bd1ce3ec 51 int lives;
el18a2k 10:e221bd1ce3ec 52 int check_width;
el18a2k 10:e221bd1ce3ec 53 int rect_width;
el18a2k 10:e221bd1ce3ec 54 int barIncrement;
el18a2k 10:e221bd1ce3ec 55 int FISH_SIZE;
el18a2k 10:e221bd1ce3ec 56 int FISH_HEIGHT;
el18a2k 10:e221bd1ce3ec 57 int FISH_WIDTH;
el18a2k 10:e221bd1ce3ec 58 int E_FISH_HEIGHT;
el18a2k 10:e221bd1ce3ec 59 int E_FISH_WIDTH;
el18a2k 10:e221bd1ce3ec 60 int E_FISH;
el18a2k 10:e221bd1ce3ec 61 int collision;
el18a2k 10:e221bd1ce3ec 62 int x_bound;
el18a2k 10:e221bd1ce3ec 63 int y_bound;
el18a2k 12:20ac766b3175 64 int check_score;
el18a2k 12:20ac766b3175 65 int SCORE;
el18a2k 12:20ac766b3175 66 int s_length;
el18a2k 10:e221bd1ce3ec 67 float centre_xpos;
el18a2k 10:e221bd1ce3ec 68 float centre_ypos;
el18a2k 12:20ac766b3175 69 float CENTRE_X;
el18a2k 12:20ac766b3175 70 float CENTRE_Y;
el18a2k 12:20ac766b3175 71 float E_CENTRE_X;
el18a2k 12:20ac766b3175 72 float E_CENTRE_Y;
el18a2k 10:e221bd1ce3ec 73 char _score[14];
el18a2k 10:e221bd1ce3ec 74
el18a2k 10:e221bd1ce3ec 75 };
el18a2k 10:e221bd1ce3ec 76
el18a2k 10:e221bd1ce3ec 77 #endif