--- /dev/null
+#include "Spawner.hpp"
+
+#include "RandomWalk.hpp"
+#include "../world/BlockType.hpp"
+#include "../world/BlockTypeRegistry.hpp"
+#include "../world/Entity.hpp"
+#include "../world/World.hpp"
+
+
+namespace blank {
+
+Spawner::Spawner(World &world)
+: world(world)
+, controllers() {
+ Spawn({ 0.0f, 0.0f, 0.0f });
+}
+
+Spawner::~Spawner() {
+
+}
+
+
+void Spawner::Update(int dt) {
+ for (auto &ctrl : controllers) {
+ ctrl.Update(dt);
+ }
+}
+
+
+void Spawner::Spawn(const glm::vec3 &pos) {
+ Entity &e = world.AddEntity();
+ e.Name("test");
+ e.Position(pos);
+ e.Bounds({ { -0.5f, -0.5f, -0.5f }, { 0.5f, 0.5f, 0.5f } });
+ e.WorldCollidable(true);
+ e.SetShape(world.BlockTypes()[1].shape, { 1.0f, 1.0f, 0.0f });
+ e.AngularVelocity(glm::quat(glm::vec3{ 0.00001f, 0.000006f, 0.000013f }));
+ controllers.emplace_back(e);
+}
+
+}
--- /dev/null
+#ifndef BLANK_AI_SPAWNER_HPP_
+#define BLANK_AI_SPAWNER_HPP_
+
+#include <list>
+#include <glm/glm.hpp>
+
+
+namespace blank {
+
+class RandomWalk;
+class World;
+
+class Spawner {
+
+public:
+ explicit Spawner(World &);
+ ~Spawner();
+
+ void Update(int dt);
+
+private:
+ void Spawn(const glm::vec3 &);
+
+private:
+ World &world;
+ std::list<RandomWalk> controllers;
+
+};
+
+}
+
+#endif
#include "Assets.hpp"
#include "FrameCounter.hpp"
-#include "../ai/RandomWalk.hpp"
+#include "../ai/Spawner.hpp"
#include "../audio/Audio.hpp"
#include "../graphics/Viewport.hpp"
#include "../ui/Interface.hpp"
/// push the current state to display
void Render();
- static Entity &MakeTestEntity(World &);
-
private:
Window &window;
Viewport viewport;
World world;
Interface interface;
- RandomWalk test_controller;
+ Spawner spawner;
bool running;
, counter()
, world(config.world)
, interface(config.interface, assets, audio, counter, world)
-, test_controller(MakeTestEntity(world))
+, spawner(world)
, running(false) {
viewport.VSync(config.vsync);
}
audio.StopAll();
}
-Entity &Application::MakeTestEntity(World &world) {
- Entity &e = world.AddEntity();
- e.Name("test");
- e.Position({ 0.0f, 0.0f, 0.0f });
- e.Bounds({ { -0.5f, -0.5f, -0.5f }, { 0.5f, 0.5f, 0.5f } });
- e.WorldCollidable(true);
- e.SetShape(world.BlockTypes()[1].shape, { 1.0f, 1.0f, 0.0f });
- e.AngularVelocity(glm::quat(glm::vec3{ 0.00001f, 0.000006f, 0.000013f }));
- return e;
-}
-
void Application::RunN(size_t n) {
Uint32 last = SDL_GetTicks();
void Application::Update(int dt) {
counter.EnterUpdate();
interface.Update(dt);
- test_controller.Update(dt);
+ spawner.Update(dt);
world.Update(dt);
glm::mat4 trans = world.Player().Transform(Chunk::Pos(0, 0, 0));