Re: garbage collection in bgt

Easiest question first: For entity managers, only have one.  When the player changes levels, dump everything but the player and reload.  If you're going to have levels, just make other levels stop, possibly even letting them reset completely.
The rest of this sails very, very far into things you get to duplicate because you chose BGT territory.  For starters, Python has Pyglet for event handling and Blinker for pubsub (though you may want to roll your own pubssub because that pattern can often be improved on).  C++ has signals2 from Boost for Pubsub and I honestly don't know what for event handling, but since it's C++ it probably has at least 5 popular options (game programming in C++ = not my idea of fun).  Java is a horrible choice for game programming but a common choice for new programmers, so it manages to also have a lot of options for the stuff being discussed here.
For menus that don't pause, you need what CAE is sugge sting, but you also need what I have seen called event bubbling.  You maintain a stack of objects that are interested in handling game events, only ever pushing onto or popping from the top.  Each event-handling function (say on_,key_press from Pyglet) returns either true or false.  When an event comes in, you begin at the top of the stack, call the event function, repeat until one of them returns true.  If the menu wants to let the things below it keep going, then, it need only return false from tick.  I like to follow this up with a base class that responds to everything and returns a member variable, coupled with a function that disables or enables passthrough for everything the thing on top doesn't override itself.  Admittedly some frameworks choose true for continue and false for stop, but the idea remains the same.
The advantage to this approach for something like an online game is that your menus can take over odd keys, say q and e for left and right and w for select or something.  The rest of the game continues responding as normal: you can walk and swing your sword and whatever, and aren't completely helpless while you hunt for chain lightning in your list of 20 spells.  You can also push things like Swamp radars onto the top and have them respond to tick without blocking it.  Finally, because it's handling the main loop, it can do stuff like account for the time it takes your game to tick and hold you at a constant framerate.  This sort of structure is almost but not quite useless for single-player games; this sort of structure is almost as necessary as giving the head programmer water for online games.

_______________________________________________
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector
  • ... AudioGames . net Forum — Developers room : camlorn via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : audiogamer21 via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : camlorn via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : audiogamer21 via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : audiogamer21 via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : audiogamer21 via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : camlorn via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : audiogamer21 via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : audiogamer21 via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : CAE_Jones via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : camlorn via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : audiogamer21 via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : CAE_Jones via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : CAE_Jones via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : CAE_Jones via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : CAE_Jones via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : camlorn via Audiogames-reflector

Reply via email to