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 18:07:33 2020 +0000
Revision:
16:33d8b58a1a65
Parent:
15:4ed54ff548cf
Child:
19:bdfab290446a
Timer fully working

Who changed what in which revision?

UserRevisionLine numberNew 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 14:9b4a219dd91e 10 Date:20/03/20
el18rg 0:77899648f88b 11 */
el18rg 1:8fdb6a804c74 12
el18rg 15:4ed54ff548cf 13 /** pre-processor directives */
el18rg 0:77899648f88b 14 #include "mbed.h"
el18rg 0:77899648f88b 15 #include "Gamepad.h"
el18rg 0:77899648f88b 16 #include "N5110.h"
el18rg 10:b6e45e4acde7 17 #include "Swatter.h"
el18rg 9:e7dce4de0910 18 #include "Bug.h"
el18rg 2:b936aa854de2 19 #include "Engine.h"
el18rg 0:77899648f88b 20
el18rg 14:9b4a219dd91e 21 #define SWATTER_WIDTH 10
el18rg 14:9b4a219dd91e 22 #define SWATTER_HEIGHT 9
el18rg 9:e7dce4de0910 23 #define BUG_SPEED 3
el18rg 2:b936aa854de2 24
el18rg 15:4ed54ff548cf 25 /** objects */
el18rg 0:77899648f88b 26 Gamepad pad;
el18rg 0:77899648f88b 27 N5110 lcd;
el18rg 2:b936aa854de2 28 Engine engine;
el18rg 2:b936aa854de2 29
el18rg 15:4ed54ff548cf 30 /** prototypes */
el18rg 2:b936aa854de2 31 void first_init();
el18rg 2:b936aa854de2 32 void start();
el18rg 2:b936aa854de2 33 void play_game();
el18rg 0:77899648f88b 34
el18rg 15:4ed54ff548cf 35 /** functions */
el18rg 0:77899648f88b 36 int main()
el18rg 0:77899648f88b 37 {
el18rg 2:b936aa854de2 38 first_init();
el18rg 16:33d8b58a1a65 39 engine.timer();
el18rg 2:b936aa854de2 40 start();
el18rg 2:b936aa854de2 41 while (1) {
el18rg 2:b936aa854de2 42 engine.read_input(pad);
el18rg 7:b5ef03efe784 43 engine.update(lcd, pad);
el18rg 2:b936aa854de2 44 pad.leds_off();
el18rg 2:b936aa854de2 45 play_game();
el18rg 2:b936aa854de2 46 wait_ms(80);
el18rg 2:b936aa854de2 47 }
el18rg 2:b936aa854de2 48 }
el18rg 2:b936aa854de2 49
el18rg 15:4ed54ff548cf 50 void first_init() //initilises the gamepad and screen
el18rg 2:b936aa854de2 51 {
el18rg 2:b936aa854de2 52 lcd.init();
el18rg 0:77899648f88b 53 pad.init();
el18rg 11:93da75c1849d 54 engine.init(SWATTER_WIDTH,SWATTER_HEIGHT,BUG_SPEED);
el18rg 2:b936aa854de2 55 }
el18rg 0:77899648f88b 56
el18rg 15:4ed54ff548cf 57 void play_game() //starts the game and timer
el18rg 2:b936aa854de2 58 {
el18rg 2:b936aa854de2 59 lcd.clear();
el18rg 2:b936aa854de2 60 engine.draw(lcd);
el18rg 2:b936aa854de2 61 lcd.refresh();
el18rg 2:b936aa854de2 62 }
el18rg 2:b936aa854de2 63
el18rg 15:4ed54ff548cf 64 void start() //displays the start screen
el18rg 2:b936aa854de2 65 {
el18rg 9:e7dce4de0910 66 lcd.printString("Bug Splat",15,2);
el18rg 0:77899648f88b 67 lcd.printString("Leeds Edition",1,3);
el18rg 0:77899648f88b 68 lcd.refresh();
el18rg 7:b5ef03efe784 69 pad.tone(500.0,0.5);
el18rg 2:b936aa854de2 70 for (int i = 0; i < 5; i++) {
el18rg 0:77899648f88b 71 pad.leds_on();
el18rg 0:77899648f88b 72 wait_ms(200);
el18rg 0:77899648f88b 73 pad.leds_off();
el18rg 0:77899648f88b 74 wait_ms(200);
el18rg 0:77899648f88b 75 }
el18rg 2:b936aa854de2 76 pad.leds_off();
el18rg 0:77899648f88b 77 lcd.clear();
el18rg 2:b936aa854de2 78 lcd.refresh();
el18rg 9:e7dce4de0910 79 lcd.printString("Splat the bug",0,0);
el18rg 9:e7dce4de0910 80 lcd.printString("as fast",0,1);
el18rg 9:e7dce4de0910 81 lcd.printString("as you can!",0,2);
el18rg 16:33d8b58a1a65 82 lcd.printString("Press start",0,5);
el18rg 0:77899648f88b 83 lcd.refresh();
el18rg 2:b936aa854de2 84 while ( pad.start_pressed() == false) {
el18rg 2:b936aa854de2 85 pad.leds_on();
el18rg 0:77899648f88b 86 }
el18rg 2:b936aa854de2 87 }