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