Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: Enemy1 Enemy2 Enemy3 Enemy4 Enemy5 Enemy6 Engine Friendly Gamepad N5110 Rocket Stats mbed
main.cpp
- Committer:
- musallambseiso
- Date:
- 2017-04-10
- Revision:
- 5:638ffc5c66f6
- Parent:
- 4:9660fc7ede8c
- Child:
- 6:0ad91977f14f
File content as of revision 5:638ffc5c66f6:
#include "mbed.h" #include "Gamepad.h" #include "N5110.h" #include "Engine.h" #define FRIENDLY_WIDTH 6 #define FRIENDLY_HEIGHT 6 #define SHIP_SIZE 1 #define SHIP_SPEED 3 struct UserInput { Direction d; float mag; }; N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11); Gamepad pad; Engine engine; void init(); void update_game(UserInput input); void generate(); void welcome(); int main() { int fps = 14; init(); welcome(); generate(); wait(1.0f/fps); while (1) { engine.read_input(pad); engine.checker(lcd, pad); engine.update(lcd, pad); //engine.shoot(lcd, pad, SHIP_SPEED); generate(); lcd.refresh(); wait(1.0f/fps); } } void init() { lcd.init(); pad.init(); engine.init(FRIENDLY_WIDTH,FRIENDLY_HEIGHT,SHIP_SIZE,SHIP_SPEED,lcd,pad); } void generate() { lcd.clear(); engine.draw(lcd); // grid, health lcd.refresh(); } void welcome() { lcd.printString(" Press Start! ",0,4); lcd.refresh(); while ( pad.check_event(Gamepad::START_PRESSED) == false) { wait(0.1); } }