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: Engine/Engine.cpp
- Revision:
- 7:bbc2b75c1418
- Parent:
- 5:eda40cdde3e7
- Child:
- 8:5327418f823a
--- a/Engine/Engine.cpp Tue Mar 19 11:34:21 2019 +0000
+++ b/Engine/Engine.cpp Wed Mar 20 17:56:55 2019 +0000
@@ -11,6 +11,9 @@
_level = 0;
_x = 40;
_y = 40;
+
+ _map.init();
+ srand(time(NULL));
}
void Engine::read_input(Gamepad &gamepad) {
@@ -24,10 +27,14 @@
_jump_counter = _skater.get_jump_counter();
}
-void Engine::process_x() {
+void Engine::process_x(int t) {
_skater.set_x_position( _input.coord.x, _moving_counter, _direction, _input.coord.y );
_x = _skater.get_x_position();
_moving_counter = _skater.get_moving_counter();
+
+ if( (t % 6 == 0 || t % 8 == 0) && (_input.coord.x > -0.1) ) {
+ _moving_counter--;
+ }
}
void Engine::process_sprite() {
@@ -43,12 +50,28 @@
_level = 0;
}
}
+
+void Engine::generate_map() {
+ _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();
+
+ }
void Engine::update_lcd(N5110 &lcd){
_skate_sprite = _skater.get_sprite(_sprite);
lcd.drawSprite(_x,_y,17,10,(int *)_skate_sprite);
- lcd.drawLine(5,40,80,40,FILL_BLACK);
- lcd.drawLine(5,22,30,22,FILL_BLACK);
- lcd.drawLine(50,22,80,22,FILL_BLACK);
+ 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);
}
\ No newline at end of file