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.
Diff: Player/Player.cpp
- Revision:
- 5:928c2eee4109
- Parent:
- 4:cf5088ace087
- Child:
- 7:530ca713d2b2
--- a/Player/Player.cpp Mon May 18 18:46:13 2020 +0000
+++ b/Player/Player.cpp Fri May 22 01:26:24 2020 +0000
@@ -11,6 +11,7 @@
}
+//initialize
void Player::init(int x,int y)
{
_playerX = x;
@@ -19,27 +20,17 @@
-
+//Player jumps if A is pressed
bool Player::jump(Gamepad &pad)
{
- bool bttnA = pad.A_pressed();
- _jmp = false;
- // returns true when A is pressed for jump
- if(bttnA == true) {
- _jmp = true;
- return _jmp;
- } else {
- _jmp = false;
- }
-
- return _jmp;
+
}
+//Draw the sprites depending on the orientation
void Player::draw(N5110 &lcd)
{
- draw_map1(lcd);
if(_dir == E) {
Bitmap bit_player(s_player, 8, 9);
bit_player.render(lcd, _playerX, _playerY);
@@ -54,6 +45,7 @@
}
}
+//Update player movement and set screen restrictions
void Player::update(Direction d, float mag)
{
int _vx = int(mag*4.0f);
@@ -72,8 +64,12 @@
if(_playerX < 0) {
_playerX = 0;
}
+
+ //debug
+ //printf("x: %i, y: %i \n", _playerX, _playerY);
}
+//get the position of the player in a 2D vector
Vector2D Player::get_pos()
{
Vector2D pos = {_playerX, _playerY};