pointer clarity
This commit is contained in:
parent
ceb2be7214
commit
65c0912500
|
@ -22,16 +22,18 @@ protected:
|
||||||
public:
|
public:
|
||||||
ForegroundPaletteManager* getForegroundPalette() { return foregroundPalette.get(); }
|
ForegroundPaletteManager* getForegroundPalette() { return foregroundPalette.get(); }
|
||||||
BackgroundPaletteManager* getBackgroundPalette() { return backgroundPalette.get(); }
|
BackgroundPaletteManager* getBackgroundPalette() { return backgroundPalette.get(); }
|
||||||
// bg music in here
|
|
||||||
|
// WHY raw pointers? they're unwrapped unique_ptrs managed by the scene implementation - will be cleaned up in engine
|
||||||
virtual std::vector<Sprite*> sprites() = 0;
|
virtual std::vector<Sprite*> sprites() = 0;
|
||||||
virtual std::vector<Background*> backgrounds() = 0;
|
virtual std::vector<Background*> backgrounds() = 0;
|
||||||
|
|
||||||
virtual void load() = 0;
|
virtual void load() = 0;
|
||||||
virtual void tick(u16 i) = 0;
|
virtual void tick(u16 i) = 0;
|
||||||
|
|
||||||
void setEngineForSceneSwitching(std::shared_ptr<GBAEngine> engine);
|
void setEngineForSceneSwitching(std::shared_ptr<GBAEngine> engine);
|
||||||
|
|
||||||
Scene() { }
|
Scene() { }
|
||||||
~Scene() {
|
virtual ~Scene() {
|
||||||
// scenes should manage their own resources - use std::unique_ptr
|
// scenes should manage their own resources - use std::unique_ptr
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
|
|
||||||
class SceneEffect {
|
class SceneEffect {
|
||||||
protected:
|
protected:
|
||||||
|
// WHY no reference? Scene& operator= is implicitly deleted and no intentions to use that
|
||||||
Scene* sceneToAffect;
|
Scene* sceneToAffect;
|
||||||
public:
|
public:
|
||||||
void setSceneToAffect(Scene* scene) { sceneToAffect = scene; };
|
void setSceneToAffect(Scene* scene) { sceneToAffect = scene; };
|
||||||
|
|
|
@ -15,8 +15,6 @@ void GBAEngine::update() {
|
||||||
|
|
||||||
if(currentEffectForTransition->isDone()) {
|
if(currentEffectForTransition->isDone()) {
|
||||||
setScene(sceneToTransitionTo);
|
setScene(sceneToTransitionTo);
|
||||||
sceneToTransitionTo = nullptr;
|
|
||||||
delete currentEffectForTransition;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,6 +38,12 @@ GBAEngine::GBAEngine() {
|
||||||
Allocator::free();
|
Allocator::free();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GBAEngine::cleanupPreviousScene() {
|
||||||
|
delete currentScene;
|
||||||
|
sceneToTransitionTo = nullptr;
|
||||||
|
delete currentEffectForTransition;
|
||||||
|
}
|
||||||
|
|
||||||
void GBAEngine::setScene(Scene* scene) {
|
void GBAEngine::setScene(Scene* scene) {
|
||||||
if(this->currentScene) {
|
if(this->currentScene) {
|
||||||
cleanupPreviousScene();
|
cleanupPreviousScene();
|
||||||
|
|
|
@ -13,19 +13,18 @@
|
||||||
|
|
||||||
class GBAEngine {
|
class GBAEngine {
|
||||||
private:
|
private:
|
||||||
|
// WHY raw pointers? the engine does the transition and cleanup work itself
|
||||||
Scene* currentScene;
|
Scene* currentScene;
|
||||||
SpriteManager spriteManager;
|
|
||||||
|
|
||||||
Scene* sceneToTransitionTo;
|
Scene* sceneToTransitionTo;
|
||||||
SceneEffect* currentEffectForTransition;
|
SceneEffect* currentEffectForTransition;
|
||||||
|
|
||||||
|
SpriteManager spriteManager;
|
||||||
|
|
||||||
void vsync() {
|
void vsync() {
|
||||||
while (REG_VCOUNT >= 160);
|
while (REG_VCOUNT >= 160);
|
||||||
while (REG_VCOUNT < 160);
|
while (REG_VCOUNT < 160);
|
||||||
}
|
}
|
||||||
void cleanupPreviousScene() {
|
void cleanupPreviousScene();
|
||||||
delete currentScene;
|
|
||||||
}
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
GBAEngine();
|
GBAEngine();
|
||||||
|
|
Loading…
Reference in New Issue