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 15:38:14 2020 +0000
Revision:
15:4ed54ff548cf
Parent:
14:9b4a219dd91e
Child:
19:bdfab290446a
Adding doxygen stage 2 (still having global autocorrect isues)

Who changed what in which revision?

UserRevisionLine numberNew contents of line
el18rg 10:b6e45e4acde7 1 #include "Swatter.h"
el18rg 11:93da75c1849d 2
el18rg 15:4ed54ff548cf 3 Swatter::Swatter() {} //Constuctor
el18rg 15:4ed54ff548cf 4 Swatter::~Swatter() {} //Destructor
el18rg 11:93da75c1849d 5
el18rg 15:4ed54ff548cf 6 void Swatter::init(int x,int height,int width) //initilises the swatter parameters
el18rg 10:b6e45e4acde7 7 {
el18rg 10:b6e45e4acde7 8 _x = x;
el18rg 10:b6e45e4acde7 9 _y = HEIGHT - 10;
el18rg 10:b6e45e4acde7 10 _height = height;
el18rg 10:b6e45e4acde7 11 _width = width;
el18rg 10:b6e45e4acde7 12 _speed = 1;
el18rg 10:b6e45e4acde7 13 }
el18rg 11:93da75c1849d 14
el18rg 15:4ed54ff548cf 15 void Swatter::draw(N5110 &lcd) //draws the swatter
el18rg 10:b6e45e4acde7 16 {
el18rg 15:4ed54ff548cf 17 const int swat[10][9] = { //The array for the swatter, 1=pixel turn on
el18rg 11:93da75c1849d 18 {1,1,1,1,1,1,1,1,1},
el18rg 11:93da75c1849d 19 {1,0,1,0,1,0,1,0,1},
el18rg 11:93da75c1849d 20 {1,1,0,1,0,1,0,1,1},
el18rg 11:93da75c1849d 21 {1,0,1,0,1,0,1,0,1},
el18rg 11:93da75c1849d 22 {1,1,0,1,0,1,0,1,1},
el18rg 11:93da75c1849d 23 {1,1,1,1,1,1,1,1,1},
el18rg 11:93da75c1849d 24 {0,0,0,0,1,0,0,0,0},
el18rg 11:93da75c1849d 25 {0,0,0,0,1,0,0,0,0},
el18rg 11:93da75c1849d 26 {0,0,0,0,1,0,0,0,0},
el18rg 11:93da75c1849d 27 {0,0,0,0,1,0,0,0,0},
el18rg 10:b6e45e4acde7 28 };
el18rg 15:4ed54ff548cf 29 lcd.drawSprite(_x,_y,10,9,(int *)swat); //draws the swatter
el18rg 10:b6e45e4acde7 30 }
el18rg 15:4ed54ff548cf 31 void Swatter::update(Direction d,float mag) //updates the direction of the swatter from the joystick movement
el18rg 10:b6e45e4acde7 32 {
el18rg 11:93da75c1849d 33 _speed = int(mag*10.0f);
el18rg 10:b6e45e4acde7 34 if (d == E) {
el18rg 10:b6e45e4acde7 35 _x+=_speed;
el18rg 10:b6e45e4acde7 36 } else if (d == W) {
el18rg 10:b6e45e4acde7 37 _x-=_speed;
el18rg 10:b6e45e4acde7 38 }
el18rg 10:b6e45e4acde7 39 if (_x < 1) {
el18rg 10:b6e45e4acde7 40 _x = 1;
el18rg 10:b6e45e4acde7 41 }
el18rg 10:b6e45e4acde7 42 if (_x > WIDTH - _width - 1) {
el18rg 10:b6e45e4acde7 43 _x = WIDTH - _width - 8;
el18rg 10:b6e45e4acde7 44 }
el18rg 10:b6e45e4acde7 45 }
el18rg 10:b6e45e4acde7 46
el18rg 15:4ed54ff548cf 47 Vector2D Swatter::get_pos() //gets the swatter's actual position
el18rg 11:93da75c1849d 48 {
el18rg 10:b6e45e4acde7 49 Vector2D p = {_x,_y};
el18rg 11:93da75c1849d 50 return p;
el18rg 10:b6e45e4acde7 51 }