Skip to content

Commit

Permalink
refactor(core): renamed engine
Browse files Browse the repository at this point in the history
  • Loading branch information
ms0g committed Apr 8, 2024
1 parent 1f0c265 commit 4a46817
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 16 deletions.
16 changes: 7 additions & 9 deletions src/core/engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,11 @@
#include "gui.h"
#include "../world/world.h"
#include "../world/skybox.h"
#include <chrono>
#include <thread>

VoxelEngine::VoxelEngine() = default;
VoxelEngine::~VoxelEngine() = default;
CellularAutomatonEngine::CellularAutomatonEngine() = default;
CellularAutomatonEngine::~CellularAutomatonEngine() = default;

void VoxelEngine::init() {
void CellularAutomatonEngine::init() {
mWindow = std::make_unique<Window>();
mWindow->init("Voxel Engine");

Expand Down Expand Up @@ -46,19 +44,19 @@ void VoxelEngine::init() {
mIsRunning = true;
}

void VoxelEngine::run(World& world, Skybox& skybox) {
void CellularAutomatonEngine::run(World& world, Skybox& skybox) {
while (mIsRunning) {
processInput();
update(world);
render(world, skybox);
}
}

void VoxelEngine::processInput() {
void CellularAutomatonEngine::processInput() {
mInput->process(*mCamera, mWindow->nativeHandle(), mDeltaTime, mIsRunning);
}

void VoxelEngine::update(World& world) {
void CellularAutomatonEngine::update(World& world) {
mDeltaTime = (SDL_GetTicks() - mMillisecsPreviousFrame) / 1000.0f;
mMillisecsPreviousFrame = SDL_GetTicks();
#ifdef DEBUG
Expand All @@ -70,7 +68,7 @@ void VoxelEngine::update(World& world) {
mCamera->update();
}

void VoxelEngine::render(World& world, Skybox& skybox) {
void CellularAutomatonEngine::render(World& world, Skybox& skybox) {
mWindow->clear(0.2f, 0.3f, 0.3f, 1.0f);

glm::mat4 view = mCamera->getViewMatrix();
Expand Down
6 changes: 3 additions & 3 deletions src/core/engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ class Camera;
class Window;
class Input;
class Gui;
class VoxelEngine {
class CellularAutomatonEngine {
public:
VoxelEngine();
CellularAutomatonEngine();

~VoxelEngine();
~CellularAutomatonEngine();

void init();

Expand Down
7 changes: 3 additions & 4 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@
#include "world/world.h"
#include "world/skybox.h"


int main() {
VoxelEngine voxen;
voxen.init();
CellularAutomatonEngine cae;
cae.init();

World world;
Skybox skyBox;

voxen.run(world, skyBox);
cae.run(world, skyBox);

return 0;
}

0 comments on commit 4a46817

Please sign in to comment.