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:
- 4:ce4eea1c2a28
- Parent:
- 3:28a3c118e071
- Child:
- 6:8741d2011692
--- a/Skateboarder/Stakeboarder.cpp Sat Mar 16 10:38:04 2019 +0000 +++ b/Skateboarder/Stakeboarder.cpp Sun Mar 17 13:36:10 2019 +0000 @@ -1,93 +1,139 @@ #include "Skateboarder.h" - int skate_right[17][12] = { +int skate_right[17][10] = { + + { 0,0,0,1,1,1,0,0,0,0 }, + { 0,0,0,1,1,1,1,0,0,0 }, + { 0,1,1,1,1,1,1,0,0,0 }, + { 0,0,0,1,0,1,1,0,0,0 }, + { 0,0,0,1,1,1,0,0,0,0 }, + { 0,0,0,1,1,0,0,0,0,0 }, + { 0,0,0,1,1,0,0,0,0,0 }, + { 0,1,1,1,1,1,1,1,0,0 }, + { 1,1,0,1,1,0,0,1,1,0 }, + { 1,0,0,1,1,0,0,0,0,0 }, + { 0,0,0,1,1,0,0,0,0,0 }, + { 0,0,0,1,1,0,0,0,0,0 }, + { 0,0,0,1,0,1,0,0,0,0 }, + { 0,0,0,1,0,0,1,0,0,0 }, + { 1,0,0,1,0,0,0,1,0,1 }, + { 0,1,1,1,1,1,1,1,1,0 }, + { 0,0,1,0,0,0,0,1,0,0 }, + - { 0,0,0,0,1,1,1,0,0,0,0,0 }, - { 0,0,0,0,1,1,1,1,0,0,0,0 }, - { 0,0,1,1,1,1,1,1,0,0,0,0 }, - { 0,0,0,0,1,0,1,1,0,0,0,0 }, - { 0,0,0,0,1,1,1,0,0,0,0,0 }, - { 0,0,0,0,1,1,0,0,0,0,0,0 }, - { 0,0,0,0,1,1,0,0,0,0,0,0 }, - { 0,0,1,1,1,1,1,1,1,0,0,0 }, - { 0,1,1,0,1,1,0,0,1,1,0,0 }, - { 0,1,0,0,1,1,0,0,0,0,0,0 }, - { 0,0,0,0,1,1,0,0,0,0,0,0 }, - { 0,0,0,0,1,1,0,0,0,0,0,0 }, - { 0,0,0,0,1,0,1,0,0,0,0,0 }, - { 0,0,0,0,1,0,0,1,0,0,0,0 }, - { 0,1,0,0,1,0,0,0,1,0,1,0 }, - { 0,0,1,1,1,1,1,1,1,1,0,0 }, - { 0,0,0,1,0,0,0,0,1,0,0,0 }, +}; + +int skate_left[17][10] = { + + { 0,0,0,0,1,1,1,0,0,0 }, + { 0,0,0,1,1,1,1,0,0,0 }, + { 0,0,0,1,1,1,1,1,1,0 }, + { 0,0,0,1,1,0,1,0,0,0 }, + { 0,0,0,0,1,1,1,0,0,0 }, + { 0,0,0,0,0,1,1,0,0,0 }, + { 0,0,0,0,0,1,1,1,0,0 }, + { 0,1,1,1,1,1,1,1,0,0 }, + { 0,0,0,1,1,1,1,1,1,0 }, + { 0,0,0,0,1,1,0,0,1,0 }, + { 0,0,0,0,1,1,0,0,0,1 }, + { 0,0,0,0,1,1,0,0,0,0 }, + { 0,0,0,1,0,1,0,0,0,0 }, + { 0,0,1,0,0,1,0,0,0,0 }, + { 1,1,0,0,0,1,0,0,0,1 }, + { 0,1,1,1,1,1,1,1,1,0 }, + { 0,0,0,1,0,0,0,0,1,0 }, }; -int skate_left[17][12] = { +int skate_stand_left[17][10] = { - { 0,0,0,0,1,1,1,0,0,0,0,0 }, - { 0,0,0,1,1,1,1,0,0,0,0,0 }, - { 0,0,0,1,1,1,1,1,1,0,0,0 }, - { 0,0,0,1,1,0,1,0,0,0,0,0 }, - { 0,0,0,0,1,1,1,0,0,0,0,0 }, - { 0,0,0,0,0,1,1,0,0,0,0,0 }, - { 0,0,0,0,0,1,1,1,0,0,0,0 }, - { 0,1,1,1,1,1,1,1,0,0,0,0 }, - { 0,0,0,1,1,1,1,1,1,0,0,0 }, - { 0,0,0,0,1,1,0,0,1,0,0,0 }, - { 0,0,0,0,1,1,0,0,0,1,0,0 }, - { 0,0,0,0,1,1,0,0,0,0,0,0 }, - { 0,0,0,1,0,1,0,0,0,0,0,0 }, - { 0,0,1,0,0,1,0,0,0,0,0,0 }, - { 1,1,0,0,0,1,0,0,0,1,0,0 }, - { 0,1,1,1,1,1,1,1,1,0,0,0 }, - { 0,0,0,1,0,0,0,0,1,0,0,0 }, + { 0,0,0,0,1,1,0,0,0,0 }, + { 0,0,0,1,1,1,1,0,0,0 }, + { 0,0,0,1,1,1,1,1,1,0 }, + { 0,0,0,1,0,0,1,0,0,0 }, + { 0,0,0,1,1,1,1,0,0,0 }, + { 0,0,0,0,1,1,0,0,0,0 }, + { 0,0,0,1,1,1,1,0,0,0 }, + { 0,0,1,1,1,1,0,1,0,0 }, + { 1,1,0,1,1,1,0,1,0,0 }, + { 0,0,0,1,1,1,0,0,0,0 }, + { 0,0,1,1,1,1,0,0,0,0 }, + { 1,0,1,0,0,1,0,0,0,0 }, + { 1,1,0,0,0,1,0,0,0,0 }, + { 0,1,0,0,0,1,0,0,0,0 }, + { 1,0,1,0,0,1,0,0,0,0 }, + { 0,0,0,1,0,1,0,0,0,0 }, + { 0,0,1,0,1,1,1,0,0,0 }, }; -int skate_standing_left[17][12] = { +int skate_stand_right[17][10] = { - { 0,0,0,0,1,1,0,0,0,0,0,0 }, - { 0,0,0,1,1,1,1,0,0,0,0,0 }, - { 0,0,0,1,1,1,1,1,1,0,0,0 }, - { 0,0,0,1,0,0,1,0,0,0,0,0 }, - { 0,0,0,1,1,1,1,0,0,0,0,0 }, - { 0,0,0,0,1,1,0,0,0,0,0,0 }, - { 0,0,0,1,1,1,1,0,0,0,0,0 }, - { 0,0,1,1,1,1,0,1,0,0,0,0 }, - { 1,1,0,1,1,1,0,1,0,0,0,0 }, - { 0,0,0,1,1,1,0,0,0,0,0,0 }, - { 0,0,1,1,1,1,0,0,0,0,0,0 }, - { 1,0,1,0,0,1,0,0,0,0,0,0 }, - { 1,1,0,0,0,1,0,0,0,0,0,0 }, - { 0,1,0,0,0,1,0,0,0,0,0,0 }, - { 1,0,1,0,0,1,0,0,0,0,0,0 }, - { 0,0,0,1,0,1,0,0,0,0,0,0 }, - { 0,0,1,0,1,1,1,0,0,0,0,0 }, + { 0,0,0,1,1,0,0,0,0,0 }, + { 0,0,1,1,1,1,0,0,0,0 }, + { 1,1,1,1,1,1,0,0,0,0 }, + { 0,0,1,0,0,1,0,0,0,0 }, + { 0,0,1,1,1,1,0,0,0,0 }, + { 0,0,0,1,1,0,0,0,0,0 }, + { 0,0,1,1,1,1,0,0,0,0 }, + { 0,1,1,1,1,0,1,0,0,0 }, + { 1,0,1,1,1,0,0,1,0,0 }, + { 1,0,1,1,1,0,0,0,0,0 }, + { 0,0,1,1,1,1,1,0,0,0 }, + { 0,0,1,0,0,0,1,0,1,0 }, + { 0,0,1,0,0,0,1,1,0,0 }, + { 0,0,1,0,0,0,1,0,1,0 }, + { 0,0,1,0,0,1,0,0,0,0 }, + { 0,0,1,0,1,0,0,0,0,0 }, + { 0,1,1,1,0,1,0,0,0,0 }, }; -int skate_standing_right[17][12] = { +int skate_duck_right[17][10] = { + + { 0,0,0,0,0,0,0,0,0,0 }, + { 0,0,0,0,0,0,0,0,0,0 }, + { 0,0,0,0,0,0,0,0,0,0 }, + { 0,0,0,0,0,0,0,0,0,0 }, + { 0,0,0,0,1,1,0,0,0,0 }, + { 0,0,0,1,1,1,1,0,0,0 }, + { 0,1,1,1,1,1,1,0,0,0 }, + { 0,0,0,1,0,0,1,0,0,0 }, + { 0,0,0,0,1,1,0,0,0,0 }, + { 0,0,1,1,1,1,1,1,0,0 }, + { 0,1,0,1,1,1,1,0,1,1 }, + { 1,0,0,1,1,1,1,0,0,0 }, + { 0,0,0,1,1,1,1,0,0,0 }, + { 0,0,1,1,0,0,1,1,0,0 }, + { 1,0,1,1,0,0,1,1,0,1 }, + { 0,1,1,1,1,1,1,1,1,0 }, + { 0,0,1,0,0,0,0,1,0,0 }, + - { 0,0,0,0,1,1,0,0,0,0,0,0 }, - { 0,0,0,1,1,1,1,0,0,0,0,0 }, - { 0,1,1,1,1,1,1,0,0,0,0,0 }, - { 0,0,0,1,0,0,1,0,0,0,0,0 }, - { 0,0,0,1,1,1,1,0,0,0,0,0 }, - { 0,0,0,0,1,1,0,0,0,0,0,0 }, - { 0,0,0,1,1,1,1,0,0,0,0,0 }, - { 0,0,1,1,1,1,0,1,0,0,0,0 }, - { 0,1,0,1,1,1,0,0,1,0,0,0 }, - { 0,1,0,1,1,1,0,0,0,0,0,0 }, - { 0,0,0,1,1,1,1,1,0,0,0,0 }, - { 0,0,0,1,0,0,0,1,0,1,0,0 }, - { 0,0,0,1,0,0,0,1,1,0,0,0 }, - { 0,0,0,1,0,0,0,1,0,1,0,0 }, - { 0,0,0,1,0,0,1,0,0,0,0,0 }, - { 0,0,0,1,0,1,0,0,0,0,0,0 }, - { 0,0,1,1,1,0,1,0,0,0,0,0 }, +}; + +int skate_duck_left[17][10] = { + + { 0,0,0,0,0,0,0,0,0,0 }, + { 0,0,0,0,0,0,0,0,0,0 }, + { 0,0,0,0,0,0,0,0,0,0 }, + { 0,0,0,0,0,0,0,0,0,0 }, + { 0,0,0,0,1,1,0,0,0,0 }, + { 0,0,0,1,1,1,1,0,0,0 }, + { 0,0,0,1,1,1,1,1,1,0 }, + { 0,0,0,1,0,0,1,0,0,0 }, + { 0,0,0,0,1,1,0,0,0,0 }, + { 0,0,1,1,1,1,1,1,0,0 }, + { 1,1,0,1,1,1,1,0,1,0 }, + { 0,0,0,1,1,1,1,0,0,1 }, + { 0,0,0,1,1,1,1,0,0,0 }, + { 0,0,1,1,0,0,1,1,0,0 }, + { 1,0,1,1,0,0,1,1,0,1 }, + { 0,1,1,1,1,1,1,1,1,0 }, + { 0,0,1,0,0,0,0,1,0,0 }, }; @@ -96,11 +142,9 @@ Skateboarder::~Skateboarder(){} -void Skateboarder::set_x_position(float joy_x, int moving_counter, Skate_Direction direction) { - +void Skateboarder::set_x_position(float joy_x, int moving_counter, Skate_Direction direction, float joy_y) { _skate_direction = direction; _moving_counter = moving_counter; - if(joy_x > float(0.1)){ _moving_counter = _moving_counter++; _skate_direction = Right; @@ -114,31 +158,31 @@ } else { _sprite_value = Stand_right; } - _x = 40 + 0.4*_moving_counter; - + _x = 40 + 0.4*_moving_counter; + if(joy_y < float(-0.1) && joy_x > float(0.1)){ + _sprite_value = Skate_duck_right; + } else if(joy_y < float(-0.1) && joy_x < float(-0.1)){ + _sprite_value = Skate_duck_left; + } } void Skateboarder::set_y_position(bool jump, int jump_counter, int level) { _jump_counter = jump_counter; _level = level; - if(jump) { + + if(jump && _jump_counter < 10) { _jump_counter = 40; } if(_jump_counter !=0){ _jump_counter--; } - - - if(_level == 0){ _y = 23 - 0.5*_jump_counter; - } - + } else { - _y = 5 - 0.25*_jump_counter; // need to get rid of double jump use if(jump) + _y = 5 - 0.25*_jump_counter; } - } @@ -173,8 +217,12 @@ } else if(sprite == Skate_left){ return *skate_left; } else if(sprite == Stand_left){ - return *skate_standing_left; + return *skate_stand_left; + } else if(sprite == Skate_duck_right){ + return *skate_duck_right; + } else if(sprite == Skate_duck_left){ + return *skate_duck_left; } else { - return *skate_standing_right; + return *skate_stand_right; } } \ No newline at end of file