Toader
By Jake MeinershagenBack in the new year for game 3 of the 20 Games Challenge.
I'll be honest, I wasn't super excited about any of the options for this one. I chose frogger on a bit of a whim. That was kind of a mistake because it reduced the amount of excitement I had to push me through some of the frustrating parts. I made it through though.
This game was the first time I seriously implemented a state machine. I had some problems when doing that, but it turns out they wound up being due to something else. Overall I like the design pattern and will probably use it in the future. I think the one I created here is general enough that I can drop it in to future games when needed.
Another problem I had was with comparing Vectors in Godot. I don't know how it hadn't come up yet, but I was trying to compare if one vector was 'less than' another one. I hadn't thought about the assumptions behind what 'less than' means when you have a 2d vector so I would up with a pretty annoying to track bug. In Godot, using the < operator on a Vector2 will first compare if the first element is less than, it will only move on to the second element if the first elements are equal. I've put some examples below:
(2, 4) < (1, 20) = false
(1, 3) < (1, 5) = true
(5, 20) < (6, 6) = true
This cause me trouble because my assumption was that < would compare the magnitudes of the vectors. However, once we know that the built in operator doesn't do that, it is an easy fix. We simply use the lengths of the vectors for comparison instead.
my_vec_1.length() < my_vec_2.length()
The final cool thing I learned about for this project was the VisibleOnScreenNotifier2D node that Godot has. Obviously it is super useful in this project since I have lots of objects moving in and out of the screen. All I had to do was connect the signal for exit_screen to the script on the object and then call queue_free when the signal is emitted. Nice!
That's it for this one. Happy new year!
Jake Meinershagen
Previous TOC Next