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.
Player/Player.cpp
- Committer:
- joebarhouch
- Date:
- 2020-04-10
- Revision:
- 2:f22cb01c43bc
- Child:
- 3:e4e1cbf750b6
File content as of revision 2:f22cb01c43bc:
#include "Player.h"
Gamepad pad;
Player::Player()
{
}
Player::~Player()
{
}
bool Player::dir()
{
Direction d;
//true for left to right
if(d == E || d == NE || d == SE) {
_direction = true;
_vx = 2;
}
//false for right to left
else if(d == W || d == NW || d == SW) {
_direction = false;
_vx = 2;
}
return _direction;
}
bool Player::jump()
{
bool bttnA = pad.A_pressed();
_jmp = false;
// returns true when A is pressed for jump
if(bttnA == true) {
_jmp = true;
_vy = 3;
return _jmp;
} else {
_jmp = false;
_vy = 0;
}
return _jmp;
}
void Player::draw(N5110 &lcd)
{
if(_direction == true & _playerX + 9 < WIDTH) {
_playerX = _playerX + _vx;
player.render(lcd, _playerX, _playerY);
}
if(_direction == false & _playerX > 0) {
_playerX = _playerX - _vx;
player_inv.render(lcd, _playerX, _playerY);
}
}