diff options
author | Matthew Kosarek <matthew@matthewkosarek.xyz> | 2023-09-27 08:03:04 -0400 |
---|---|---|
committer | Matthew Kosarek <matthew@matthewkosarek.xyz> | 2023-09-27 08:03:04 -0400 |
commit | 1da356d8a64c45c99871aca156ee9fdd3e10ec15 (patch) | |
tree | 00438481bc972c9606995af794be09189833510a /themes/src/autumn | |
parent | ec0b1d450a0f6219b3b0d352cd6625ae05f62618 (diff) |
Simplification of the Theme system with a more OO model
Diffstat (limited to 'themes/src/autumn')
-rw-r--r-- | themes/src/autumn/AutumnTheme.cpp | 14 | ||||
-rw-r--r-- | themes/src/autumn/AutumnTheme.hpp | 10 |
2 files changed, 21 insertions, 3 deletions
diff --git a/themes/src/autumn/AutumnTheme.cpp b/themes/src/autumn/AutumnTheme.cpp index affcc00..c6431a1 100644 --- a/themes/src/autumn/AutumnTheme.cpp +++ b/themes/src/autumn/AutumnTheme.cpp @@ -8,6 +8,17 @@ namespace const int NUM_HILLS = 3; } +AutumnTheme::AutumnTheme(Renderer2d* renderer) + : renderer{renderer} +{ + load(renderer); +} + +AutumnTheme::~AutumnTheme() +{ + unload(); +} + void AutumnTheme::load(Renderer2d* renderer) { renderer->clearColor = Vector4(252, 210, 153, 255).toNormalizedColor(); auto lr = tree.load(renderer); @@ -45,7 +56,8 @@ void AutumnTheme::update(f32 dtSeconds) { leafParticles.update(dtSeconds); } -void AutumnTheme::render(Renderer2d* renderer) { +void AutumnTheme::render() { + renderer->render(); background->render(); background_hill->render(); tree.render(renderer); diff --git a/themes/src/autumn/AutumnTheme.hpp b/themes/src/autumn/AutumnTheme.hpp index 2d9958c..41df04c 100644 --- a/themes/src/autumn/AutumnTheme.hpp +++ b/themes/src/autumn/AutumnTheme.hpp @@ -4,6 +4,7 @@ #include "TreeShape.h" #include "LeafParticleRender.h" #include "../types.h" +#include "../theme.h" #include <memory> #include <vector> @@ -11,7 +12,10 @@ struct Renderer2d; class RectangularGradient; class Circleish; -struct AutumnTheme { +class AutumnTheme : public Theme { +public: + AutumnTheme(Renderer2d* renderer); + ~AutumnTheme(); TreeShape tree; LeafParticleRender leafParticles; RectangularGradient* background; @@ -20,8 +24,10 @@ struct AutumnTheme { void load(Renderer2d* renderer); void update(f32 dtSeconds); - void render(Renderer2d* renderer); + void render(); void unload(); +private: + Renderer2d* renderer; }; #endif |