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
main.cpp@2:b936aa854de2, 2020-05-27 (annotated)
- Committer:
- el18rg
- Date:
- Wed May 27 01:35:20 2020 +0000
- Revision:
- 2:b936aa854de2
- Parent:
- 1:8fdb6a804c74
- Child:
- 7:b5ef03efe784
Basic function working (start-up, cup x movement, ball y movement, boundaries etc.)
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
el18rg | 0:77899648f88b | 1 | /* |
el18rg | 2:b936aa854de2 | 2 | ELEC2645 Embedded Systems Project |
el18rg | 2:b936aa854de2 | 3 | School of Electronic & Electrical Engineering |
el18rg | 2:b936aa854de2 | 4 | University of Leeds |
el18rg | 2:b936aa854de2 | 5 | 2019/20 |
el18rg | 2:b936aa854de2 | 6 | |
el18rg | 2:b936aa854de2 | 7 | Name: Rosemary Gillman |
el18rg | 2:b936aa854de2 | 8 | Username: EL18RG |
el18rg | 2:b936aa854de2 | 9 | Student ID Number: 201265952 |
el18rg | 2:b936aa854de2 | 10 | Date:10/03/20 |
el18rg | 0:77899648f88b | 11 | */ |
el18rg | 1:8fdb6a804c74 | 12 | |
el18rg | 2:b936aa854de2 | 13 | // includes |
el18rg | 0:77899648f88b | 14 | #include "mbed.h" |
el18rg | 0:77899648f88b | 15 | #include "Gamepad.h" |
el18rg | 0:77899648f88b | 16 | #include "N5110.h" |
el18rg | 2:b936aa854de2 | 17 | #include "Cups.h" |
el18rg | 2:b936aa854de2 | 18 | #include "Ball.h" |
el18rg | 2:b936aa854de2 | 19 | #include "Engine.h" |
el18rg | 0:77899648f88b | 20 | |
el18rg | 2:b936aa854de2 | 21 | #define PADDLE_WIDTH 2 |
el18rg | 2:b936aa854de2 | 22 | #define PADDLE_HEIGHT 8 |
el18rg | 2:b936aa854de2 | 23 | #define BALL_SIZE 2 |
el18rg | 2:b936aa854de2 | 24 | #define BALL_SPEED 3 |
el18rg | 2:b936aa854de2 | 25 | |
el18rg | 2:b936aa854de2 | 26 | // objects |
el18rg | 0:77899648f88b | 27 | Gamepad pad; |
el18rg | 0:77899648f88b | 28 | N5110 lcd; |
el18rg | 2:b936aa854de2 | 29 | Engine engine; |
el18rg | 2:b936aa854de2 | 30 | Cups cups; |
el18rg | 2:b936aa854de2 | 31 | Ball ball; |
el18rg | 2:b936aa854de2 | 32 | |
el18rg | 2:b936aa854de2 | 33 | //prototypes |
el18rg | 2:b936aa854de2 | 34 | void first_init(); |
el18rg | 2:b936aa854de2 | 35 | void start(); |
el18rg | 2:b936aa854de2 | 36 | void play_game(); |
el18rg | 0:77899648f88b | 37 | |
el18rg | 0:77899648f88b | 38 | int main() |
el18rg | 0:77899648f88b | 39 | { |
el18rg | 2:b936aa854de2 | 40 | first_init(); |
el18rg | 2:b936aa854de2 | 41 | start(); |
el18rg | 2:b936aa854de2 | 42 | while (1) { |
el18rg | 2:b936aa854de2 | 43 | engine.read_input(pad); |
el18rg | 2:b936aa854de2 | 44 | engine.update(pad); |
el18rg | 2:b936aa854de2 | 45 | pad.leds_off(); |
el18rg | 2:b936aa854de2 | 46 | play_game(); |
el18rg | 2:b936aa854de2 | 47 | wait_ms(80); |
el18rg | 2:b936aa854de2 | 48 | } |
el18rg | 2:b936aa854de2 | 49 | } |
el18rg | 2:b936aa854de2 | 50 | |
el18rg | 2:b936aa854de2 | 51 | void first_init() |
el18rg | 2:b936aa854de2 | 52 | { |
el18rg | 2:b936aa854de2 | 53 | lcd.init(); |
el18rg | 0:77899648f88b | 54 | pad.init(); |
el18rg | 2:b936aa854de2 | 55 | engine.init(PADDLE_WIDTH,PADDLE_HEIGHT,BALL_SIZE,BALL_SPEED); |
el18rg | 2:b936aa854de2 | 56 | } |
el18rg | 0:77899648f88b | 57 | |
el18rg | 2:b936aa854de2 | 58 | void play_game() |
el18rg | 2:b936aa854de2 | 59 | { |
el18rg | 2:b936aa854de2 | 60 | lcd.clear(); |
el18rg | 2:b936aa854de2 | 61 | engine.draw(lcd); |
el18rg | 2:b936aa854de2 | 62 | lcd.refresh(); |
el18rg | 2:b936aa854de2 | 63 | } |
el18rg | 2:b936aa854de2 | 64 | |
el18rg | 2:b936aa854de2 | 65 | void start() |
el18rg | 2:b936aa854de2 | 66 | { |
el18rg | 2:b936aa854de2 | 67 | lcd.printString("Beer Pong",15,2); |
el18rg | 0:77899648f88b | 68 | lcd.printString("Leeds Edition",1,3); |
el18rg | 0:77899648f88b | 69 | lcd.refresh(); |
el18rg | 2:b936aa854de2 | 70 | pad.tone(1000.0,2.0); |
el18rg | 2:b936aa854de2 | 71 | for (int i = 0; i < 5; i++) { |
el18rg | 0:77899648f88b | 72 | pad.leds_on(); |
el18rg | 0:77899648f88b | 73 | wait_ms(200); |
el18rg | 0:77899648f88b | 74 | pad.leds_off(); |
el18rg | 0:77899648f88b | 75 | wait_ms(200); |
el18rg | 0:77899648f88b | 76 | } |
el18rg | 2:b936aa854de2 | 77 | pad.leds_off(); |
el18rg | 0:77899648f88b | 78 | lcd.clear(); |
el18rg | 2:b936aa854de2 | 79 | lcd.refresh(); |
el18rg | 2:b936aa854de2 | 80 | lcd.printString("Instructions:",0,0); |
el18rg | 0:77899648f88b | 81 | lcd.printString("Use joystick",0,1); |
el18rg | 0:77899648f88b | 82 | lcd.printString("to aim.",0,2); |
el18rg | 0:77899648f88b | 83 | lcd.printString("X to fire.",0,3); |
el18rg | 0:77899648f88b | 84 | lcd.printString("Press start",0,4); |
el18rg | 0:77899648f88b | 85 | lcd.printString("to go.",0,5); |
el18rg | 0:77899648f88b | 86 | lcd.refresh(); |
el18rg | 2:b936aa854de2 | 87 | while ( pad.start_pressed() == false) { |
el18rg | 2:b936aa854de2 | 88 | pad.leds_on(); |
el18rg | 0:77899648f88b | 89 | } |
el18rg | 2:b936aa854de2 | 90 | } |