• entries
22
11
• views
25711

# Toasty Update #2

482 views

So previously I showed a basic usage of the GameSystem and how the GameSystem works as well as the BehaviourSystem. I also showed how on windows the maximum FPS was 999 compared to Mac and Linux which had many thousands. This is due to visual studio missing a proper high res timer implementation for std::chrono and if the speed of the application is equal to or greater than 1000 the two timepoints taken before and after execution will be seen as the same points creating a delta of 0, at the moment I have a simple way of fixing it:#ifdef WIN32 while(timeTwo == timeOne) { timeTwo = std::chrono::high_resolution_clock::now(); }#endif
It just loops until timeTwo is no longer the same as timeOne! Pretty easy fix, I don't plan on removing this until the proper high res timer is implemented in msvc.

So for this time I'll talk about scenes.

Scenes basically just contain entities and the components those entities hold (And what systems those components should go into). You can define a scene something like this:// Create the sceneScene* myScene = new Scene();// Create an entityToasty::Entity* entity = new Toasty::Entity();// Create a component to attach to the entitytestScript = new DebugInfoTest(gameSystem, entity);// Add entity if it isn't already added and attach the testScript component to it// making sure it goes to the Toasty::BehaviourSystem system.myScene->AttachComponent(entity , "Toasty::BehaviourSystem", testScript);// Then somewhere in the program// This will load the scene and populate the entities into the system// Which will go ahead and give them unique ids and put the components// into systems (if the systems exist in the gamesystem).gameSystem->LoadScene(myScene);// Then somewhere else in the program// Takes out all the entities, components that myScene loaded into the gameSystem.gameSystem->UnloadScene(myScene);
The cool thing about scenes is you can load them while another one is loaded, a use-case for this is kind of memory buckets, breaking up a scene into essential \ non-essential parts so you can load one straight away and then load the next one slowly over many frames. Another thing you can do is inherit from Scene and have your scene manage it's entities and components memory.

At the moment scenes don't copy construct the entities and components instead they directly use the created entities and components. In my next update I'll probably have worked on some sort of rendersystem.

There are no comments to display.

## Create an account

Register a new account