Skip to content

Commit

Permalink
switch scenes to use an internal scene list rather than a global object
Browse files Browse the repository at this point in the history
  • Loading branch information
BinaryMoon committed Feb 13, 2025
1 parent cd9ee57 commit e7fd7c2
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions src/internal/scene.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
*/
let activeScene = null;

const sceneList = {};


/**
* Adds a new scene to the scene manager.
Expand All @@ -36,7 +38,11 @@

beep8.Utilities.checkInt( 'frameRate', frameRate );

beep8.scenes[ name ] = { update, render, frameRate };
const init = gameObject.init || null;
const update = gameObject.update || null;
const render = gameObject.render || null;

sceneList[ name ] = { init, update, render, frameRate };

};

Expand All @@ -50,7 +56,7 @@

beep8.Utilities.checkString( 'name', name );

if ( !beep8.scenes[ name ] ) {
if ( !sceneList[ name ] ) {
beep8.Utilities.fatal( `Scene "${name}" does not exist.` );
}

Expand All @@ -72,4 +78,16 @@

};


/**
* Gets all scenes.
*
* @returns {Object} All scenes.
*/
beep8.Scenes.getAll = function() {

return sceneList;

};

} )( beep8 || ( beep8 = {} ) );

0 comments on commit e7fd7c2

Please sign in to comment.