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: mbed
Diff: main.cpp
- Revision:
- 9:fff2009f826e
- Parent:
- 8:5327418f823a
- Child:
- 12:ebaefda53dd0
--- a/main.cpp Sat Mar 23 15:36:56 2019 +0000 +++ b/main.cpp Sun Mar 24 19:22:50 2019 +0000 @@ -8,99 +8,35 @@ #include "N5110.h" #include "Gamepad.h" -#include "Skateboarder.h" -#include "Engine.h" -#include "Map.h" -#include <cstdlib> -#include <ctime> -#include <cmath> +#include "Menu.h" +#include "mbed.h" N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11); Gamepad gamepad; -Engine game_engine; -//Map map; - +Menu menu; void init_game(); -void run_game(int t); - -/* -Line line_1; -Line line_2; -Line line_3; -int length_1; -int length_2; -int length_3; -*/ - -int t = 0; +void run_game(); -int main(){ - - init_game(); - /* - map.init(); - srand(time(NULL)); -*/ - while(1){ - lcd.clear(); - - /* - - run_game(); - length_1 = (rand() %20)+10; - length_2 = (rand() %20)+10; - length_3 = (rand() %20)+10; - - - map.generate_line_1(length_1); - line_1 = map.get_line_1(); - - map.generate_line_2(length_2); - line_2 = map.get_line_2(); - - map.generate_line_3(length_3); - line_3 = map.get_line_3(); - - lcd.drawLine(line_2.x_start,line_2.y,line_2.x_end,line_2.y,FILL_BLACK); - lcd.drawLine(line_1.x_start,line_1.y,line_1.x_end,line_1.y,FILL_BLACK); - lcd.drawLine(line_3.x_start,line_3.y,line_3.x_end,line_3.y,FILL_BLACK); - - wait(0.1); - - */ - - run_game(t); - //wait(0.1); - lcd.refresh(); - wait(0.01); - t++; - if(t == 100) { - t = 0; - } -} +int main() { + init_game(); + while(1) { + lcd.clear(); + run_game(); + lcd.refresh(); + wait(0.01); + } } void init_game() { - gamepad.init(); - game_engine.init(); - lcd.init(); - lcd.setContrast(0.5); - lcd.normalMode(); - lcd.setBrightness(0.5); + gamepad.init(); + menu.init(); + lcd.init(); + lcd.setContrast(0.5); + lcd.normalMode(); + lcd.setBrightness(0.5); } -void run_game(int t) { - game_engine.check_reset(); - game_engine.read_input(gamepad); - - if( t % 10 == 0 ){ - game_engine.generate_map(); - } - - game_engine.find_level(); - game_engine.process_y(); - game_engine.process_x(t); - game_engine.process_sprite(); - game_engine.update_lcd(lcd); +void run_game() { + menu.run_game_engine(lcd, gamepad); } \ No newline at end of file