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:
- 2:f22cb01c43bc
- Child:
- 3:e4e1cbf750b6
diff -r 7fe71d8e48da -r f22cb01c43bc Player/Player.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Player/Player.cpp Fri Apr 10 19:07:13 2020 +0000
@@ -0,0 +1,64 @@
+#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);
+ }
+}