blob: 2c7bb8fe8443a2d62ba114743a7deb322325bd22 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
#include "minecraft.hpp"
#include <chrono>
using namespace std::chrono;
namespace app {
Minecraft::Minecraft() : engine{WIDTH, HEIGHT, "Minecraft Vulkan", "res/image/icon.png"} {};
Minecraft::~Minecraft() {}
void Minecraft::run() {
Chunk::load();
auto viewer = xe::GameObject::createGameObject();
viewer.transform.translation = {0.f, 40.f, 0.f};
viewer.transform.rotation.y = glm::radians(45.f);
World world {viewer, 10, 12345};
xe::Sound sound{"res/sound/when_the_world_ends.wav"};
sound.setLooping(true);
sound.play();
PlayerController playerController{engine.getInput(), viewer};
while (engine.poll()) {
playerController.update(engine.getFrameTime());
world.reloadChunks();
if(engine.beginFrame()) {
world.render(engine.getCamera());
engine.endFrame();
}
}
engine.close();
Chunk::unload();
}
}
|