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.
Dependencies: mbed
SpaceInvaderEngine/SpaceInvaderEngine.h@35:517b56b010df, 2020-05-18 (annotated)
- Committer:
- josh_ohara
- Date:
- Mon May 18 19:26:06 2020 +0000
- Revision:
- 35:517b56b010df
- Parent:
- 33:d8284dee58db
- Child:
- 37:90a0671d2ba7
Powerup function added
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| josh_ohara | 6:5bea67cc96f9 | 1 | #ifndef SPACEINVADERENGINE_H |
| josh_ohara | 6:5bea67cc96f9 | 2 | #define SPACEINVADERENGINE_H |
| josh_ohara | 6:5bea67cc96f9 | 3 | |
| josh_ohara | 6:5bea67cc96f9 | 4 | #include "mbed.h" |
| josh_ohara | 6:5bea67cc96f9 | 5 | #include "N5110.h" |
| josh_ohara | 6:5bea67cc96f9 | 6 | #include "Gamepad.h" |
| josh_ohara | 6:5bea67cc96f9 | 7 | #include "Ship.h" |
| josh_ohara | 12:be491ab6e742 | 8 | #include "Armada.h" |
| josh_ohara | 15:dde4ce4bf7fe | 9 | #include "Cover.h" |
| josh_ohara | 11:c174d84e4866 | 10 | #include <vector> |
| josh_ohara | 6:5bea67cc96f9 | 11 | |
| josh_ohara | 6:5bea67cc96f9 | 12 | #define BORDER 2 |
| josh_ohara | 6:5bea67cc96f9 | 13 | |
| josh_ohara | 6:5bea67cc96f9 | 14 | class SpaceInvaderEngine |
| josh_ohara | 6:5bea67cc96f9 | 15 | { |
| josh_ohara | 6:5bea67cc96f9 | 16 | |
| josh_ohara | 6:5bea67cc96f9 | 17 | public: |
| josh_ohara | 6:5bea67cc96f9 | 18 | SpaceInvaderEngine(); |
| josh_ohara | 8:86cb9a9f8a73 | 19 | ~SpaceInvaderEngine(); |
| josh_ohara | 33:d8284dee58db | 20 | void init(int ship_height, int ship_width, int alien_size, int no_aliens, int armada_column_size, int armada_row_size, int cover_y, int cover1_x, int cover2_x, int cover3_x, int no_rocks, int level); //initialise all needed objects and set private member variables |
| josh_ohara | 33:d8284dee58db | 21 | void read_input(Gamepad &pad); //read the gamepad input (buttons and joystick) |
| josh_ohara | 33:d8284dee58db | 22 | void update(Gamepad &pad, N5110 &lcd, int counter, int level); //update all objects |
| josh_ohara | 33:d8284dee58db | 23 | void render(N5110 &lcd); //draw all objects |
| josh_ohara | 33:d8284dee58db | 24 | void ship_bullet_alien_collision(Gamepad &pad, N5110 &lcd); //check for collision between the ship bullets and the aliens |
| josh_ohara | 33:d8284dee58db | 25 | void ship_bullet_cover1_collision(Gamepad &pad, N5110 &lcd); //check for collision between the ship bullets and cover 1 |
| josh_ohara | 33:d8284dee58db | 26 | void ship_bullet_cover2_collision(Gamepad &pad, N5110 &lcd); //check for collision between the ship bullets and cover 2 |
| josh_ohara | 33:d8284dee58db | 27 | void ship_bullet_cover3_collision(Gamepad &pad, N5110 &lcd); //check for collision between the ship bullets and cover 3 |
| josh_ohara | 33:d8284dee58db | 28 | void alien_bullet_ship_collision(Gamepad &pad, N5110 &lcd); //check for collision between the alien bullets and the ship |
| josh_ohara | 33:d8284dee58db | 29 | void alien_bullet_cover3_collision(Gamepad &pad, N5110 &lcd); //check for collision between the alien bullets and cover 3 |
| josh_ohara | 33:d8284dee58db | 30 | void alien_bullet_cover1_collision(Gamepad &pad, N5110 &lcd); //check for collision between the alien bullets and cover 1 |
| josh_ohara | 33:d8284dee58db | 31 | void alien_bullet_cover2_collision(Gamepad &pad, N5110 &lcd); //check for collision between the alien bullets and cover 2 |
| josh_ohara | 33:d8284dee58db | 32 | void alien_ship_collision(Gamepad &pad, N5110 &lcd); //check for collision between the aliens and the ship |
| josh_ohara | 33:d8284dee58db | 33 | void alien_cover1_collision(Gamepad &pad, N5110 &lcd); //check for collision between the aliens and cover 1 |
| josh_ohara | 33:d8284dee58db | 34 | void alien_cover2_collision(Gamepad &pad, N5110 &lcd); //check for collision between the aliens and cover 2 |
| josh_ohara | 33:d8284dee58db | 35 | void alien_cover3_collision(Gamepad &pad, N5110 &lcd); //check for collision between the aliens and cover 3 |
| josh_ohara | 35:517b56b010df | 36 | void ship_powerup_collision(Gamepad &pad, N5110 &lcd); |
| josh_ohara | 33:d8284dee58db | 37 | //accessors and mutators// |
| josh_ohara | 33:d8284dee58db | 38 | void get_ship_pos(); //return the position of ths ship |
| josh_ohara | 33:d8284dee58db | 39 | bool get_armada_life(); //return the life value of the alien armada |
| josh_ohara | 33:d8284dee58db | 40 | bool get_ship_life(); //return the life value of the ship |
| josh_ohara | 33:d8284dee58db | 41 | void kill_all(); //set life value of all objects to 0 |
| josh_ohara | 14:e88bcf5c0887 | 42 | |
| josh_ohara | 6:5bea67cc96f9 | 43 | private: |
| josh_ohara | 6:5bea67cc96f9 | 44 | |
| josh_ohara | 33:d8284dee58db | 45 | Armada _armada; //armada (vector of aliens) object |
| josh_ohara | 33:d8284dee58db | 46 | Ship _ship; //ship object |
| josh_ohara | 33:d8284dee58db | 47 | BulletS _ship_bullets; //ship bullet vector |
| josh_ohara | 33:d8284dee58db | 48 | Cover _cover_1; //cover object (vector of rocks) |
| josh_ohara | 33:d8284dee58db | 49 | Cover _cover_2; //cover object (vector of rocks) |
| josh_ohara | 33:d8284dee58db | 50 | Cover _cover_3; //cover object (vector of rocks) |
| josh_ohara | 6:5bea67cc96f9 | 51 | |
| josh_ohara | 33:d8284dee58db | 52 | int _ship_height; //height of ship |
| josh_ohara | 33:d8284dee58db | 53 | int _ship_width; //width of ship |
| josh_ohara | 33:d8284dee58db | 54 | int _alien_size; //size of alien |
| josh_ohara | 33:d8284dee58db | 55 | int _alien_number; //number of aliens |
| josh_ohara | 33:d8284dee58db | 56 | int _armada_column_size; //number of of aliens per column of armada |
| josh_ohara | 33:d8284dee58db | 57 | int _armada_row_size; //number of aliens per row of armada |
| josh_ohara | 35:517b56b010df | 58 | int _powerup; |
| josh_ohara | 6:5bea67cc96f9 | 59 | |
| josh_ohara | 33:d8284dee58db | 60 | int _ship_x; //x position of ship |
| josh_ohara | 33:d8284dee58db | 61 | int _ship_y; //y position of ship |
| josh_ohara | 33:d8284dee58db | 62 | int _cover_y; //y position of covers |
| josh_ohara | 33:d8284dee58db | 63 | int _cover_1_x; //x position of cover 1 |
| josh_ohara | 33:d8284dee58db | 64 | int _cover_2_x; //x position of cover 2 |
| josh_ohara | 33:d8284dee58db | 65 | int _cover_3_x; //x position of cover 3 |
| josh_ohara | 33:d8284dee58db | 66 | int _rock_number; //number of rocks per cover |
| josh_ohara | 33:d8284dee58db | 67 | |
| josh_ohara | 12:be491ab6e742 | 68 | |
| josh_ohara | 33:d8284dee58db | 69 | Direction D; //direction of joystick |
| josh_ohara | 33:d8284dee58db | 70 | float _mag; //magnitude of joystick offset |
| josh_ohara | 6:5bea67cc96f9 | 71 | }; |
| josh_ohara | 6:5bea67cc96f9 | 72 | |
| josh_ohara | 6:5bea67cc96f9 | 73 | #endif |