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@19:bdfab290446a, 2020-05-29 (annotated)
- Committer:
- el18rg
- Date:
- Fri May 29 20:58:32 2020 +0000
- Revision:
- 19:bdfab290446a
- Parent:
- 16:33d8b58a1a65
- Child:
- 22:0b207694a5f7
All comments finished/checked
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 | #define GAP 2 |
el18rg | 2:b936aa854de2 | 17 | |
el18rg | 2:b936aa854de2 | 18 | class Engine |
el18rg | 2:b936aa854de2 | 19 | { |
el18rg | 2:b936aa854de2 | 20 | public: |
el18rg | 14:9b4a219dd91e | 21 | |
el18rg | 14:9b4a219dd91e | 22 | /** Constructor */ |
el18rg | 2:b936aa854de2 | 23 | Engine(); |
el18rg | 14:9b4a219dd91e | 24 | |
el18rg | 14:9b4a219dd91e | 25 | /** Destructor */ |
el18rg | 2:b936aa854de2 | 26 | ~Engine(); |
el18rg | 14:9b4a219dd91e | 27 | |
el18rg | 14:9b4a219dd91e | 28 | /** Set initalisation |
el18rg | 14:9b4a219dd91e | 29 | * @param the value of the swatter width, swatter heigh and speed (int) |
el18rg | 14:9b4a219dd91e | 30 | */ |
el18rg | 11:93da75c1849d | 31 | void init(int swatter_width,int swatter_height,int speed); |
el18rg | 14:9b4a219dd91e | 32 | |
el18rg | 15:4ed54ff548cf | 33 | /** Read the engine input |
el18rg | 15:4ed54ff548cf | 34 | * @return the values to the pad |
el18rg | 14:9b4a219dd91e | 35 | */ |
el18rg | 2:b936aa854de2 | 36 | void read_input(Gamepad &pad); |
el18rg | 14:9b4a219dd91e | 37 | |
el18rg | 14:9b4a219dd91e | 38 | /** Update the engine |
el18rg | 15:4ed54ff548cf | 39 | * @return the values to the pad and lcd |
el18rg | 14:9b4a219dd91e | 40 | */ |
el18rg | 7:b5ef03efe784 | 41 | void update(N5110 & lcd, Gamepad & pad); |
el18rg | 14:9b4a219dd91e | 42 | |
el18rg | 15:4ed54ff548cf | 43 | /** Time the duration of gameplay |
el18rg | 15:4ed54ff548cf | 44 | * @return the start time |
el18rg | 14:9b4a219dd91e | 45 | */ |
el18rg | 13:09bc615e6665 | 46 | void timer(); |
el18rg | 14:9b4a219dd91e | 47 | |
el18rg | 14:9b4a219dd91e | 48 | /** Draw the game |
el18rg | 15:4ed54ff548cf | 49 | * @return the values to the lcd |
el18rg | 14:9b4a219dd91e | 50 | */ |
el18rg | 11:93da75c1849d | 51 | void draw(N5110 &lcd); |
el18rg | 14:9b4a219dd91e | 52 | |
el18rg | 14:9b4a219dd91e | 53 | /** Check side collisions |
el18rg | 15:4ed54ff548cf | 54 | * @return the values to the pad |
el18rg | 14:9b4a219dd91e | 55 | */ |
el18rg | 14:9b4a219dd91e | 56 | void check_side_collision(Gamepad &pad); |
el18rg | 14:9b4a219dd91e | 57 | |
el18rg | 14:9b4a219dd91e | 58 | /** Check swatter/bug collisions |
el18rg | 15:4ed54ff548cf | 59 | * @return the values to the lcd/pad |
el18rg | 14:9b4a219dd91e | 60 | */ |
el18rg | 11:93da75c1849d | 61 | void check_swatter_collisions(N5110 & lcd, Gamepad & pad); |
el18rg | 14:9b4a219dd91e | 62 | |
el18rg | 14:9b4a219dd91e | 63 | /** End the game |
el18rg | 15:4ed54ff548cf | 64 | * @return the values to the lcd/pad |
el18rg | 14:9b4a219dd91e | 65 | */ |
el18rg | 7:b5ef03efe784 | 66 | void ending(N5110 & lcd, Gamepad & pad); |
el18rg | 11:93da75c1849d | 67 | |
el18rg | 2:b936aa854de2 | 68 | private: |
el18rg | 14:9b4a219dd91e | 69 | |
el18rg | 14:9b4a219dd91e | 70 | int height; //swatter height |
el18rg | 14:9b4a219dd91e | 71 | int width; //swatter width |
el18rg | 14:9b4a219dd91e | 72 | int x; //x-axis point |
el18rg | 14:9b4a219dd91e | 73 | int _speed; //bug speed |
el18rg | 14:9b4a219dd91e | 74 | int random_collision; //sets the |
el18rg | 14:9b4a219dd91e | 75 | |
el18rg | 14:9b4a219dd91e | 76 | float _mag; //magnitude |
el18rg | 14:9b4a219dd91e | 77 | |
el18rg | 14:9b4a219dd91e | 78 | clock_t start; //start time |
el18rg | 14:9b4a219dd91e | 79 | clock_t clockTicksTaken; //time value |
el18rg | 14:9b4a219dd91e | 80 | |
el18rg | 14:9b4a219dd91e | 81 | double timeInSeconds; //time in seconds of game |
el18rg | 14:9b4a219dd91e | 82 | double duration; //duration of game |
el18rg | 19:bdfab290446a | 83 | double final; //final time |
el18rg | 14:9b4a219dd91e | 84 | |
el18rg | 15:4ed54ff548cf | 85 | Bug _bug; //identifying the bug |
el18rg | 15:4ed54ff548cf | 86 | Splat _splat; //identifying the splat |
el18rg | 15:4ed54ff548cf | 87 | Swatter _swatter; //identifying the swatter |
el18rg | 15:4ed54ff548cf | 88 | Direction _d; //identifying the direction |
el18rg | 14:9b4a219dd91e | 89 | |
el18rg | 14:9b4a219dd91e | 90 | bool collisionX; //X-axis collision |
el18rg | 14:9b4a219dd91e | 91 | bool collisionY; //Y-axis collision |
el18rg | 14:9b4a219dd91e | 92 | |
el18rg | 2:b936aa854de2 | 93 | }; |
el18rg | 2:b936aa854de2 | 94 | #endif |