![]() bs.Call and bs.WeakCallīs.Call is a convenient way to wrap up a Python callable along with arguments/keywords into a single callable object. Familiarize yourself with weakref.ref and bs.WeakCall to help combat this. If you’re writing a Mini-Game and it gets ‘stuck’ after it ends, this is probably the problem. ![]() On a related note, be aware that BombSquad Activities are told to begin *only* after the previous Activity has been cleaned up, so you should be very careful about holding strong references to Activities. If you never see this print, your object is still alive because there’s a reference to it out there somewhere. Because of this, you should make sure to avoid dependency loops in your code, using weak-references or other methods as necessary.Ī good way to debug references is to add a _del_() method to your objects containing a simple print statement. Be aware that BombSquad disables this second type of garbage collection to avoid hitches (though it does explicitly run it periodically at ‘safe’ times such as between games). (Object A referencing object B which also references A). CPython, which BombSquad uses, has two methods for garbage-collection in most cases objects are simply cleaned up when their reference-counts drop to zero, but there is also a fancier garbage-collector that runs periodically to clean up cases such as cyclical references. There are a few key concepts related to Python garbage collection to keep in mind when working in BombSquad. Some example actors include bsSpaz.Spaz which is the standard character class and bsBomb.Bomb which is the standard explosive unit.Ĭoncepts & Guidelines to Keep in Mind: Reference counts, WeakRefs, and Activities They generally encompass one or more nodes and handle message passing with other actors. bs.ActorĪctors are a high-level building block implemented purely in Python. If you want to create a single-shot timer that can’t be cancelled, you can use the bs.gameTimer() or bs.realTimer() functions. If the timer object dies (due to its reference count falling to zero) the timer will be cancelled, so make sure to store it as a field on your game/actor/etc if you want to keep it running. ![]() Timers are used to run code at some point in the future, either once or in a repeating fashion. At the most basic level, a BombSquad game script creates and manipulates these to construct a game experience. These are BombSquad’s low level building blocks. Examples of activities include mini-games and score-screens. bs.ActivityĪn activity represents a single sub-unit of a session, of which one is current at a time (though multiple can exist briefly during transitions). Current session types include Co-op, Teams, and Free-for-All. Represents the entire set of games you are playing, and is in charge of swapping in activities for games, score-screens, etc. Anyway, let’s dive right in: Classes to Be Familiar With: bs.Session We’ll get back to writing code next episide. This episode is just a brain-dump of basic scripting types and concepts, intended to be used as a reference guide.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |