|
@@ -1,6 +1,8 @@
|
|
#include <sstream>
|
|
#include <sstream>
|
|
|
|
|
|
#include "client/Game.h"
|
|
#include "client/Game.h"
|
|
|
|
+#include "client/utils/Utils.h"
|
|
|
|
+#include "rendering/Renderer.h"
|
|
|
|
|
|
Game::Game(const Control& control, const Camera& camera, Ray& ray, const Clock& fps, const Clock& tps,
|
|
Game::Game(const Control& control, const Camera& camera, Ray& ray, const Clock& fps, const Clock& tps,
|
|
RenderSettings& renderSettings) :
|
|
RenderSettings& renderSettings) :
|
|
@@ -10,7 +12,7 @@ widthAngle(35.0f), texture("resources/textures.png") {
|
|
for(int y = -6; y <= 6; y++) {
|
|
for(int y = -6; y <= 6; y++) {
|
|
for(int z = -6; z <= 6; z++) {
|
|
for(int z = -6; z <= 6; z++) {
|
|
if(x * x + y * y + z * z < 16) {
|
|
if(x * x + y * y + z * z < 16) {
|
|
- addCube(x - 3, y - 5, z - 10,
|
|
|
|
|
|
+ addCube(x, y, z,
|
|
x * x + (y - 1) * (y - 1) + z * z >= 16,
|
|
x * x + (y - 1) * (y - 1) + z * z >= 16,
|
|
x * x + (y + 1) * (y + 1) + z * z >= 16 && !(x == 0 && y == 3 && z == 0),
|
|
x * x + (y + 1) * (y + 1) + z * z >= 16 && !(x == 0 && y == 3 && z == 0),
|
|
(x - 1) * (x - 1) + y * y + z * z >= 16,
|
|
(x - 1) * (x - 1) + y * y + z * z >= 16,
|
|
@@ -21,8 +23,8 @@ widthAngle(35.0f), texture("resources/textures.png") {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- addCube(-3, -1, -10, false, true, true, true, true, true);
|
|
|
|
- //pos.set(-3, 0, -10);
|
|
|
|
|
|
+ addCube(0, 4, 0, false, true, true, true, true, true);
|
|
|
|
+ pos.set(0, 10, 0);
|
|
m.build();
|
|
m.build();
|
|
}
|
|
}
|
|
|
|
|
|
@@ -84,6 +86,8 @@ void Game::addCube(float x, float y, float z, bool bottom, bool top, bool left,
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+float testAngle = 0.0f;
|
|
|
|
+
|
|
void Game::tick() {
|
|
void Game::tick() {
|
|
const float speed = 0.25f;
|
|
const float speed = 0.25f;
|
|
if(control.keys.down.isDown()) {
|
|
if(control.keys.down.isDown()) {
|
|
@@ -137,20 +141,24 @@ void Game::tick() {
|
|
if(control.keys.test4.isDown()) {
|
|
if(control.keys.test4.isDown()) {
|
|
renderSettings.testBias *= 0.95f;
|
|
renderSettings.testBias *= 0.95f;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ testAngle += 5.0;
|
|
}
|
|
}
|
|
|
|
|
|
-void Game::renderWorld(float lag, MatrixStack& stack, Shader& sh) const {
|
|
|
|
|
|
+void Game::renderWorld(float lag, Renderer& renderer) const {
|
|
(void) lag;
|
|
(void) lag;
|
|
- (void) stack;
|
|
|
|
- (void) sh;
|
|
|
|
|
|
+ (void) renderer;
|
|
|
|
+ renderer.translateTo(0.0f, 0.0f, -0.5f)
|
|
|
|
+ .rotateY(interpolate(lag, testAngle - 5.0, testAngle))
|
|
|
|
+ .translate(-0.5f, 0.0f, -0.5f)
|
|
|
|
+ .update();
|
|
texture.bind(0);
|
|
texture.bind(0);
|
|
m.draw();
|
|
m.draw();
|
|
}
|
|
}
|
|
|
|
|
|
-void Game::renderTextOverlay(float lag, MatrixStack& stack, Shader& sh, FontRenderer& fr) const {
|
|
|
|
|
|
+void Game::renderTextOverlay(float lag, Renderer& renderer, FontRenderer& fr) const {
|
|
(void) lag;
|
|
(void) lag;
|
|
- //stack.get().scale(2.0f, 2.0f, 2.0f);
|
|
|
|
- sh.setMatrix("model", stack.get().getValues());
|
|
|
|
|
|
+ renderer.scale(2.0f).update();
|
|
|
|
|
|
char buffer[50];
|
|
char buffer[50];
|
|
snprintf(buffer, 50, "FPS: %.2f", fps.getUpdatesPerSecond());
|
|
snprintf(buffer, 50, "FPS: %.2f", fps.getUpdatesPerSecond());
|