mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-05 11:01:49 +00:00
add: lua func
This commit is contained in:
parent
2f2d6a69e8
commit
7a1c035f01
7 changed files with 114 additions and 4 deletions
|
|
@ -18,7 +18,7 @@ const float PLAYER_GROUND_DAMPING = 10.0f;
|
|||
const float PLAYER_AIR_DAMPING = 7.0f;
|
||||
const float FLIGHT_SPEED_MUL = 4.0f;
|
||||
const float CHEAT_SPEED_MUL = 5.0f;
|
||||
const float JUMP_FORCE = 8.0f;
|
||||
const float JUMP_FACTOR = 8.0f;
|
||||
|
||||
Player::Player(glm::vec3 position, float speed, std::shared_ptr<Inventory> inv) :
|
||||
speed(speed),
|
||||
|
|
@ -96,7 +96,7 @@ void Player::updateInput(
|
|||
}
|
||||
|
||||
if (input.jump && hitbox->grounded){
|
||||
hitbox->velocity.y = JUMP_FORCE;
|
||||
hitbox->velocity.y = JUMP_FACTOR * jumpForce;
|
||||
}
|
||||
|
||||
if ((input.flight && !noclip) ||
|
||||
|
|
@ -106,6 +106,7 @@ void Player::updateInput(
|
|||
hitbox->grounded = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (input.noclip) {
|
||||
noclip = !noclip;
|
||||
}
|
||||
|
|
@ -184,6 +185,14 @@ void Player::setNoclip(bool flag) {
|
|||
this->noclip = flag;
|
||||
}
|
||||
|
||||
float Player::getJumpForce() const {
|
||||
return jumpForce;
|
||||
}
|
||||
|
||||
void Player::setJumpForce(float value) {
|
||||
jumpForce = value;
|
||||
}
|
||||
|
||||
std::shared_ptr<Inventory> Player::getInventory() const {
|
||||
return inventory;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ class Player : public Object, public Serializable {
|
|||
int chosenSlot;
|
||||
glm::vec3 spawnpoint {};
|
||||
std::shared_ptr<Inventory> inventory;
|
||||
float jumpForce = 1.0f;
|
||||
bool flight = false;
|
||||
bool noclip = false;
|
||||
public:
|
||||
|
|
@ -73,6 +74,9 @@ public:
|
|||
|
||||
bool isNoclip() const;
|
||||
void setNoclip(bool flag);
|
||||
|
||||
float getJumpForce() const;
|
||||
void setJumpForce(float value);
|
||||
|
||||
std::shared_ptr<Inventory> getInventory() const;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue