2022-10-01 18:35:16 +00:00
|
|
|
#include "minecraft.hpp"
|
2022-09-19 01:20:51 +00:00
|
|
|
|
2022-09-30 19:40:42 +00:00
|
|
|
#include <chrono>
|
|
|
|
using namespace std::chrono;
|
|
|
|
|
2022-09-20 01:28:41 +00:00
|
|
|
namespace app {
|
2022-09-19 01:20:51 +00:00
|
|
|
|
2022-10-01 20:28:38 +00:00
|
|
|
Minecraft::Minecraft() : engine{WIDTH, HEIGHT, "Minecraft Vulkan", "res/image/icon.png"} {};
|
2022-09-19 01:20:51 +00:00
|
|
|
|
2022-10-01 18:35:16 +00:00
|
|
|
Minecraft::~Minecraft() {}
|
2022-09-19 01:20:51 +00:00
|
|
|
|
2022-10-01 18:35:16 +00:00
|
|
|
void Minecraft::run() {
|
2022-09-19 01:20:51 +00:00
|
|
|
|
2022-09-27 00:57:53 +00:00
|
|
|
Chunk::load();
|
2022-09-21 02:02:58 +00:00
|
|
|
|
2022-10-01 20:28:38 +00:00
|
|
|
auto viewer = xe::GameObject::createGameObject();
|
|
|
|
viewer.transform.translation = {0.f, 40.f, 0.f};
|
|
|
|
viewer.transform.rotation.y = glm::radians(45.f);
|
2022-09-27 21:03:43 +00:00
|
|
|
|
2022-10-01 20:28:38 +00:00
|
|
|
World world {viewer, 10, 12345};
|
2022-09-22 15:14:00 +00:00
|
|
|
|
2022-09-29 02:55:22 +00:00
|
|
|
xe::Sound sound{"res/sound/when_the_world_ends.wav"};
|
|
|
|
sound.setLooping(true);
|
|
|
|
sound.play();
|
2022-09-20 01:28:41 +00:00
|
|
|
|
2022-10-01 20:28:38 +00:00
|
|
|
PlayerController playerController{engine.getInput(), viewer};
|
2022-09-19 01:20:51 +00:00
|
|
|
|
2022-10-01 20:28:38 +00:00
|
|
|
while (engine.poll()) {
|
2022-09-19 01:20:51 +00:00
|
|
|
|
2022-10-01 20:28:38 +00:00
|
|
|
playerController.update(engine.getFrameTime());
|
2022-09-19 01:20:51 +00:00
|
|
|
|
2022-10-01 20:28:38 +00:00
|
|
|
world.reloadChunks();
|
2022-09-19 01:20:51 +00:00
|
|
|
|
2022-10-01 20:28:38 +00:00
|
|
|
if(engine.beginFrame()) {
|
|
|
|
world.render(engine.getCamera());
|
|
|
|
engine.endFrame();
|
2022-09-19 20:35:45 +00:00
|
|
|
}
|
2022-09-27 21:03:43 +00:00
|
|
|
|
2022-09-19 01:20:51 +00:00
|
|
|
}
|
|
|
|
|
2022-10-01 20:28:38 +00:00
|
|
|
engine.close();
|
2022-09-19 01:20:51 +00:00
|
|
|
|
2022-09-27 00:57:53 +00:00
|
|
|
Chunk::unload();
|
|
|
|
|
2022-09-19 01:20:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|