Not logged inGosu Forums
Forum back to Help Search Register Login
Up Topic Gosu / Gosu Exchange / What's the proper way to do room transitions ?
- - By OldBoy Date 2014-07-23 15:56
like old-school platformers (VVVVVV, Prince Of Persia ...etc). Should I delete all the assets from old room and draw new ones every time I need to change the room, or there is some other way ? I also need room transitions for: main menu --> game --> show end game screen cycle, but I couldn't find any working examples (plain gosu, without other gems)
Parent - By jlnr (dev) Date 2014-07-23 20:38
I like the pattern where you define a GameState class that has the same callback methods as Gosu::Window does ( draw, update, ...). The window has "one" state at all times, and forwards all its callbacks to it.

One example is here:

Then when you want to show something different, you just replace the GameState instance of the main window. The pattern is very flexible. For example, if a dialog box state wants to show the game in the background, it can just have a reference to the "last state" and in its draw method, it can first draw the old state, then draw its information on top. You can also realise transitions in a similar way.

I use this pattern absolutely everywhere. :)
Parent - By ZenVirZan Date 2014-10-22 23:59
It may not be very good practice, but I use the same method as RPGMakerXP. $scene is a class that handles a scene. Window#update calls $scene.main and calls a draw in the window draw method.
In your case, I would create a main menu scene, end screen and a map scene. The map scene can load new maps within itself without requiring a scene change, and therefore leaving assets that exist through both scenes loaded through a comparison.
Up Topic Gosu / Gosu Exchange / What's the proper way to do room transitions ?

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill