Of Loot Bombs and Sticky Walls
While you program, you create and form a thought and visualize it through a programming language. It's a beautiful and interesting process that is its own reward. But inevitably, this process will also create nasty little buggers called bugs. A flaws in thought, programming logic or simply an error while writing code.
In the early Critters development, back in the dawn of time (few weeks ago). I implemented a Toolbar HUD element with a few Critters-Murder tools I wanted to test and play around with, with one of them being a grenade type weapon that player can drop on the little bastards. After timer is complete, the bomb grenade explodes with the satisfying destruction inside its radius.
Critters die and spawn gems and ammo. Player collects loot and continues the destruction.
All in all, often used but a proven little concept of blowing stuff up. Until loot pickup started spawning their own grenades - that is. Now, I'm the first one in line for more Critter destruction, but we can't just have anarchy grenades running around. It would inhibit us in Critter destruction in the future.
It was some weird shit. Loot didn't even come close to bombs being spawned. So I decided to tract the event from FIRE, to DELETE_CRITTER to SPAWN_LOOT. Nothing. Until a lucky debug next line in my LEVEL_EVENT switch loop failed to leave the switch loop and just fell to the next event.
And what do you know. It was SPAWN_GRENADE event.
And then there the the curious case of sticky walls.
In a perfect world, critters will always turn to opposite direction when they encounter collision object. These object are all defined in the level editor. In Critter's case it's tiled.
In here we can see, emitters, obstacles, walking surface and the source of my pain for an hour: Collision Objects. At this point only the right emitter was spawning little menaces that had the LEFT direction. But something was wrong and instead of critters changing direction they would get stuck on the collision object.
After checking and rechecking the code and even moving emitter to the obstacle (Green Object) and rechecking it there (all works as it should). I was completely out of options. Collision works and the CHANGE_DIRECTION event is fired, and the critters all ran a ChangeDirection() function. But nothing was happening.
It was mind bending.
So it was finally time for the trusty old measure of last resort. Start deleting stuff an-masse and see what sticks.
First on the list is of course the offending collision object. And there it was. Hidden behind the object was his evil trolling twin brother.
So you can probably deduce what actually happened. Critter would encounter the collision object, change direction and then immediately change direction again and again and again. Making it virtually stuck in place.
I actually know how this happened. In Tiled you Pan and move the View by using the middle mouse button. But in Critters, you do that by using the right mouse button. I sometimes mistakenly use one on the other with not much thought. But when you do it in Tiled you open a Context menu with the first option being:
Duplicate Object.
If you're interested in Critters or find this blog moderately interesting,
You can follow me on Twitter for news and updates
https://twitter.com/CrittersDev
In the early Critters development, back in the dawn of time (few weeks ago). I implemented a Toolbar HUD element with a few Critters-Murder tools I wanted to test and play around with, with one of them being a grenade type weapon that player can drop on the little bastards. After timer is complete, the bomb grenade explodes with the satisfying destruction inside its radius.
Critters die and spawn gems and ammo. Player collects loot and continues the destruction.
All in all, often used but a proven little concept of blowing stuff up. Until loot pickup started spawning their own grenades - that is. Now, I'm the first one in line for more Critter destruction, but we can't just have anarchy grenades running around. It would inhibit us in Critter destruction in the future.
Anarchy bombs spawning |
It was some weird shit. Loot didn't even come close to bombs being spawned. So I decided to tract the event from FIRE, to DELETE_CRITTER to SPAWN_LOOT. Nothing. Until a lucky debug next line in my LEVEL_EVENT switch loop failed to leave the switch loop and just fell to the next event.
And what do you know. It was SPAWN_GRENADE event.
Guilty party |
And then there the the curious case of sticky walls.
In a perfect world, critters will always turn to opposite direction when they encounter collision object. These object are all defined in the level editor. In Critter's case it's tiled.
Object Layer in Level Editor |
In here we can see, emitters, obstacles, walking surface and the source of my pain for an hour: Collision Objects. At this point only the right emitter was spawning little menaces that had the LEFT direction. But something was wrong and instead of critters changing direction they would get stuck on the collision object.
Stuck on collision |
After checking and rechecking the code and even moving emitter to the obstacle (Green Object) and rechecking it there (all works as it should). I was completely out of options. Collision works and the CHANGE_DIRECTION event is fired, and the critters all ran a ChangeDirection() function. But nothing was happening.
It was mind bending.
So it was finally time for the trusty old measure of last resort. Start deleting stuff an-masse and see what sticks.
First on the list is of course the offending collision object. And there it was. Hidden behind the object was his evil trolling twin brother.
Fucker |
So you can probably deduce what actually happened. Critter would encounter the collision object, change direction and then immediately change direction again and again and again. Making it virtually stuck in place.
I actually know how this happened. In Tiled you Pan and move the View by using the middle mouse button. But in Critters, you do that by using the right mouse button. I sometimes mistakenly use one on the other with not much thought. But when you do it in Tiled you open a Context menu with the first option being:
Duplicate Object.
If you're interested in Critters or find this blog moderately interesting,
You can follow me on Twitter for news and updates
https://twitter.com/CrittersDev
Comments
Post a Comment