Boobie Teeth 0.22 is now available for download at the Releases page.
I figured out how to fix the bugs with the Feeder Fish, so they’re back in the game. The problem was rather complicated, and had to do with both Game Maker’s inheritance model AND the weird way that Game Maker can change an instance of one type of object into an object of another type. When Feeder Fish feed on each other, they eventually grow large enough to change into Fish. For reasons I still don’t understand, when the built-in function instance_change() is called, it results in a weird condition with the instance’s variables no longer being accessible to the application.
In my AI targeting code, this could cause a changed instance to no longer exist insofar as the Game Maker engine was concerned, resulting in an unhandled “unknown variable” exception being thrown. To work around the problem, I had to write my own code to handle the instance_change, and so it creates a new Fish, assigns it properties equivalent to the former Feeder Fish instance that it used to be, and then destroys the original Feeder Fish.
Further complicating matters was the fact that I had initialization happening in the Create event for the Fish object, which normally gives a new fish random values for its properties. In this case, however, the Create event initialization was blowing out the Feeder Fish’s properties which I’d just assigned to the new Fish. So to fix that problem, I had to remove the call to my initialization function from the Fish object, and am now calling it from outside after the Fish instance is created. The Fish Factory uses randomized values, while a matured Feeder Fish passes its original values. This works nicely, and I am happy with the result. The game is more fun with Feeder Fish acting as an attractive food source to the full-grown AI fish in the game, so I’m glad I was able to get this in before the demo at Notacon.
I also added a function to prevent fish from getting stuck on the bottom of the sea. Now if a fish swims and hits bottom, it changes course. I have seen on occasion a fish being spawned too close to the bottom and getting stuck, and will have to fix that in a different manner. I have been trying to work some safety checks into my level_spawn function to prevent the player from being unfairly killed and prevent fish from being spawned stuck in the sea floor. So far, though, this has proved tricky. I can’t simply check for collisions, because the fish’s sprite gets scaled up immediately after it is spawned, and in the first tick of the game when the fish is newly spawned, its sprite is still normal size, so an anti-collision check could still leave it too close when it spawns. As well, I can’t merely check for collisions with the Player, because I want to ensure that the Player has enough room to swim away from a nearby threatening fish. I had some experimental code that should calculate a safe clearance distance around the player and pick coordinates outside of this safe zone to place newly-spawned fish, but when I tried running it, an odd bug arose wherein the fish count function stopped working properly — I’m guessing fish end up outside the room where they can’t be seen or eaten, but I can’t see how that’s possible given how I wrote the code that checks for this. At any rate, level transitions will be a future development goal that I will work out in more detail anyway.
The game demo level is already pretty fun to play, so if you have not yet tried the game out, now is a great time to get acquainted.
Like this:
Like Loading...