Rosie Gillman

Dependencies:   mbed Gamepad2 ELEC2645_Project_el18rg

Dependents:   ELEC2645_Project_el18rg

https://os.mbed.com/media/uploads/el18rg/bug_splat_logo.png

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 https://os.mbed.com/media/uploads/el18rg/buttons.png

Instructions

  1. Turn the gamepad on
  2. Wait for start screen and press start
  3. Move the joystick to control the swatter
  4. Splat the bug as fast as you can
  5. 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

https://os.mbed.com/media/uploads/el18rg/intro_screen1.jpg

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

https://os.mbed.com/media/uploads/el18rg/intro_screen_2.jpg

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

https://os.mbed.com/media/uploads/el18rg/gameplay.jpg

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 https://os.mbed.com/media/uploads/el18rg/end_screen.jpg
Committer:
el18rg
Date:
Fri May 29 14:59:59 2020 +0000
Revision:
14:9b4a219dd91e
Parent:
13:09bc615e6665
Child:
15:4ed54ff548cf
Adding doxygen stage 1 (having problems with global autocorrect)

Who changed what in which revision?

UserRevisionLine numberNew 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 14:9b4a219dd91e 33 /**
el18rg 14:9b4a219dd91e 34 * @
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 14:9b4a219dd91e 39 * @
el18rg 14:9b4a219dd91e 40 */
el18rg 7:b5ef03efe784 41 void update(N5110 & lcd, Gamepad & pad);
el18rg 14:9b4a219dd91e 42
el18rg 14:9b4a219dd91e 43 /**
el18rg 14:9b4a219dd91e 44 * @
el18rg 14:9b4a219dd91e 45 */
el18rg 13:09bc615e6665 46 void timer();
el18rg 14:9b4a219dd91e 47
el18rg 14:9b4a219dd91e 48 /** Draw the game
el18rg 14:9b4a219dd91e 49 * @return
el18rg 14:9b4a219dd91e 50 */
el18rg 11:93da75c1849d 51 void draw(N5110 &lcd);
el18rg 14:9b4a219dd91e 52
el18rg 14:9b4a219dd91e 53 /** Check side collisions
el18rg 14:9b4a219dd91e 54 * @
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 14:9b4a219dd91e 59 * @
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 14:9b4a219dd91e 64 * @
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 end; //end time
el18rg 14:9b4a219dd91e 80 clock_t clockTicksTaken; //time value
el18rg 14:9b4a219dd91e 81
el18rg 14:9b4a219dd91e 82 double timeInSeconds; //time in seconds of game
el18rg 14:9b4a219dd91e 83 double duration; //duration of game
el18rg 14:9b4a219dd91e 84
el18rg 9:e7dce4de0910 85 Bug _bug;
el18rg 7:b5ef03efe784 86 Splat _splat;
el18rg 10:b6e45e4acde7 87 Swatter _swatter;
el18rg 14:9b4a219dd91e 88 Direction _d;
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