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
Swatter/Swatter.cpp@12:a8196d72a3e7, 2020-05-28 (annotated)
- Committer:
- el18rg
- Date:
- Thu May 28 21:20:47 2020 +0000
- Revision:
- 12:a8196d72a3e7
- Parent:
- 11:93da75c1849d
- Child:
- 14:9b4a219dd91e
Neaten 2
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
el18rg | 10:b6e45e4acde7 | 1 | #include "Swatter.h" |
el18rg | 11:93da75c1849d | 2 | |
el18rg | 11:93da75c1849d | 3 | Swatter::Swatter() {} |
el18rg | 11:93da75c1849d | 4 | Swatter::~Swatter() {} |
el18rg | 11:93da75c1849d | 5 | |
el18rg | 11:93da75c1849d | 6 | void Swatter::init(int x,int height,int width) |
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 | 11:93da75c1849d | 15 | void Swatter::draw(N5110 &lcd) |
el18rg | 10:b6e45e4acde7 | 16 | { |
el18rg | 11:93da75c1849d | 17 | const int man[10][9] = { |
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 | 10:b6e45e4acde7 | 29 | lcd.drawSprite(_x,_y,10,9,(int *)man); |
el18rg | 10:b6e45e4acde7 | 30 | } |
el18rg | 11:93da75c1849d | 31 | void Swatter::update(Direction d,float mag) |
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 | 11:93da75c1849d | 47 | Vector2D Swatter::get_pos() |
el18rg | 11:93da75c1849d | 48 | { |
el18rg | 10:b6e45e4acde7 | 49 | Vector2D p = {_x,_y}; |
el18rg | 11:93da75c1849d | 50 | return p; |
el18rg | 10:b6e45e4acde7 | 51 | } |