|
@@ -6,11 +6,9 @@
|
|
#include "common/network/toserver/PlayerUpdatePacket.h"
|
|
#include "common/network/toserver/PlayerUpdatePacket.h"
|
|
#include "rendering/renderer/WorldRenderer.h"
|
|
#include "rendering/renderer/WorldRenderer.h"
|
|
#include "utils/Logger.h"
|
|
#include "utils/Logger.h"
|
|
-#include "utils/Random.h"
|
|
|
|
#include "utils/Utils.h"
|
|
#include "utils/Utils.h"
|
|
|
|
|
|
-BlockRegistry Game::blockRegistry;
|
|
|
|
-World Game::world{blockRegistry};
|
|
|
|
|
|
+World Game::world;
|
|
static WorldRenderer worldRenderer{Game::world};
|
|
static WorldRenderer worldRenderer{Game::world};
|
|
Controller Game::controller;
|
|
Controller Game::controller;
|
|
Entity Game::player;
|
|
Entity Game::player;
|
|
@@ -22,9 +20,6 @@ static State renderState;
|
|
static BaseGUI baseGUI;
|
|
static BaseGUI baseGUI;
|
|
static StartGUI startGUI;
|
|
static StartGUI startGUI;
|
|
|
|
|
|
-static List<PlayerUpdatePacket> delay;
|
|
|
|
-static Random rng;
|
|
|
|
-
|
|
|
|
static void tickConnectedState() {
|
|
static void tickConnectedState() {
|
|
Game::player.skip = false;
|
|
Game::player.skip = false;
|
|
Game::world.tick();
|
|
Game::world.tick();
|
|
@@ -59,7 +54,6 @@ static void tickConnectedState() {
|
|
|
|
|
|
if(Game::controller.jump.isDown() && Game::player.isOnGround()) {
|
|
if(Game::controller.jump.isDown() && Game::player.isOnGround()) {
|
|
Game::player.jump();
|
|
Game::player.jump();
|
|
- // Game::player.acceleration[1] += 0.4;
|
|
|
|
}
|
|
}
|
|
if(Game::controller.camLeft.isDown()) {
|
|
if(Game::controller.camLeft.isDown()) {
|
|
Game::player.addLengthAngle(-rotationSpeed);
|
|
Game::player.addLengthAngle(-rotationSpeed);
|
|
@@ -74,21 +68,10 @@ static void tickConnectedState() {
|
|
Game::player.addWidthAngle(rotationSpeed * 0.5f);
|
|
Game::player.addWidthAngle(rotationSpeed * 0.5f);
|
|
}
|
|
}
|
|
|
|
|
|
- delay.add(PlayerUpdatePacket(Game::player));
|
|
|
|
- if(rng.nextFloat() < 0.5f) {
|
|
|
|
- OutPacket out = OutPacket::reliable(PlayerUpdatePacket::getSize());
|
|
|
|
- delay[0].write(out);
|
|
|
|
- GameClient::send(out);
|
|
|
|
- delay.remove(0);
|
|
|
|
-
|
|
|
|
- if(delay.getLength() > 0) {
|
|
|
|
- OutPacket out = OutPacket::reliable(PlayerUpdatePacket::getSize());
|
|
|
|
- delay[0].write(out);
|
|
|
|
- GameClient::send(out);
|
|
|
|
- delay.remove(0);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- LOG_DEBUG(delay.getLength());
|
|
|
|
|
|
+ PlayerUpdatePacket p(Game::player);
|
|
|
|
+ OutPacket out = OutPacket::reliable(PlayerUpdatePacket::getSize());
|
|
|
|
+ p.write(out);
|
|
|
|
+ GameClient::send(out);
|
|
}
|
|
}
|
|
|
|
|
|
static void renderConnectedState() {
|
|
static void renderConnectedState() {
|
|
@@ -114,6 +97,7 @@ static void renderConnectState() {
|
|
}
|
|
}
|
|
|
|
|
|
bool Game::init() {
|
|
bool Game::init() {
|
|
|
|
+ Block::init();
|
|
if(worldRenderer.init()) {
|
|
if(worldRenderer.init()) {
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
@@ -155,5 +139,4 @@ void Game::onEntityUpdate(EntityUpdatePacket& p) {
|
|
LOG_DEBUG("set");
|
|
LOG_DEBUG("set");
|
|
player.setPosition(p.position);
|
|
player.setPosition(p.position);
|
|
player.velocity = p.velocity;
|
|
player.velocity = p.velocity;
|
|
- delay.clear();
|
|
|
|
}
|
|
}
|