Rosie Gillman
Dependencies: mbed Gamepad2 ELEC2645_Project_el18rg
Dependents: ELEC2645_Project_el18rg
Rosemary Gillman 201265952
Objective
The goal of the game is to splat the bug as fast as you can using the swatter.
Controls
1 - Joystick - left/right to control the swatter 2 - Start button - starts the game 3 - Reset - resets the game 4 - Volume pot - adjusts the volume
Instructions
- Turn the gamepad on
- Wait for start screen and press start
- Move the joystick to control the swatter
- Splat the bug as fast as you can
- Press reset to play again
Gameplay
Start Screen 1
- Low pad tone plays for 0.5s
- Pad lights flash (200ms on/200ms off)
- Text saying "Bug Splat Leeds Edition" is displayed
- After 5 flashes the screen changes to Start Screen 2
Start Screen 2
- Pad lights stay on constantly
- Text reads "Splat the bug as fast as you can! Press start"
- When start is pressed the screen changes to Gamplay Screen
Gameplay Screen
- The timer begins
- Bug appears in the top right corner
- Swatter appears in the bottom left corner
- The bug bounces (with random velocity/direction) off the sides
- When the bug bounces off the wall a low pad tone is played each time for 0.1 seconds
- Swatter is controlled left to right with the joystick
- When the bug and swatter overlap the screen changes to the Ending Screen
Ending Screen
- Low pad tone plays for 0.5s
- The timer ends and its value is displayed
- Text reads "SPLAT (time) secs"
- Splats are drawn on the screen
Engine/Engine.h@24:6e6bcdd22159, 2020-05-29 (annotated)
- Committer:
- el18rg
- Date:
- Fri May 29 21:49:53 2020 +0000
- Revision:
- 24:6e6bcdd22159
- Parent:
- 22:0b207694a5f7
Final Submission. I have read and agreed with Statement of Academic Integrity
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
el18rg | 14:9b4a219dd91e | 1 | /** Engine Class |
el18rg | 14:9b4a219dd91e | 2 | * @brief Operates the game |
el18rg | 14:9b4a219dd91e | 3 | * @author Rosemary Gillman |
el18rg | 14:9b4a219dd91e | 4 | * @date April, 2020 |
el18rg | 14:9b4a219dd91e | 5 | */ |
el18rg | 2:b936aa854de2 | 6 | #ifndef ENGINE_H |
el18rg | 2:b936aa854de2 | 7 | #define ENGINE_H |
el18rg | 2:b936aa854de2 | 8 | |
el18rg | 2:b936aa854de2 | 9 | #include "mbed.h" |
el18rg | 2:b936aa854de2 | 10 | #include "N5110.h" |
el18rg | 2:b936aa854de2 | 11 | #include "Gamepad.h" |
el18rg | 9:e7dce4de0910 | 12 | #include "Bug.h" |
el18rg | 10:b6e45e4acde7 | 13 | #include "Swatter.h" |
el18rg | 7:b5ef03efe784 | 14 | #include "Splat.h" |
el18rg | 7:b5ef03efe784 | 15 | |
el18rg | 2:b936aa854de2 | 16 | class Engine |
el18rg | 2:b936aa854de2 | 17 | { |
el18rg | 2:b936aa854de2 | 18 | public: |
el18rg | 14:9b4a219dd91e | 19 | |
el18rg | 14:9b4a219dd91e | 20 | /** Constructor */ |
el18rg | 2:b936aa854de2 | 21 | Engine(); |
el18rg | 14:9b4a219dd91e | 22 | |
el18rg | 14:9b4a219dd91e | 23 | /** Destructor */ |
el18rg | 2:b936aa854de2 | 24 | ~Engine(); |
el18rg | 14:9b4a219dd91e | 25 | |
el18rg | 14:9b4a219dd91e | 26 | /** Set initalisation |
el18rg | 14:9b4a219dd91e | 27 | * @param the value of the swatter width, swatter heigh and speed (int) |
el18rg | 14:9b4a219dd91e | 28 | */ |
el18rg | 11:93da75c1849d | 29 | void init(int swatter_width,int swatter_height,int speed); |
el18rg | 14:9b4a219dd91e | 30 | |
el18rg | 15:4ed54ff548cf | 31 | /** Read the engine input |
el18rg | 15:4ed54ff548cf | 32 | * @return the values to the pad |
el18rg | 14:9b4a219dd91e | 33 | */ |
el18rg | 2:b936aa854de2 | 34 | void read_input(Gamepad &pad); |
el18rg | 14:9b4a219dd91e | 35 | |
el18rg | 14:9b4a219dd91e | 36 | /** Update the engine |
el18rg | 15:4ed54ff548cf | 37 | * @return the values to the pad and lcd |
el18rg | 14:9b4a219dd91e | 38 | */ |
el18rg | 7:b5ef03efe784 | 39 | void update(N5110 & lcd, Gamepad & pad); |
el18rg | 14:9b4a219dd91e | 40 | |
el18rg | 15:4ed54ff548cf | 41 | /** Time the duration of gameplay |
el18rg | 15:4ed54ff548cf | 42 | * @return the start time |
el18rg | 14:9b4a219dd91e | 43 | */ |
el18rg | 13:09bc615e6665 | 44 | void timer(); |
el18rg | 14:9b4a219dd91e | 45 | |
el18rg | 14:9b4a219dd91e | 46 | /** Draw the game |
el18rg | 15:4ed54ff548cf | 47 | * @return the values to the lcd |
el18rg | 14:9b4a219dd91e | 48 | */ |
el18rg | 11:93da75c1849d | 49 | void draw(N5110 &lcd); |
el18rg | 14:9b4a219dd91e | 50 | |
el18rg | 14:9b4a219dd91e | 51 | /** Check side collisions |
el18rg | 15:4ed54ff548cf | 52 | * @return the values to the pad |
el18rg | 14:9b4a219dd91e | 53 | */ |
el18rg | 14:9b4a219dd91e | 54 | void check_side_collision(Gamepad &pad); |
el18rg | 14:9b4a219dd91e | 55 | |
el18rg | 14:9b4a219dd91e | 56 | /** Check swatter/bug collisions |
el18rg | 15:4ed54ff548cf | 57 | * @return the values to the lcd/pad |
el18rg | 14:9b4a219dd91e | 58 | */ |
el18rg | 11:93da75c1849d | 59 | void check_swatter_collisions(N5110 & lcd, Gamepad & pad); |
el18rg | 14:9b4a219dd91e | 60 | |
el18rg | 14:9b4a219dd91e | 61 | /** End the game |
el18rg | 15:4ed54ff548cf | 62 | * @return the values to the lcd/pad |
el18rg | 14:9b4a219dd91e | 63 | */ |
el18rg | 7:b5ef03efe784 | 64 | void ending(N5110 & lcd, Gamepad & pad); |
el18rg | 11:93da75c1849d | 65 | |
el18rg | 2:b936aa854de2 | 66 | private: |
el18rg | 14:9b4a219dd91e | 67 | |
el18rg | 14:9b4a219dd91e | 68 | int height; //swatter height |
el18rg | 14:9b4a219dd91e | 69 | int width; //swatter width |
el18rg | 14:9b4a219dd91e | 70 | int x; //x-axis point |
el18rg | 14:9b4a219dd91e | 71 | int _speed; //bug speed |
el18rg | 14:9b4a219dd91e | 72 | int random_collision; //sets the |
el18rg | 14:9b4a219dd91e | 73 | |
el18rg | 14:9b4a219dd91e | 74 | float _mag; //magnitude |
el18rg | 14:9b4a219dd91e | 75 | |
el18rg | 14:9b4a219dd91e | 76 | clock_t start; //start time |
el18rg | 14:9b4a219dd91e | 77 | clock_t clockTicksTaken; //time value |
el18rg | 14:9b4a219dd91e | 78 | |
el18rg | 14:9b4a219dd91e | 79 | double timeInSeconds; //time in seconds of game |
el18rg | 14:9b4a219dd91e | 80 | double duration; //duration of game |
el18rg | 19:bdfab290446a | 81 | double final; //final time |
el18rg | 14:9b4a219dd91e | 82 | |
el18rg | 15:4ed54ff548cf | 83 | Bug _bug; //identifying the bug |
el18rg | 15:4ed54ff548cf | 84 | Splat _splat; //identifying the splat |
el18rg | 15:4ed54ff548cf | 85 | Swatter _swatter; //identifying the swatter |
el18rg | 15:4ed54ff548cf | 86 | Direction _d; //identifying the direction |
el18rg | 14:9b4a219dd91e | 87 | |
el18rg | 14:9b4a219dd91e | 88 | bool collisionX; //X-axis collision |
el18rg | 14:9b4a219dd91e | 89 | bool collisionY; //Y-axis collision |
el18rg | 14:9b4a219dd91e | 90 | |
el18rg | 2:b936aa854de2 | 91 | }; |
el18rg | 2:b936aa854de2 | 92 | #endif |