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:
- 29:bdc4138b5171
- Parent:
- 28:be77ad6c0bda
diff -r be77ad6c0bda -r bdc4138b5171 Engine/Engine.cpp --- a/Engine/Engine.cpp Tue May 07 08:39:38 2019 +0000 +++ b/Engine/Engine.cpp Tue May 07 17:21:00 2019 +0000 @@ -13,6 +13,7 @@ Engine::~Engine() {} void Engine::init() { + // Reset functions are used for init. reset_skater(); reset_engine(); srand(time(NULL)); // Set up for generating random numbers, [1]. @@ -30,6 +31,7 @@ } void Engine::execute_dying_sequence(N5110 &lcd, Gamepad &gamepad) { + // Player has died and game needs to restart, printing their score. wait(1); // Short pause. gamepad.leds_off(); lcd.clear(); @@ -50,6 +52,7 @@ } void Engine::reset_skater() { + // Initial values for skater. _skater_direction = Left; _start_platform_flag = true; // For printing start text in EngineController. _skater.set_reset_flag(false); @@ -59,6 +62,7 @@ } void Engine::reset_engine() { + // Inital values for engine (and gamepad input). _input.coord.x = 0; _input.coord.y = 0; _input.A_flag = false; @@ -72,7 +76,7 @@ } void Engine::read_input(Gamepad &gamepad) { - // Set up the input struct. + // Set up the input struct for use. _input.coord = gamepad.get_mapped_coord(); _input.A_flag = gamepad.check_event(Gamepad::A_PRESSED); } @@ -81,7 +85,7 @@ // Sets the y coord by first checking if the skater should be falling. set_fall_flag(); // Update the fall flag dependent on skater position. if (_fall_flag) { - _skater.fall(_fall_flag, gamepad); + _skater.fall(_fall_flag, gamepad); // Fall if the skater should be. } else { _skater.set_y_position(_input.A_flag, _jump_counter, _level_condition, gamepad); @@ -114,7 +118,7 @@ } void Engine::process_x(int game_counter) { - // Sets the x coord. + // Sets the x coord from input. _skater.set_x_position_and_sprite(_input.coord.x, _moving_counter, _skater_direction, @@ -244,6 +248,7 @@ _upper_line_1.y,FILL_BLACK); lcd.drawLine(_upper_line_3.x_start,_upper_line_3.y,_upper_line_3.x_end, _upper_line_3.y,FILL_BLACK); + // Print the score. sprintf(buffer,"%2d",_player_score); lcd.printString(buffer,0,0); draw_screen_fire(game_counter, lcd);