mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-05 02:51:49 +00:00
refactor Entities
This commit is contained in:
parent
36a522bee0
commit
3eae377024
23 changed files with 485 additions and 348 deletions
|
|
@ -9,6 +9,7 @@
|
|||
#include "content/ContentReport.hpp"
|
||||
#include "items/Inventory.hpp"
|
||||
#include "Entities.hpp"
|
||||
#include "Entity.hpp"
|
||||
#include "rigging.hpp"
|
||||
#include "physics/Hitbox.hpp"
|
||||
#include "physics/PhysicsSolver.hpp"
|
||||
|
|
@ -137,7 +138,7 @@ void Player::updateInput(PlayerInput& input, float delta) {
|
|||
}
|
||||
if (glm::length(dir) > 0.0f) {
|
||||
dir = glm::normalize(dir);
|
||||
hitbox->velocity += dir * speed * delta * 9.0f;
|
||||
doMove(dir, speed, delta);
|
||||
}
|
||||
if (flight) {
|
||||
if (input.jump) {
|
||||
|
|
@ -146,9 +147,22 @@ void Player::updateInput(PlayerInput& input, float delta) {
|
|||
if (input.shift) {
|
||||
hitbox->velocity.y -= speed * delta * 9;
|
||||
}
|
||||
} else if (input.jump) {
|
||||
doJump();
|
||||
}
|
||||
if (input.jump && hitbox->grounded) {
|
||||
hitbox->velocity.y = JUMP_FORCE;
|
||||
}
|
||||
|
||||
void Player::doMove(const glm::vec3& dir, float speed, float delta) {
|
||||
if (auto hitbox = getHitbox()) {
|
||||
hitbox->velocity += dir * speed * delta * 9.0f;
|
||||
}
|
||||
}
|
||||
|
||||
void Player::doJump() {
|
||||
if (auto hitbox = getHitbox()) {
|
||||
if (hitbox->grounded) {
|
||||
hitbox->velocity.y = JUMP_FORCE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue