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 MotionSensor
Diff: Entity/Player/Player.cpp
- Revision:
- 10:1a3499f6b583
- Child:
- 11:63e54f6e7939
diff -r 304079450898 -r 1a3499f6b583 Entity/Player/Player.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Entity/Player/Player.cpp Sun Apr 21 23:23:35 2019 +0000
@@ -0,0 +1,60 @@
+#include "Player.h"
+#include "math.h"
+
+Player::Player(float pos_x, float pos_y){
+ moving = false;
+ face = 0;
+ hp = 0;
+ hitbox.width = 6;
+ hitbox.height = 5;
+ position.x = pos_x;
+ position.y = pos_y;
+ sprite_size.width = 6;
+ sprite_size.height = 12;
+ sprite_size.offset_x = 0;
+ sprite_size.offset_y = 7;
+}
+
+void Player::move(float mapped_x, float mapped_y){
+ if(!matrix_collision_test(position.x + 1.2f*mapped_x, position.y, 0)){
+ position.x += 1.2f*mapped_x;
+ }
+ if(!matrix_collision_test(position.x, position.y - 1.2f*mapped_y, 0)){
+ position.y -= 1.2f*mapped_y;
+ }
+ moving = false;
+ if (abs(mapped_x) + abs(mapped_y) > 0.1f){
+ moving = true;
+ if (mapped_y < 0 && abs(mapped_y) > abs(mapped_x)){
+ face = 2;
+ }
+ else if (mapped_y > 0 && abs(mapped_y) > abs(mapped_x)){
+ face = 0;
+ }
+ else if (mapped_x > 0 && abs(mapped_x) > abs(mapped_y)){
+ face = 1;
+ }
+ else if (mapped_x < 0 && abs(mapped_x) > abs(mapped_y)){
+ face = 3;
+ }
+ }
+}
+
+void Player::chkdmg(){
+
+}
+
+void Player::buttons(bool button_A, bool button_B, bool button_Y, bool button_X){
+ if (button_Y){
+ face = 0;
+ }
+ else if (button_B){
+ face = 1;
+ }
+ else if (button_A){
+ face = 2;
+ }
+ else if (button_X){
+ face = 3;
+ }
+}