]> git.lizzy.rs Git - dragonblocks-bedrock.git/blobdiff - src/player.cpp
Upload Files
[dragonblocks-bedrock.git] / src / player.cpp
diff --git a/src/player.cpp b/src/player.cpp
new file mode 100644 (file)
index 0000000..6a463b9
--- /dev/null
@@ -0,0 +1,40 @@
+#include <iostream>
+#include <math.h>
+#include "texture.h"
+#include "entity.h"
+#include "player.h"
+#include "map.h"
+#include "mapgen.h"
+#include "graphics.h"
+#include "game.h"
+using namespace std;
+Player::Player(){
+       name = "player";
+       texture = new Texture("textures/player.png", true);
+       width = 1;
+       height = 2;
+       int spawnposX = MAPWIDTH / 2;
+       int spawnposY = MAPHEIGHT - 2;
+       while((Game::map->getNode(spawnposX, spawnposY) != MAPGEN_AIR) || (Game::map->getNode(spawnposX, spawnposY + 1) != MAPGEN_AIR))
+               spawnposY--;
+       spawn(spawnposX, spawnposY, true);
+       inventory = new Inventory();
+}
+void Player::left(){
+       if(vx == -PLAYER_SPEED)
+               return;
+       physics_reset_x();
+       vx = -PLAYER_SPEED;
+}
+void Player::right(){
+       if(vx == PLAYER_SPEED)
+               return;
+       physics_reset_x();
+       vx = PLAYER_SPEED;
+}
+void Player::stop(){
+       physics_reset_x();
+}
+void Player::jump(){
+       vy = -PLAYER_JUMPSPEED;
+}