Handling of game state changes (game over, etc)

164 views
Skip to first unread message

Szenia Zadvornykh

unread,
Dec 13, 2012, 11:40:35 AM12/13/12
to ash-fr...@googlegroups.com
Hello.

I recently finished my first project using Ash, where I ended up injecting a single callback from my root class (where the systems are created) into my main system (GameManager). When the game time reaches zero, this callback is executed, stopping the game update loop and showing a score screen.

This is very hack-ish, and I am looking for a more robust solution. Can anyone here share some thoughts on how to properly handle game state changes using an entity component framework like Ash?

On a related note, should I try to integrate menu screens (level select, pause, etc) into the entity component architecture, or keep such UI logic clearly separated?

Abiyasa

unread,
Dec 14, 2012, 9:48:59 AM12/14/12
to ash-fr...@googlegroups.com
I use event to notify game over. The root class (where systems are created) will dispatch game over event and the GameManager (or in my case, the play screen) will listen to it. When the event is triggered, the GameManager will stops game update loop and display different screen.

I'm not sure this is the best way to do it but I like it since the root class doesn't have to care which manager/screen will process the event.

See the code at: 

Neil Manuell

unread,
Dec 15, 2012, 9:32:34 AM12/15/12
to ash-fr...@googlegroups.com
The way I have dealt with this, subverting ash for a non game application is to create self removing systems, plus a system that monitors the number of systems currently in the game.
 I use signals for communications.

Richard

unread,
Dec 15, 2012, 12:32:24 PM12/15/12
to ash-fr...@googlegroups.com
I favour the idea of an event bus or signal bus that is shared between your game and any external systems that may need it. So, for example, a system could dispatch a game over event or signal and some object outside of the game can receive it and respond accordingly. Equally an object outside the game can communicate into the game via this event bus. You can use this for UI too, allowing you to use existing MVC frameworks for the UI and communicating with the game via the event bus.

Neil Manuell

unread,
Dec 15, 2012, 1:54:28 PM12/15/12
to ash-fr...@googlegroups.com

Mmm yes this is how I arrange my signals. Don't really like the self removing systems, but for the simple config I have at mo it works well.

On Dec 15, 2012 5:32 PM, "Richard" <ric...@richardlord.net> wrote:
I favour the idea of an event bus or signal bus that is shared between your game and any external systems that may need it. So, for example, a system could dispatch a game over event or signal and some object outside of the game can receive it and respond accordingly. Equally an object outside the game can communicate into the game via this event bus. You can use this for UI too, allowing you to use existing MVC frameworks for the UI and communicating with the game via the event bus.

--
You received this message because you are subscribed to the Google Groups "Ash Framework" group.
Visit this group at http://groups.google.com/group/ash-framework?hl=en.


vladislav oleynick

unread,
Dec 18, 2012, 5:12:15 AM12/18/12
to ash-fr...@googlegroups.com
I use entities (or entities in some state) as events. The systems just listen to nodeAdded signal from nodeList. Sometimes I create temporary entities for this and remove them after handling.
Reply all
Reply to author
Forward
0 new messages