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:
- 6:8741d2011692
- Parent:
- 5:eda40cdde3e7
- Child:
- 7:bbc2b75c1418
--- a/main.cpp Sun Mar 17 14:45:37 2019 +0000 +++ b/main.cpp Tue Mar 19 11:34:21 2019 +0000 @@ -10,29 +10,54 @@ #include "Gamepad.h" #include "Skateboarder.h" #include "Engine.h" +#include "Map.h" +#include <cstdlib> +#include <ctime> #include <cmath> N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11); Gamepad gamepad; Engine game_engine; +Map map; void init_game(); - +void run_game(); +Line line_1; +Line line_2; +Line line_3; +int length_1; +int length_2; +int length_3; int main(){ init_game(); + map.init(); + srand(time(NULL)); while(1){ lcd.clear(); - game_engine.read_input(gamepad); - game_engine.find_level(); - game_engine.process_y(); - game_engine.process_x(); - game_engine.process_sprite(); - game_engine.update_lcd(lcd); - + //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); lcd.refresh(); wait(0.01); } @@ -47,3 +72,11 @@ lcd.setBrightness(0.5); } +void run_game() { + game_engine.read_input(gamepad); + game_engine.find_level(); + game_engine.process_y(); + game_engine.process_x(); + game_engine.process_sprite(); + game_engine.update_lcd(lcd); +} \ No newline at end of file