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 Class Reference
Skateboarder Class. More...
#include <Skateboarder.h>
Public Member Functions | |
| Skateboarder () | |
| Constructor. | |
| ~Skateboarder () | |
| Destructor. | |
| void | set_x_position_and_sprite (float joy_x, int moving_counter, Skate_direction direction, float joy_y) |
| Sets the X coordinate of the Skateboarder. | |
| void | set_y_position (bool jump, int jump_counter, int level_condition, Gamepad &gamepad) |
| Sets the Y coordinate of the Skateboarder. | |
| void | set_reset_flag (bool flag) |
| Sets the reset flag of the Skateboarder. | |
| int | get_x_position () |
| Gets the X coordinate. | |
| int | get_moving_counter () |
| Gets the moving counter. | |
| int | get_y_position () |
| Gets the Y coordinate. | |
| int | get_jump_counter () |
| Gets the jump counter. | |
| bool | get_fall_flag () |
| Gets the fall flag. | |
| bool | get_reset_flag () |
| Gets the reset flag. | |
| Sprite_value | get_sprite_value () |
| Gets the sprite value. | |
| Skate_direction | get_direction () |
| Gets the skate direction. | |
| int * | get_sprite (Sprite_value sprite) |
| Gets the sprite. | |
| void | fall (bool fall_flag, Gamepad &gamepad) |
| Executes the falling sequence for the Skateboarder. | |
Detailed Description
Skateboarder Class.
Describes the characteristics of the skateboarder sprite *
- Date:
- March 2019
#include "mbed.h" #include "N5110.h" #include "Gamepad.h" #include "mbed.h" #include "N5110.h" #include "Gamepad.h" #include "Skateboarder.h" #include <cstdlib> #include <ctime> N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11); Gamepad gamepad; Skateboarder _skater; int _moving_counter; int _jump_counter; int _skater_x; int _skater_y; int _level_condition; bool _fall_flag; Skate_direction _skater_direction; Sprite_value _skater_sprite; bool _start_platform_flag; int main() { // Initialise external skater values. _skater_direction = Left; _start_platform_flag = true; // For printing start text in EngineController. _skater.set_reset_flag(false); _moving_counter = 0; _jump_counter = 20; // Start game falling onto the platform. _fall_flag = false; while(1) { // Process Y coord. if (_fall_flag) { _skater.fall(_fall_flag, gamepad); } else { _skater.set_y_position(false, _jump_counter, _level_condition, gamepad); // Not jumping as input flag is false. } _fall_flag = _skater.get_fall_flag(); // Update fall flag. _skater_y = _skater.get_y_position(); _jump_counter = _skater.get_jump_counter(); // Update jump counter. // Process X coord. _skater.set_x_position_and_sprite(1, _moving_counter, _skater_direction, 1); // For input coords (1,1). _skater_x = _skater.get_x_position(); _moving_counter = _skater.get_moving_counter(); // Update moving counter. //Update the direction. _skater_direction = _skater.get_direction(); // Print sprite. lcd.drawSprite(_skater_x,_skater_y,17,10, (int *)_skater.get_sprite(_skater_sprite)); } }
Definition at line 94 of file Skateboarder.h.
Constructor & Destructor Documentation
| Skateboarder | ( | ) |
| ~Skateboarder | ( | ) |
Member Function Documentation
| void fall | ( | bool | fall_flag, |
| Gamepad & | gamepad | ||
| ) |
Executes the falling sequence for the Skateboarder.
- Parameters:
-
fall_flag The boolean fall flag of the Skateboarder &gamepad The gamepad object from Gamepad class
Definition at line 235 of file Stakeboarder.cpp.
| Skate_direction get_direction | ( | ) |
Gets the skate direction.
- Returns:
- The Skateboarders direction (from the enum class Skate_Direction)
Definition at line 210 of file Stakeboarder.cpp.
| bool get_fall_flag | ( | ) |
Gets the fall flag.
- Returns:
- The fall flag of the Skateboarder
Definition at line 248 of file Stakeboarder.cpp.
| int get_jump_counter | ( | ) |
Gets the jump counter.
- Returns:
- The jump counter for the Skateboarder
Definition at line 206 of file Stakeboarder.cpp.
| int get_moving_counter | ( | ) |
Gets the moving counter.
- Returns:
- The moving counter for the Skateboarder
Definition at line 198 of file Stakeboarder.cpp.
| bool get_reset_flag | ( | ) |
Gets the reset flag.
- Returns:
- The Reset flag of the Skateboarder
Definition at line 252 of file Stakeboarder.cpp.
| int * get_sprite | ( | Sprite_value | sprite ) |
Gets the sprite.
- Returns:
- The Skateboarders sprite (an integer array)
Definition at line 218 of file Stakeboarder.cpp.
| Sprite_value get_sprite_value | ( | ) |
Gets the sprite value.
- Returns:
- The sprite value of the Skateboarder (from the enum class Sprite_value)
Definition at line 214 of file Stakeboarder.cpp.
| int get_x_position | ( | ) |
Gets the X coordinate.
- Returns:
- The X coordinate of the Skateboarder
Definition at line 194 of file Stakeboarder.cpp.
| int get_y_position | ( | ) |
Gets the Y coordinate.
- Returns:
- The Y coordinate of the Skateboarder
Definition at line 202 of file Stakeboarder.cpp.
| void set_reset_flag | ( | bool | flag ) |
Sets the reset flag of the Skateboarder.
- Parameters:
-
flag A boolean flag that is assigned to the Skateboarder reset flag
Definition at line 256 of file Stakeboarder.cpp.
| void set_x_position_and_sprite | ( | float | joy_x, |
| int | moving_counter, | ||
| Skate_direction | direction, | ||
| float | joy_y | ||
| ) |
Sets the X coordinate of the Skateboarder.
- Parameters:
-
joy_x The horizontal value of the joystick moving_counter The counter that adds the displacement to the X coordinate from the centre position The current direction the skater is facing from the enum class Skate_direction The vertical value of the joystick
Definition at line 129 of file Stakeboarder.cpp.
| void set_y_position | ( | bool | jump, |
| int | jump_counter, | ||
| int | level_condition, | ||
| Gamepad & | gamepad | ||
| ) |
Sets the Y coordinate of the Skateboarder.
- Parameters:
-
jump A boolean flag that is true only if the A button is pressed jump_counter The counter that adds the displacement to the Y coordinate from the current position level_condition an integer that is 1 if the skateboarder is under / on top of the top platforms &gamepad The gamepad object from Gamepad class
Definition at line 168 of file Stakeboarder.cpp.
Generated on Mon Jul 18 2022 14:06:02 by
1.7.2