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:
- 20:a8cad4e044ea
- Parent:
- 18:304700b5d8f8
- Child:
- 21:20478f086bc2
--- a/Skateboarder/Stakeboarder.cpp Mon Apr 15 18:49:35 2019 +0000 +++ b/Skateboarder/Stakeboarder.cpp Tue Apr 16 19:19:43 2019 +0000 @@ -167,13 +167,18 @@ } -void Skateboarder::set_y_position(bool jump, int jump_counter, int level_condition) { +void Skateboarder::set_y_position(bool jump, int jump_counter, int level_condition, Gamepad &gamepad) { _jump_counter = jump_counter; _level_condition = level_condition; // Set jump counter to 40 if button is pressed, jump counter condition is to restrict // double jump. Keep subtracting jump counter from default y position, subtracting // one from the jump counter on every iteration until it is equal to 0. - if (jump && _jump_counter < 15) _jump_counter = 40; + if (jump && _jump_counter < 25) { + _jump_counter = 40; + gamepad.tone(440, 0.05); + wait(0.05); + gamepad.tone(880, 0.05); + } if (_jump_counter !=0) _jump_counter--; if(_level_condition == 1 && jump){ _level = 5; @@ -225,9 +230,11 @@ } } -void Skateboarder::fall(bool fall_flag) { +void Skateboarder::fall(bool fall_flag, Gamepad &gamepad) { _fall_flag = fall_flag; _y++; + gamepad.tone(int(-15.8*_y + 1363), 0.05); + wait(0.005); if (_y == 80) { _fall_flag = false; _reset_flag = true;