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:
- 8:5327418f823a
- Parent:
- 7:bbc2b75c1418
- Child:
- 9:fff2009f826e
diff -r bbc2b75c1418 -r 5327418f823a Engine/Engine.cpp --- a/Engine/Engine.cpp Wed Mar 20 17:56:55 2019 +0000 +++ b/Engine/Engine.cpp Sat Mar 23 15:36:56 2019 +0000 @@ -4,6 +4,20 @@ Engine::~Engine(){} +void Engine::check_reset() { + if(_skater.get_reset_flag()) { + _moving_counter = 0; + _jump_counter = 0; + _direction = Left; + _level = 0; + _x = 40; + _y = 40; + _map.init(); + _skater.set_reset_flag(false); + wait(1); + } + } + void Engine::init() { _moving_counter = 0; _jump_counter = 0; @@ -22,12 +36,29 @@ } void Engine::process_y() { + if ( ( (_line_1.x_end < _x) && (_x < (_line_2.x_start - 6) ) ) && _y == 23 ) { + _fall_flag = true; + } else if ( ( (_line_2.x_end < _x) && (_x < (_line_3.x_start - 6) ) ) && _y == 23 ) { + _fall_flag = true; + } else if ( ( (_line_3.x_end < _x) && (_x < (_line_1.x_start - 6) ) ) && _y == 23 ) { + _fall_flag = true; + } + + if(_fall_flag) { + _skater.fall(_fall_flag); + } else { _skater.set_y_position( _input.A_flag, _jump_counter, _level ); + } + + _fall_flag = _skater.get_fall_flag(); _y = _skater.get_y_position(); _jump_counter = _skater.get_jump_counter(); } void Engine::process_x(int t) { + if ( _x < -10 || _x > 84 ) { + _skater.set_reset_flag(true); + } else { _skater.set_x_position( _input.coord.x, _moving_counter, _direction, _input.coord.y ); _x = _skater.get_x_position(); _moving_counter = _skater.get_moving_counter(); @@ -36,6 +67,7 @@ _moving_counter--; } } + } void Engine::process_sprite() { _sprite = _skater.get_sprite_value();