Lab 6 for ECE 2036,a lame version of Galiga that needs to have the bullet fixed, but focuses on the concept of polymorphism
Dependencies: mbed 4DGL-uLCD-SE PinDetect
graphics.h
00001 #ifndef GRAPHICS_H 00002 #define GRAPHICS_H 00003 00004 #define POSITION 2 00005 00006 enum InputType {HIT,NO_HIT}; 00007 enum StateType {DAMAGE,NO_DAMAGE}; 00008 00009 00010 00011 //Base Class 00012 00013 class ScreenObjects 00014 { 00015 public: 00016 int getHealth(); 00017 void setHealth(int); 00018 int * getPosition(); 00019 void setPosition(int,int); 00020 int * getPrevPosition(); 00021 void setPrevPosition(int *); 00022 InputType getInput(); 00023 void setInput(InputType); 00024 StateType getState(); 00025 void setState(StateType); 00026 virtual void draw(int,int)=0; 00027 void erase(int,int); 00028 virtual void update()=0; 00029 int getDirection(); 00030 void setDirection(int); 00031 bool getDirPos(); 00032 void setDirPos(bool); 00033 00034 00035 private: 00036 int health; 00037 int Position[POSITION]; 00038 int * previousPosition; 00039 InputType input; 00040 StateType state; 00041 00042 int direction; 00043 bool dirPos; 00044 00045 }; 00046 00047 class BobAlien:public ScreenObjects 00048 { 00049 public: 00050 BobAlien(); 00051 void draw(int,int); 00052 void update(); 00053 void attack(); 00054 00055 private: 00056 bool bobBullet; 00057 }; 00058 00059 00060 class AliceAlien:public ScreenObjects 00061 { 00062 public: 00063 AliceAlien(); 00064 void draw(int,int); 00065 void update(); 00066 void attack(); 00067 00068 private: 00069 bool aliceBullet; 00070 00071 }; 00072 //Gears for the Ship 00073 enum GearShift {STOP,GEAR1,GEAR2,GEAR3}; 00074 00075 00076 00077 class Ship:public ScreenObjects 00078 { 00079 00080 public: 00081 Ship(); 00082 void draw(int,int); 00083 void attackBullet(); 00084 void update(); 00085 void attackRocket(); 00086 void setGear(GearShift); 00087 GearShift getGear(); 00088 virtual int move(double); 00089 friend class Bullet; 00090 int * getShipPosition(); 00091 void setShipPos(int *); 00092 00093 00094 private: 00095 int numBullets; 00096 int numRockets; 00097 GearShift gear; 00098 int * shipPos; 00099 00100 00101 00102 }; 00103 00104 00105 00106 class Bullet:public Ship 00107 { 00108 00109 public: 00110 Bullet(); 00111 void draw(int,int); 00112 void update(); 00113 //void launch(); 00114 bool getLoaded(); 00115 00116 private: 00117 bool load; 00118 bool trueDraw; 00119 00120 }; 00121 00122 00123 00124 class Rocket:public ScreenObjects 00125 { 00126 00127 public: 00128 Rocket(); 00129 void draw(int,int); 00130 void update(); 00131 void drawExplosion(); 00132 void launch(); 00133 00134 00135 }; 00136 00137 00138 #endif//End of Graphics h
Generated on Fri Aug 19 2022 02:30:07 by
1.7.2