Laila Al Badwawi 200906179 SpaceInvaders I declare this my own independent work and understand the university rules on plagiarism.
Dependencies: mbed
main.cpp
- Committer:
- fy14lkaa
- Date:
- 2019-05-06
- Revision:
- 131:2084e4a8338f
- Parent:
- 128:a3f581b8461c
- Child:
- 133:eed60548d170
File content as of revision 131:2084e4a8338f:
///////// pre-processor directives //////// #include "mbed.h" #include "Gamepad.h" #include "N5110.h" #include "SpaceEngine.h" // structs // struct UserInput { Direction d; float mag; }; /////////////// objects /////////////// N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11); Gamepad pad; SpaceEngine space; ///////////// prototypes /////////////// void init(); void update_game(UserInput input); void render(); void welcome(); ///////////// functions //////////////// int main() { int fps = 8; init(); welcome(); render(); wait(1.0f/fps); while (1) { space.read_input(pad); space.update(pad); render(); wait(1.0f/fps); } } // initialies all classes and libraries void init() { lcd.init(); pad.init(); space.init(0,10,11,10,0,70,10,1,1,1); } void render() { lcd.clear(); space.draw(lcd); lcd.refresh(); } void welcome() { lcd.printString(" Spaceship!",0,1); lcd.printString(" Press Start ",0,4); lcd.refresh(); // wait flashing LEDs until start button is pressed while ( pad.check_event(Gamepad::START_PRESSED) == false) { pad.leds_on(); wait(0.1); pad.leds_off(); wait(0.1); } }