reverse: libplayer
This commit is contained in:
@@ -136,18 +136,6 @@ world.set_vel_time(value: number)
|
|||||||
|
|
||||||
Устанавливает указанную скорость для игрового времени.
|
Устанавливает указанную скорость для игрового времени.
|
||||||
|
|
||||||
```python
|
|
||||||
world.get_vel_time() -> number
|
|
||||||
```
|
|
||||||
|
|
||||||
Возвращает скорость для игрового времени.
|
|
||||||
|
|
||||||
```python
|
|
||||||
world.get_total_time() -> number
|
|
||||||
```
|
|
||||||
|
|
||||||
Возвращает общее суммарное время, прошедшее в мире
|
|
||||||
|
|
||||||
```python
|
```python
|
||||||
world.get_seed() -> int
|
world.get_seed() -> int
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -147,25 +147,6 @@ static int l_player_set_spawnpoint(lua::State* L) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int l_player_set_jump_force(lua::State* L) {
|
|
||||||
|
|
||||||
if (auto player = get_player(L, 1)) {
|
|
||||||
player->setJumpForce(std::abs(lua::tonumber(L, 2)));
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int l_player_get_jump_force(lua::State* L) {
|
|
||||||
|
|
||||||
if (auto player = get_player(L, 1)) {
|
|
||||||
return lua::pushnumber(L, player->getJumpForce());
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
const luaL_Reg playerlib [] = {
|
const luaL_Reg playerlib [] = {
|
||||||
{"get_pos", lua::wrap<l_player_get_pos>},
|
{"get_pos", lua::wrap<l_player_get_pos>},
|
||||||
{"set_pos", lua::wrap<l_player_set_pos>},
|
{"set_pos", lua::wrap<l_player_set_pos>},
|
||||||
@@ -181,7 +162,5 @@ const luaL_Reg playerlib [] = {
|
|||||||
{"get_selected_block", lua::wrap<l_player_get_selected_block>},
|
{"get_selected_block", lua::wrap<l_player_get_selected_block>},
|
||||||
{"set_spawnpoint", lua::wrap<l_player_set_spawnpoint>},
|
{"set_spawnpoint", lua::wrap<l_player_set_spawnpoint>},
|
||||||
{"get_spawnpoint", lua::wrap<l_player_get_spawnpoint>},
|
{"get_spawnpoint", lua::wrap<l_player_get_spawnpoint>},
|
||||||
{"get_jump_force", lua::wrap<l_player_get_jump_force>},
|
|
||||||
{"set_jump_force", lua::wrap<l_player_set_jump_force>},
|
|
||||||
{NULL, NULL}
|
{NULL, NULL}
|
||||||
};
|
};
|
||||||
|
|||||||
+3
-12
@@ -18,7 +18,7 @@ const float PLAYER_GROUND_DAMPING = 10.0f;
|
|||||||
const float PLAYER_AIR_DAMPING = 7.0f;
|
const float PLAYER_AIR_DAMPING = 7.0f;
|
||||||
const float FLIGHT_SPEED_MUL = 4.0f;
|
const float FLIGHT_SPEED_MUL = 4.0f;
|
||||||
const float CHEAT_SPEED_MUL = 5.0f;
|
const float CHEAT_SPEED_MUL = 5.0f;
|
||||||
const float JUMP_FACTOR = 8.0f;
|
const float JUMP_FORCE = 8.0f;
|
||||||
|
|
||||||
Player::Player(glm::vec3 position, float speed, std::shared_ptr<Inventory> inv) :
|
Player::Player(glm::vec3 position, float speed, std::shared_ptr<Inventory> inv) :
|
||||||
speed(speed),
|
speed(speed),
|
||||||
@@ -96,7 +96,7 @@ void Player::updateInput(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (input.jump && hitbox->grounded){
|
if (input.jump && hitbox->grounded){
|
||||||
hitbox->velocity.y = JUMP_FACTOR * jumpForce;
|
hitbox->velocity.y = JUMP_FORCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((input.flight && !noclip) ||
|
if ((input.flight && !noclip) ||
|
||||||
@@ -106,7 +106,6 @@ void Player::updateInput(
|
|||||||
hitbox->grounded = false;
|
hitbox->grounded = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (input.noclip) {
|
if (input.noclip) {
|
||||||
noclip = !noclip;
|
noclip = !noclip;
|
||||||
}
|
}
|
||||||
@@ -185,14 +184,6 @@ void Player::setNoclip(bool flag) {
|
|||||||
this->noclip = flag;
|
this->noclip = flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
float Player::getJumpForce() const {
|
|
||||||
return jumpForce;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Player::setJumpForce(float value) {
|
|
||||||
jumpForce = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::shared_ptr<Inventory> Player::getInventory() const {
|
std::shared_ptr<Inventory> Player::getInventory() const {
|
||||||
return inventory;
|
return inventory;
|
||||||
}
|
}
|
||||||
@@ -284,4 +275,4 @@ void Player::convert(dynamic::Map* data, const ContentLUT* lut) {
|
|||||||
Inventory::convert(inventory, lut);
|
Inventory::convert(inventory, lut);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -45,7 +45,6 @@ class Player : public Object, public Serializable {
|
|||||||
int chosenSlot;
|
int chosenSlot;
|
||||||
glm::vec3 spawnpoint {};
|
glm::vec3 spawnpoint {};
|
||||||
std::shared_ptr<Inventory> inventory;
|
std::shared_ptr<Inventory> inventory;
|
||||||
float jumpForce = 1.0f;
|
|
||||||
bool flight = false;
|
bool flight = false;
|
||||||
bool noclip = false;
|
bool noclip = false;
|
||||||
public:
|
public:
|
||||||
@@ -74,9 +73,6 @@ public:
|
|||||||
|
|
||||||
bool isNoclip() const;
|
bool isNoclip() const;
|
||||||
void setNoclip(bool flag);
|
void setNoclip(bool flag);
|
||||||
|
|
||||||
float getJumpForce() const;
|
|
||||||
void setJumpForce(float value);
|
|
||||||
|
|
||||||
std::shared_ptr<Inventory> getInventory() const;
|
std::shared_ptr<Inventory> getInventory() const;
|
||||||
|
|
||||||
@@ -93,4 +89,4 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SRC_OBJECTS_PLAYER_HPP_
|
#endif // SRC_OBJECTS_PLAYER_HPP_
|
||||||
Reference in New Issue
Block a user