CAGD 377 - Blog Post 2 - 9/29/2024

During this sprint, I completed the game's swipe, merge, and spawning feature. Some of these features were giving me a bit of a headache. Firstly, the swipe feature was something I had never done before, so I started at first with the new input system and tried that out to see how it worked, but I was ultimately unable to figure it out, so I ended up using the old input system. It still works great, and you can swipe the blocks, which will become zombies later on, around so that you can merge them. The hardest part about the swipe was that they could only swipe one the four-by-four grid and only move in one direction at a time, even if it detected you swiping diagonally. I had to implement a few checks on every swipe so that the blocks know when they can swipe to the next space and whether or not they can merge with the block next to them if there is any. Getting the blocks to move only in one direction at a time was a challenge at the start because I could only get them to move left and right or up and down.

The spawning, on the other hand, was a little easier because I was able to take the code; I used to spawn in the first two blocks instantly, and then I just put a book on each spawner that would say whether or not a block can spawn on there after a swipe. The check would happen after the swipe had finished. By making the spawn check happen last, I avoided a block spawning on a spot where a block was already at or moving to. Currently, the swipe is set at two blocks for each swipe, but if I need to lower that or raise it, I can do so without worrying about breaking the rest of the code. I can also easily adjust how the spewing works, so if we want to switch it to a button that the player must press, that can also be done without much change needs to be made. It is also set to spawn in the lowest two numbers in the merge sequence, but that can also be adjusted to be the lowest number instead to make it harder for the player to soft lock and lose.


By far, the most challenging part of this sprint was the merge. This was the most challenging part because, at least with the swipe, when the swiped blocks could go diagonally, it was an easy fix that I did not need help or have to look up. With the merge, however, I was running into quite a few problems. For example, the blocks would sometimes not merge but would go to the following number in the sequence. Then, when I finally fixed that, they would merge, but then the blocks would sit on the square they merged at instead of going to the furthest open square. That was the hardest thing for me to fix because I could not figure out why it was happening, but it did have the most straightforward fix as the problem was an issue in the order the checks and swipes were happening. The code was laid out: they would start moving to the next spot on the grid, then when they found out they could merge, they would, but then they would stop moving to the next spot. All I needed to do to fix it was making it so they merged after they were all done moving.

Comments