[ADD] Commented main_character h and cpp files
This commit is contained in:
@@ -7,53 +7,62 @@
|
|||||||
#include"../renderEngine/loader.h"
|
#include"../renderEngine/loader.h"
|
||||||
namespace entities
|
namespace entities
|
||||||
{
|
{
|
||||||
main_character::main_character(const models::TexturedModel& model, const glm::vec3& position,
|
MainCharacter::MainCharacter(const models::TexturedModel& model, const glm::vec3& position,
|
||||||
const glm::vec3& rotation, float scale, const collision::Box& bounding_box)
|
const glm::vec3& rotation, float scale, const collision::Box& bounding_box)
|
||||||
: CollisionEntity(model, position, rotation, scale, bounding_box) {
|
: CollisionEntity(model, position, rotation, scale, bounding_box)
|
||||||
|
{}
|
||||||
|
|
||||||
}
|
glm::vec3 MainCharacter::Move(GLFWwindow* window)
|
||||||
glm::vec3 main_character::move(GLFWwindow* window)
|
|
||||||
{
|
{
|
||||||
float movement_speed = -1.0f;
|
float movement_speed = -1.0f; //Forward speed adjustment, bee is moving at a standard speedrate
|
||||||
float up_down_speed = -0.2f;
|
float down_speed = -1.0f; //Down speed adjustment, downspeed is difference between down_speed and UP_SPEED
|
||||||
float side_speed = 0;
|
float side_speed = 0; //Side speed adjustment
|
||||||
|
|
||||||
|
//For gameplay with use of keyboard keys: W, A, S, D
|
||||||
|
//W: Go forward
|
||||||
|
//A: Go left
|
||||||
|
//S: Go backwards
|
||||||
|
//D: Go right
|
||||||
|
//TODO Implement CV actions
|
||||||
if (glfwGetKey(window, GLFW_KEY_W) == GLFW_PRESS)
|
if (glfwGetKey(window, GLFW_KEY_W) == GLFW_PRESS)
|
||||||
{
|
{
|
||||||
movement_speed -= SPEED;
|
movement_speed -= SIDE_SPEED;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (glfwGetKey(window, GLFW_KEY_S) == GLFW_PRESS)
|
if (glfwGetKey(window, GLFW_KEY_S) == GLFW_PRESS)
|
||||||
{
|
{
|
||||||
movement_speed += SPEED;
|
movement_speed += SIDE_SPEED;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (glfwGetKey(window, GLFW_KEY_D) == GLFW_PRESS)
|
if (glfwGetKey(window, GLFW_KEY_D) == GLFW_PRESS)
|
||||||
{
|
{
|
||||||
side_speed += SPEED;
|
side_speed += SIDE_SPEED;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (glfwGetKey(window, GLFW_KEY_A) == GLFW_PRESS)
|
if (glfwGetKey(window, GLFW_KEY_A) == GLFW_PRESS)
|
||||||
{
|
{
|
||||||
side_speed -= SPEED;
|
side_speed -= SIDE_SPEED;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (glfwGetKey(window, GLFW_KEY_SPACE) == GLFW_PRESS)
|
if (glfwGetKey(window, GLFW_KEY_SPACE) == GLFW_PRESS)
|
||||||
{
|
{
|
||||||
up_down_speed += UP_SPEED;
|
down_speed += UP_SPEED;
|
||||||
}
|
}
|
||||||
if (glfwGetKey(window, GLFW_KEY_LEFT_SHIFT) == GLFW_PRESS)
|
if (glfwGetKey(window, GLFW_KEY_LEFT_SHIFT) == GLFW_PRESS)
|
||||||
{
|
{
|
||||||
up_down_speed -= UP_SPEED;
|
down_speed -= UP_SPEED;
|
||||||
}
|
}
|
||||||
IncreasePosition(glm::vec3(side_speed, up_down_speed, movement_speed));
|
IncreasePosition(glm::vec3(side_speed, down_speed, movement_speed));
|
||||||
|
|
||||||
|
//Use only for binding bee to house, such that it doesn't go outside of the room.
|
||||||
|
//TODO delete when boundingbox is implemented!
|
||||||
if (position.x > 190) position.x = 190;
|
if (position.x > 190) position.x = 190;
|
||||||
else if (position.x < -190) position.x = -190;
|
else if (position.x < -190) position.x = -190;
|
||||||
if (position.y > 350) position.y = 350;
|
if (position.y > 350) position.y = 350;
|
||||||
else if (position.y < -40) position.y = -40;
|
else if (position.y < -40) position.y = -40;
|
||||||
|
|
||||||
|
//Move player bounding box according to the position on screen
|
||||||
MoveCollisionBox();
|
MoveCollisionBox();
|
||||||
return glm::vec3(side_speed, up_down_speed, movement_speed );
|
return glm::vec3(side_speed, down_speed, movement_speed );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -5,12 +5,32 @@
|
|||||||
|
|
||||||
namespace entities
|
namespace entities
|
||||||
{
|
{
|
||||||
class main_character : public CollisionEntity {
|
/*
|
||||||
const float SPEED = 1.0f;
|
* This class contains the information about the player model
|
||||||
const float UP_SPEED = 0.6f;
|
*/
|
||||||
|
class MainCharacter : public CollisionEntity {
|
||||||
|
const float SIDE_SPEED = 0.8f; //Standard movement speed for left/right movement
|
||||||
|
const float UP_SPEED = 2.0f; //Standard movement speed for up movement
|
||||||
public:
|
public:
|
||||||
main_character(const models::TexturedModel& model, const glm::vec3& position,
|
/*
|
||||||
|
* @brief: Constructor for the main character model
|
||||||
|
*
|
||||||
|
* @param model: Model to load in as the player model
|
||||||
|
* @param position: Position of the model inside the game window
|
||||||
|
* @param rotation: Rotation of the model inside the game window
|
||||||
|
* @param scale: Size of the model
|
||||||
|
* @param bounding_box: Collision box around the player model
|
||||||
|
*/
|
||||||
|
MainCharacter(const models::TexturedModel& model, const glm::vec3& position,
|
||||||
const glm::vec3& rotation, float scale, const collision::Box& bounding_box);
|
const glm::vec3& rotation, float scale, const collision::Box& bounding_box);
|
||||||
glm::vec3 move(GLFWwindow* window);
|
|
||||||
|
/*
|
||||||
|
* @brief: A function to move the character inside the window
|
||||||
|
*
|
||||||
|
* @param window: The game window
|
||||||
|
*
|
||||||
|
* @return: Vector with the adjusted side_speed, down_speed, and movement_speed
|
||||||
|
*/
|
||||||
|
glm::vec3 Move(GLFWwindow* window);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user