minor reformat

This commit is contained in:
MihailRis 2024-03-07 11:25:10 +03:00
parent 547c80b3f0
commit 7ca410b24d

View File

@ -19,14 +19,14 @@ const float CHEAT_SPEED_MUL = 5.0f;
const float JUMP_FORCE = 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),
chosenSlot(0), chosenSlot(0),
inventory(inv), inventory(inv),
camera(new Camera(position, glm::radians(90.0f))), camera(std::make_shared<Camera>(position, glm::radians(90.0f))),
spCamera(new Camera(position, glm::radians(90.0f))), spCamera(std::make_shared<Camera>(position, glm::radians(90.0f))),
tpCamera(new Camera(position, glm::radians(90.0f))), tpCamera(std::make_shared<Camera>(position, glm::radians(90.0f))),
currentCamera(camera), currentCamera(camera),
hitbox(new Hitbox(position, glm::vec3(0.3f,0.9f,0.3f))) hitbox(std::make_unique<Hitbox>(position, glm::vec3(0.3f,0.9f,0.3f)))
{ {
} }
@ -78,10 +78,15 @@ void Player::updateInput(
float vel = std::max(glm::length(hitbox->velocity * 0.25f), 1.0f); float vel = std::max(glm::length(hitbox->velocity * 0.25f), 1.0f);
int substeps = int(delta * vel * 1000); int substeps = int(delta * vel * 1000);
substeps = std::min(100, std::max(1, substeps)); substeps = std::min(100, std::max(1, substeps));
level->physics->step(level->chunks.get(), hitbox.get(), level->physics->step(
delta, substeps, level->chunks.get(),
crouch, flight ? 0.0f : 1.0f, hitbox.get(),
!noclip); delta,
substeps,
crouch,
flight ? 0.0f : 1.0f,
!noclip
);
if (flight && hitbox->grounded) { if (flight && hitbox->grounded) {
flight = false; flight = false;
@ -131,9 +136,11 @@ void Player::teleport(glm::vec3 position) {
void Player::attemptToFindSpawnpoint(Level* level) { void Player::attemptToFindSpawnpoint(Level* level) {
glm::vec3 ppos = hitbox->position; glm::vec3 ppos = hitbox->position;
glm::vec3 newpos {ppos.x + (rand() % 200 - 100), glm::vec3 newpos (
rand() % 80 + 100, ppos.x + (rand() % 200 - 100),
ppos.z + (rand() % 200 - 100)}; rand() % 80 + 100,
ppos.z + (rand() % 200 - 100)
);
while (newpos.y > 0 && !level->chunks->isObstacleBlock(newpos.x, newpos.y-2, newpos.z)) { while (newpos.y > 0 && !level->chunks->isObstacleBlock(newpos.x, newpos.y-2, newpos.z)) {
newpos.y--; newpos.y--;
} }