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 20:58:32 2020 +0000
Revision:
19:bdfab290446a
Parent:
16:33d8b58a1a65
Child:
23:aa2a10451586
All comments finished/checked

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 19:bdfab290446a 38 #ifdef WITH_TESTING //running tests
el18rg 19:bdfab290446a 39 int number_of_failures = run_all_tests();
el18rg 19:bdfab290446a 40
el18rg 19:bdfab290446a 41 if(number_of_failures > 0) return number_of_failures;
el18rg 19:bdfab290446a 42 #endif
el18rg 19:bdfab290446a 43
el18rg 19:bdfab290446a 44 first_init(); //first initilisation
el18rg 19:bdfab290446a 45 engine.timer(); //starts the timer
el18rg 19:bdfab290446a 46 start(); //runs the start screen
el18rg 19:bdfab290446a 47 while (1) { //while start is pressed
el18rg 19:bdfab290446a 48 engine.read_input(pad); //engine reads inputs
el18rg 19:bdfab290446a 49 engine.update(lcd, pad); //engine updates
el18rg 19:bdfab290446a 50 pad.leds_off(); //turns the leds off
el18rg 19:bdfab290446a 51 play_game(); //starts the gameplay
el18rg 19:bdfab290446a 52 wait_ms(80); //sets the fps
el18rg 2:b936aa854de2 53 }
el18rg 2:b936aa854de2 54 }
el18rg 2:b936aa854de2 55
el18rg 15:4ed54ff548cf 56 void first_init() //initilises the gamepad and screen
el18rg 2:b936aa854de2 57 {
el18rg 19:bdfab290446a 58 lcd.init(); //initalises the lcd
el18rg 19:bdfab290446a 59 pad.init(); //initlaises the gamepad
el18rg 19:bdfab290446a 60 engine.init(SWATTER_WIDTH,SWATTER_HEIGHT,BUG_SPEED); //initalises the engine with the input values
el18rg 2:b936aa854de2 61 }
el18rg 0:77899648f88b 62
el18rg 15:4ed54ff548cf 63 void play_game() //starts the game and timer
el18rg 2:b936aa854de2 64 {
el18rg 19:bdfab290446a 65 lcd.clear(); //clears the lcd
el18rg 19:bdfab290446a 66 engine.draw(lcd); //engine draws the gameplay
el18rg 19:bdfab290446a 67 lcd.refresh(); //refreshs the lcd
el18rg 2:b936aa854de2 68 }
el18rg 2:b936aa854de2 69
el18rg 15:4ed54ff548cf 70 void start() //displays the start screen
el18rg 2:b936aa854de2 71 {
el18rg 19:bdfab290446a 72 lcd.printString("Bug Splat",15,2); //lcd prints text
el18rg 19:bdfab290446a 73 lcd.printString("Leeds Edition",1,3); //lcd prints text
el18rg 19:bdfab290446a 74 lcd.refresh(); //lcd refreshes
el18rg 19:bdfab290446a 75 pad.tone(500.0,0.5); //low pad tone plays
el18rg 19:bdfab290446a 76 for (int i = 0; i < 5; i++) { //for loop flashes the leds
el18rg 0:77899648f88b 77 pad.leds_on();
el18rg 0:77899648f88b 78 wait_ms(200);
el18rg 0:77899648f88b 79 pad.leds_off();
el18rg 0:77899648f88b 80 wait_ms(200);
el18rg 0:77899648f88b 81 }
el18rg 19:bdfab290446a 82 pad.leds_off(); //leds are turned off
el18rg 19:bdfab290446a 83 lcd.clear(); //lcd is cleared
el18rg 19:bdfab290446a 84 lcd.refresh(); //lcd is refreshed
el18rg 19:bdfab290446a 85 lcd.printString("Splat the bug",0,0); //lcd prints text
el18rg 19:bdfab290446a 86 lcd.printString("as fast",0,1); //lcd prints text
el18rg 19:bdfab290446a 87 lcd.printString("as you can!",0,2); //lcd prints text
el18rg 19:bdfab290446a 88 lcd.printString("Press start",0,5); //lcd prints text
el18rg 19:bdfab290446a 89 lcd.refresh(); //lcd refreshes
el18rg 19:bdfab290446a 90 while ( pad.start_pressed() == false) { //when start is pressed lights turn off
el18rg 2:b936aa854de2 91 pad.leds_on();
el18rg 0:77899648f88b 92 }
el18rg 2:b936aa854de2 93 }