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
Skateboarder/Stakeboarder.cpp
- Committer:
- lewisgw
- Date:
- 2019-03-13
- Revision:
- 2:16ae940b0aee
- Child:
- 3:28a3c118e071
File content as of revision 2:16ae940b0aee:
#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; }