Remove node class

This commit is contained in:
Tulpen 2023-06-26 16:08:19 +02:00
parent 493ab7eb6e
commit a5380c4417
No known key found for this signature in database
GPG key ID: 12294D73B907E784
5 changed files with 24 additions and 51 deletions

18
TODO.md
View file

@ -1,21 +1,18 @@
# Hibis Engine - Feature TODOs
## Core
## Core Module
- [ ] BetterC compatibility
- [ ] Texture loading
- [ ] Model loading
- [ ] Base Renderer class
- [ ] Base Physics class
- [ ] Base Node class
- [ ] Base UI Node class
- [ ] Base Audio Playback Node class
- [ ] Figure out how scenes should be handled
- [ ] Split other sections into seperate libraries (renderers, physics)
## Audio
## Audio Module
- [ ] OGG and WAV support (do first)
- [ ] MP3 (later)
- [ ] Audio playing nodes
## Hibis UI (NEED A NAME)
## Hibis UI (NEEDS A NAME)
- [ ] GUI creation
- [ ] Text Object (rendering via SDL2_TTF (RSDL) or FreeType2 (EVERYTHING ELSE))
- [ ] Text Object (rendering via FreeType2)
## RGLCore (2D AND 3D)
- [X] Window creation
- [ ] Renderer creation
@ -35,6 +32,9 @@
## Hibis Physics (NEED A NAME)
- [ ] Physics Shape creation
- [ ] Collision via raycasting
- [ ] Option to *allow* for Physics Shapes to be able to be drawn (on by default, both compile time and run time, turn off at compile time via version(`-version=NoPhysShapeDraw`?))
- [ ] Option to *allow* for Physics Shapes to be able to be drawn (on by default, both compile time and run time, turn off at compile time via a flag (`-DNoPhysShapeDraw=1`?))
## Examples
- [ ] Example: UI test
- [ ] Example Game: Megaman clone
- [ ] Stress test using sprites
- [ ] Stress test using models

View file

@ -25,36 +25,24 @@ namespace hibis {
//watch.stop();
}
void Engine::runNodeProcesses() {
TODO("check if delta calc is correct")
TODO("get workaround for MSVC being fucking stupid (std::chrono + std::this_thread)")
float Engine::calculateDelta(bool isPhysics) {
const std::chrono::time_point<std::chrono::steady_clock> current = std::chrono::steady_clock::now();
auto delta = std::chrono::duration<float>(current - mPreviousProcessTick);
if (isPhysics) {
auto delta = std::chrono::duration<float>(current - mPreviousPhysicsProcessTick);
for (Node* node : mNodeList) {
node->process(delta.count());
return delta.count();
} else {
auto delta = std::chrono::duration<float>(current - mPreviousProcessTick);
return delta.count();
}
mPreviousProcessTick = std::chrono::steady_clock::now();
}
void Engine::runNodePhysicsProcesses() {
const std::chrono::time_point<std::chrono::steady_clock> current = std::chrono::steady_clock::now();
auto delta = std::chrono::duration<float>(current - mPreviousProcessTick);
for (Node* node : mNodeList) {
node->physicsProcess(delta.count());
}
mPreviousProcessTick = std::chrono::steady_clock::now();
}
void Engine::drawNodes() {
TODO("check if this works")
for (Node* node : mNodeList) {
if (Drawable* drawNode = (Drawable*)&node) {
drawNode->draw(mRenderer);
}
void Engine::updateDelta(bool isPhysics) {
if (isPhysics) {
mPreviousPhysicsProcessTick = std::chrono::steady_clock::now();
} else {
mPreviousProcessTick = std::chrono::steady_clock::now();
}
}

View file

@ -6,7 +6,6 @@
#include "../renderer/renderer.hpp"
#include "../callback.hpp"
#include "../node/node.hpp"
namespace hibis {
class Engine {
@ -14,11 +13,9 @@ namespace hibis {
Engine(Renderer* renderer, LoggerCallback logger);
~Engine();
void runNodeProcesses();
float calculateDelta(bool isPhysics);
void runNodePhysicsProcesses();
void drawNodes();
void updateDelta(bool isPhysics);
const char* getEngineVersion();
@ -29,7 +26,6 @@ namespace hibis {
std::chrono::time_point<std::chrono::steady_clock> mPreviousProcessTick;
std::chrono::time_point<std::chrono::steady_clock> mPreviousPhysicsProcessTick;
std::vector<Node*> mNodeList;
LoggerCallback mLoggerCallback;
};
}

View file

@ -1,9 +0,0 @@
#pragma once
namespace hibis {
class Node {
public:
virtual void process(float delta) {}
virtual void physicsProcess(float delta) {}
};
}

View file

@ -70,8 +70,6 @@ int main() {
logger(Information, "Started Hibis test app! BEHOLD: Colours.");
while (renderer.mKeepOpen) {
engine.runNodeProcesses();
// Colour changing background!
if ((red == 255 && increaseRed) || (red == 0 && !increaseRed)) {
increaseRed = !increaseRed;