2018-12-30 19:18:42 -08:00
|
|
|
//
|
|
|
|
// Created by aurailus on 28/12/18.
|
|
|
|
//
|
|
|
|
|
2019-08-24 17:39:35 -07:00
|
|
|
#pragma once
|
2018-12-30 19:18:42 -08:00
|
|
|
|
|
|
|
|
2019-01-22 17:08:06 -08:00
|
|
|
#include <iostream>
|
|
|
|
|
2019-04-18 17:03:51 -07:00
|
|
|
#include "LocalWorld.h"
|
|
|
|
#include "../../graph/Camera.h"
|
|
|
|
#include "../../../util/Timer.h"
|
|
|
|
#include "../../entity/world/WireframeEntity.h"
|
2019-05-14 12:05:54 -07:00
|
|
|
#include "../../entity/world/BlockCrackEntity.h"
|
2019-05-01 19:57:50 -07:00
|
|
|
#include "../../graph/drawable/DrawableGroup.h"
|
2019-05-15 20:35:26 -07:00
|
|
|
#include "../../../world/block/PointedThing.h"
|
2019-10-24 20:16:39 -07:00
|
|
|
#include "../../hud/GameGui.h"
|
2019-10-29 00:31:00 -07:00
|
|
|
#include "../../entity/Collidable.h"
|
2018-12-30 19:18:42 -08:00
|
|
|
|
2019-10-29 00:31:00 -07:00
|
|
|
class Player : Collidable, public Drawable {
|
2018-12-30 19:18:42 -08:00
|
|
|
public:
|
2019-10-29 00:31:00 -07:00
|
|
|
static constexpr float MOUSE_SENSITIVITY = 0.1f;
|
2019-04-09 00:51:38 -07:00
|
|
|
static constexpr float LOOK_DISTANCE = 6.5f;
|
2019-05-15 20:35:26 -07:00
|
|
|
static constexpr float LOOK_PRECISION = 0.01f;
|
2019-04-10 18:44:17 -07:00
|
|
|
static constexpr float EYE_HEIGHT = 1.65f;
|
2019-12-09 21:19:02 -08:00
|
|
|
static constexpr float BASE_MOVE_SPEED = 4.3f;
|
|
|
|
static constexpr float JUMP_VEL = 0.14f;
|
2019-11-12 01:15:06 -08:00
|
|
|
static constexpr float BLOCK_DAMAGE = 0.36f;
|
|
|
|
static constexpr float BLOCK_INTERVAL = 0.02f;
|
2019-04-08 22:55:19 -07:00
|
|
|
|
2019-10-24 20:16:39 -07:00
|
|
|
Player(LocalWorld& world, LocalDefs& defs, Renderer& renderer);
|
2018-12-30 19:18:42 -08:00
|
|
|
|
2019-04-10 18:44:17 -07:00
|
|
|
void update(InputManager &input, double delta, double mouseX, double mouseY);
|
2018-12-30 19:18:42 -08:00
|
|
|
|
2019-10-29 00:31:00 -07:00
|
|
|
void moveAndLook(InputManager &input, double delta, double deltaX, double deltaY);
|
|
|
|
void updateCamera();
|
2019-10-29 20:06:55 -07:00
|
|
|
void findPointedThing(InputManager &input);
|
|
|
|
void updateWireframe();
|
|
|
|
void breakBlock(InputManager& input, double delta);
|
2018-12-30 19:18:42 -08:00
|
|
|
|
|
|
|
void setPos(glm::vec3 pos);
|
2019-10-23 23:34:30 -07:00
|
|
|
glm::vec3 getPos();
|
|
|
|
|
|
|
|
void setVel(glm::vec3 vel);
|
|
|
|
glm::vec3 getVel();
|
2018-12-30 19:18:42 -08:00
|
|
|
|
2019-10-23 23:34:30 -07:00
|
|
|
void setYaw(float yaw);
|
2018-12-30 19:18:42 -08:00
|
|
|
float getYaw();
|
2019-10-23 23:34:30 -07:00
|
|
|
void setPitch(float pitch);
|
2018-12-30 19:18:42 -08:00
|
|
|
float getPitch();
|
|
|
|
|
2019-10-27 19:37:11 -07:00
|
|
|
void setActiveBlock(const std::string& block);
|
|
|
|
|
2019-11-04 00:43:12 -08:00
|
|
|
void setMenu(const std::string& menu);
|
|
|
|
std::string getMenuState();
|
2019-10-24 20:16:39 -07:00
|
|
|
void closeMenu();
|
|
|
|
void setGuiVisible(bool hudVisible);
|
|
|
|
|
2019-05-16 16:29:46 -07:00
|
|
|
void draw(Renderer& renderer) override;
|
2019-11-04 20:26:50 -08:00
|
|
|
void drawViginette(Renderer& renderer);
|
2019-10-24 20:16:39 -07:00
|
|
|
void drawGUI(Renderer& renderer);
|
2019-04-10 18:44:17 -07:00
|
|
|
|
2019-05-16 16:29:46 -07:00
|
|
|
PointedThing& getPointedThing();
|
2019-10-24 20:16:39 -07:00
|
|
|
|
2018-12-30 19:18:42 -08:00
|
|
|
private:
|
2019-10-24 20:16:39 -07:00
|
|
|
Renderer& renderer;
|
2019-06-10 23:53:24 -07:00
|
|
|
LocalDefs& defs;
|
2019-10-24 20:16:39 -07:00
|
|
|
GameGui gameGui;
|
2019-05-16 16:29:46 -07:00
|
|
|
|
|
|
|
bool flying = false;
|
2019-05-01 19:57:50 -07:00
|
|
|
float yaw = 0;
|
|
|
|
float pitch = 0;
|
|
|
|
|
2019-10-29 00:31:00 -07:00
|
|
|
unsigned int activeBlock = -1;
|
2019-10-27 19:37:11 -07:00
|
|
|
|
2019-05-15 20:35:26 -07:00
|
|
|
PointedThing pointedThing;
|
2019-05-16 16:29:46 -07:00
|
|
|
WireframeEntity wireframe;
|
|
|
|
double breakInterval = 0;
|
2018-12-30 19:18:42 -08:00
|
|
|
};
|
|
|
|
|