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: Skateboarder/Stakeboarder.cpp
- Revision:
- 26:4253656c0755
- Parent:
- 21:20478f086bc2
- Child:
- 27:c920c5ec31af
--- a/Skateboarder/Stakeboarder.cpp Wed Apr 24 17:58:35 2019 +0000 +++ b/Skateboarder/Stakeboarder.cpp Fri May 03 09:33:34 2019 +0000 @@ -133,8 +133,8 @@ float joy_y) { _skate_direction = direction; _moving_counter = moving_counter; - process_x_variables(joy_x); - _x = 40 + 0.4*_moving_counter; + process_x_variables(joy_x); + _x = 40 + 0.4*_moving_counter; // Moving counter is scaled for speed control. check_duck(joy_y); } @@ -171,14 +171,14 @@ Gamepad &gamepad) { _jump_counter = jump_counter; _level_condition = level_condition; - if (jump && _jump_counter < 25) { // Jump condition. Jump counter must be < - // 25 to limit double jump. + // Jump condition. Jump from A button must be true. + if (jump) { _jump_counter = 40; // Controls height and fall time. gamepad.tone(440, 0.05); // Buzzer jump sound. wait(0.05); gamepad.tone(880, 0.05); } - if (_jump_counter !=0) _jump_counter--; + if (_jump_counter !=0) _jump_counter--; // Keep falling until not jumping. if (_level_condition == 1 && jump){ // If skater is under / on-top of upper // platforms, will jump to / stay on upper platforms. _level = 5; @@ -214,6 +214,7 @@ } int * Skateboarder::get_sprite(Sprite_value sprite) { + // Return correct sprite. if (sprite == Skate_right) { return *skate_right; } else if (sprite == Skate_left) { @@ -230,12 +231,13 @@ } void Skateboarder::fall(bool fall_flag, Gamepad &gamepad) { + // Falling sequence. _fall_flag = fall_flag; _y++; gamepad.tone(int(-15.8*_y + 1363), 0.05); // Linear equation makes decending // frequency sound. wait(0.005); // Control fall time and fall sound speed. - if (_y == 80) { // Stop falling. + if (_y == 80) { // Stop falling when y = 80. _fall_flag = false; _reset_flag = true; }