|
@@ -34,28 +34,34 @@ static void tickConnectedState() {
|
|
|
back.normalize();
|
|
|
Vector3 right = back.cross(up);
|
|
|
|
|
|
- constexpr float speed = 0.1f;
|
|
|
constexpr float rotationSpeed = 4.0f;
|
|
|
ControllerPacket cp;
|
|
|
+
|
|
|
+ Vector3 force;
|
|
|
if(Game::controller.down.isDown()) {
|
|
|
cp.set(ControllerPacket::Type::DOWN);
|
|
|
- Game::player.addForce(back * speed);
|
|
|
+ force += back;
|
|
|
}
|
|
|
if(Game::controller.up.isDown()) {
|
|
|
cp.set(ControllerPacket::Type::UP);
|
|
|
- Game::player.addForce(back * -speed);
|
|
|
+ force -= back;
|
|
|
}
|
|
|
if(Game::controller.left.isDown()) {
|
|
|
cp.set(ControllerPacket::Type::LEFT);
|
|
|
- Game::player.addForce(right * -speed);
|
|
|
+ force -= right;
|
|
|
}
|
|
|
if(Game::controller.right.isDown()) {
|
|
|
cp.set(ControllerPacket::Type::RIGHT);
|
|
|
- Game::player.addForce(right * speed);
|
|
|
+ force += right;
|
|
|
+ }
|
|
|
+ if(force.squareLength() > 0.0f) {
|
|
|
+ force.normalize();
|
|
|
}
|
|
|
+ Game::player.addForce(force * 0.1f);
|
|
|
+
|
|
|
if(Game::controller.jump.isDown() && Game::player.isOnGround()) {
|
|
|
cp.set(ControllerPacket::Type::JUMP);
|
|
|
- Game::player.addForce(up * 0.5f);
|
|
|
+ Game::player.addForce(up * (0.42f / 0.98f + 0.08f));
|
|
|
}
|
|
|
if(Game::controller.sneak.isDown()) {
|
|
|
cp.set(ControllerPacket::Type::SNEAK);
|
|
@@ -111,6 +117,7 @@ bool Game::init() {
|
|
|
tickState = tickConnectState;
|
|
|
renderState = renderConnectState;
|
|
|
|
|
|
+ Game::player.setPosition(Vector3(0.0f, 2.0f, 0.0f));
|
|
|
world.addEntity(&player);
|
|
|
return false;
|
|
|
}
|
|
@@ -134,13 +141,17 @@ void Game::renderOverlay() {
|
|
|
.append(" &999TPS: &722")
|
|
|
.append(Engine::getTickClock().getUpdatesPerSecond());
|
|
|
Engine::renderer.renderString(Vector2(10.0f, 10.0f), s);
|
|
|
+ s.clear().append("a = ").append(player.acceleration);
|
|
|
+ Engine::renderer.renderString(Vector2(10.0f, 20.0f), s);
|
|
|
+ s.clear().append("v = ").append(player.velocity);
|
|
|
+ Engine::renderer.renderString(Vector2(10.0f, 30.0f), s);
|
|
|
}
|
|
|
|
|
|
void Game::onEntityUpdate(EntityUpdatePacket& p) {
|
|
|
float distance = (p.position - player.position).squareLength();
|
|
|
- StringBuffer<50>(distance).printLine();
|
|
|
+ LOG_DEBUG(StringBuffer<50>(distance));
|
|
|
if(distance > 25.0f) {
|
|
|
- std::cout << "set\n";
|
|
|
+ LOG_DEBUG("set");
|
|
|
player.setPosition(p.position);
|
|
|
}
|
|
|
// player.position = p.position;
|