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:
- 2:16ae940b0aee
- Child:
- 3:28a3c118e071
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Skateboarder/Stakeboarder.cpp Wed Mar 13 15:10:36 2019 +0000 @@ -0,0 +1,64 @@ +#include "Skateboarder.h" + +Skateboarder::Skateboarder(){} + +Skateboarder::~Skateboarder(){} + +void Skateboarder::set_x_position(float joy_x, int moving_counter, Skate_Direction direction) { + + _skate_direction = direction; + _moving_counter = moving_counter; + + if(joy_x > float(0.1)){ + _moving_counter = _moving_counter++; + _skate_direction = Right; + _sprite_value = Skate_right; + } else if(joy_x < float(-0.1)) { + _moving_counter = _moving_counter--; + _skate_direction = Left; + _sprite_value = Skate_left; + } else if (_skate_direction == Left){ + _sprite_value = Stand_left; + } else { + _sprite_value = Stand_right; + } + _x = 40 + 0.4*_moving_counter; + + } + +void Skateboarder::set_y_position(bool jump, int jump_counter) { + + _jump_counter = jump_counter; + + if(jump) { + _jump_counter = 40; + } + if(_jump_counter !=0){ + _jump_counter--; + } + _y = 23 - 0.5*_jump_counter; + + } + + + +int Skateboarder::get_x_position(){ + return _x; + } + +int Skateboarder::get_moving_counter(){ + return _moving_counter; + } + +int Skateboarder::get_y_position(){ + return _y; + } + +int Skateboarder::get_jump_counter(){ + return _jump_counter; + } + +Sprite_value Skateboarder::get_sprite(){ + return _sprite_value; + } + \ No newline at end of file