ELEC2645 (2018/19) / Mbed 2 deprecated el17aio

Dependencies:   mbed

Committer:
ikenna1
Date:
Sat May 04 05:37:33 2019 +0000
Revision:
37:8d8c8cce0bc7
Parent:
36:c25417f0d150
Child:
38:4571537238ed
Add random enemy spawning.; made a new function rand_no which uses the ctime library to seed srand() and generate random numbers which are used to set initial and reset positions of enemies.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ikenna1 2:66a4e5d7a7cd 1 #ifndef ROSENENGINE_H
ikenna1 2:66a4e5d7a7cd 2 #define ROSENENGINE_H
ikenna1 2:66a4e5d7a7cd 3
ikenna1 2:66a4e5d7a7cd 4 #include "mbed.h"
ikenna1 37:8d8c8cce0bc7 5 #include <ctime>
ikenna1 2:66a4e5d7a7cd 6 #include "N5110.h"
ikenna1 2:66a4e5d7a7cd 7 #include "Gamepad.h"
ikenna1 7:ed5870cfb3e0 8 #include "Ship.h"
ikenna1 9:241a1a7d8527 9 #include "Weapons.h"
ikenna1 9:241a1a7d8527 10 #include "Menu.h"
ikenna1 15:009ccc07bb57 11 #include "Enemy.h"
ikenna1 17:e65a9f981834 12 #include "Health.h"
ikenna1 2:66a4e5d7a7cd 13
ikenna1 2:66a4e5d7a7cd 14 class RosenEngine
ikenna1 2:66a4e5d7a7cd 15 {
ikenna1 2:66a4e5d7a7cd 16
ikenna1 2:66a4e5d7a7cd 17 public:
ikenna1 2:66a4e5d7a7cd 18 RosenEngine();
ikenna1 2:66a4e5d7a7cd 19 ~RosenEngine();
ikenna1 3:f9cd1a38d5c6 20
ikenna1 8:87a845b8575e 21 void init(int ship_width,int ship_height,int ship_speed,int ship_xpos,int ship_ypos);
ikenna1 27:f99249e727fd 22 void reset();
ikenna1 2:66a4e5d7a7cd 23 void read_input(Gamepad &pad);
ikenna1 2:66a4e5d7a7cd 24 void update(Gamepad &pad);
ikenna1 14:88ca5b1a111a 25 void draw(N5110 &lcd, Gamepad &pad);
ikenna1 9:241a1a7d8527 26 void get_pos();
ikenna1 10:c33d7593a275 27 void title(N5110 &lcd);
ikenna1 13:e114d362186d 28 int get_ycursor();
ikenna1 21:628fb703188f 29 int get_shipno();
ikenna1 12:47578eb9ea73 30 void ship_select(N5110 &lcd);
ikenna1 36:c25417f0d150 31 void check_health();
ikenna1 30:711d722f3cef 32
ikenna1 9:241a1a7d8527 33
ikenna1 9:241a1a7d8527 34 int ship_xpos;
ikenna1 9:241a1a7d8527 35 int ship_ypos;
ikenna1 9:241a1a7d8527 36 int ship_width;
ikenna1 25:faba9eb44514 37 int ship_height;
ikenna1 25:faba9eb44514 38 //*** note: add ship width and ship heirgth in place of 6 and 9 to generalize arrays after they are finished
ikenna1 10:c33d7593a275 39
ikenna1 2:66a4e5d7a7cd 40 private:
ikenna1 35:3341f2bd0408 41
ikenna1 30:711d722f3cef 42 void score(int points);
ikenna1 35:3341f2bd0408 43 bool check_collision(int xpos1, int ypos1,int width1,int height1,int xpos2, int ypos2,int width2,int height2);
ikenna1 35:3341f2bd0408 44 bool check_collision1(int xpos1,int width1,int xpos2,int width2);
ikenna1 35:3341f2bd0408 45 void test();
ikenna1 35:3341f2bd0408 46 void seeker_ship_collision(Gamepad &pad);
ikenna1 35:3341f2bd0408 47 void shooter_ship_collision(Gamepad &pad);
ikenna1 35:3341f2bd0408 48 void shooterw_ship_collision(Gamepad &pad);
ikenna1 35:3341f2bd0408 49 void kestrelw_seeker_collision(Gamepad &pad);
ikenna1 35:3341f2bd0408 50 void imperionw_seeker_collision(Gamepad &pad);
ikenna1 35:3341f2bd0408 51 void kestrelw_shooter_collision(Gamepad &pad);
ikenna1 35:3341f2bd0408 52 void imperionw_shooter_collision(Gamepad &pad);
ikenna1 37:8d8c8cce0bc7 53 int rand_no();
ikenna1 4:740e14ebbc97 54
ikenna1 36:c25417f0d150 55
ikenna1 4:740e14ebbc97 56 // Variables
ikenna1 8:87a845b8575e 57 Ship _ship;
ikenna1 9:241a1a7d8527 58 Weapons _weapons;
ikenna1 9:241a1a7d8527 59 Menu _menu;
ikenna1 15:009ccc07bb57 60 Enemy _enemy;
ikenna1 17:e65a9f981834 61 Health _health;
ikenna1 4:740e14ebbc97 62 float _xjoystick;
ikenna1 4:740e14ebbc97 63 float _yjoystick;
ikenna1 9:241a1a7d8527 64 Direction _d;
ikenna1 10:c33d7593a275 65 int _ycursor;
ikenna1 21:628fb703188f 66 int _shipno;
ikenna1 30:711d722f3cef 67 int _score;
ikenna1 34:6d0786582d81 68 int _shno;
ikenna1 34:6d0786582d81 69 Vector2D _shooter1_pos;
ikenna1 34:6d0786582d81 70 Vector2D _shooter2_pos;
ikenna1 34:6d0786582d81 71 Vector2D _shooter3_pos;
ikenna1 34:6d0786582d81 72 Vector2D _coloc;
ikenna1 36:c25417f0d150 73 bool _dead;
ikenna1 25:faba9eb44514 74
ikenna1 2:66a4e5d7a7cd 75
ikenna1 2:66a4e5d7a7cd 76 };
ikenna1 25:faba9eb44514 77 /************STUFF TO FIX******************************
ikenna1 28:6319e928f0aa 78 **** add sound effects for sjield braking
ikenna1 28:6319e928f0aa 79 **** add passive shield regeneration
ikenna1 29:4c7b16b5b6df 80 **** work on score increase
ikenna1 29:4c7b16b5b6df 81 **** add title screen with name
ikenna1 29:4c7b16b5b6df 82 **** make it so back asks you if you are sure and ststes that you will lose all progress
ikenna1 29:4c7b16b5b6df 83 **** think of level system
ikenna1 29:4c7b16b5b6df 84 **** orion should send out pulses that stun enemy ships and absorb thier shields(use draw line)
ikenna1 29:4c7b16b5b6df 85 **** scale shields properly
ikenna1 29:4c7b16b5b6df 86 **** fix the border issue(i.e the ships clip through healthbar)
ikenna1 30:711d722f3cef 87 **** make it so enemy ship spawning is random use srand
ikenna1 34:6d0786582d81 88 **** add in options for lcd brightness and contrast
ikenna1 34:6d0786582d81 89 **** add in cheats
ikenna1 34:6d0786582d81 90 ****
ikenna1 25:faba9eb44514 91 */
ikenna1 35:3341f2bd0408 92 #endif
ikenna1 35:3341f2bd0408 93 /*
ikenna1 36:c25417f0d150 94 changes not commited
ikenna1 36:c25417f0d150 95 *Fix game playing in background
ikenna1 36:c25417f0d150 96 *Change seeker damage to 175
ikenna1 36:c25417f0d150 97 *make seeker health 5
ikenna1 36:c25417f0d150 98 * implement a viewing system for enemy ships
ikenna1 36:c25417f0d150 99 * enemy comes from below very fast
ikenna1 36:c25417f0d150 100 * if you hold a button shields come up in front but not sides
ikenna1 36:c25417f0d150 101 *
ikenna1 36:c25417f0d150 102 *
ikenna1 35:3341f2bd0408 103 */