Big Game: Week 2

Monday: I updated all the matching squares so that they used the latest art, no longer do they look like squares so they will hereby be referred to as materials. I took some more time to figure out why the performance was so low within the cube script (material script, if you will). It turned out each of the 81 matching materials had a float that got the delta time added to them every frame. The float was just a temporary measure I had used to test something earlier, and later I moved that functionality into the board script. Removing the float and stopping the addition of delta time every frame improved the performance quite a bit.

I also added particles to each individual material, so when they got matched different materials yielded differently coloured particle effects. They just use simple coulours at the moment, but they will be updated to have custom particles for each material.

Tuesday: The headline of Tuesday was animations. I created animations for movement of the matching materials for every direction, for a successful match and unsuccessful match. The tool I used was the unity animation editor. Our lead programmer Philip helped me with it to begin with, because he has more experience with unity. 

The way I had to go about to make things animate was really quite illogical. I could not animate the sprite that the material prefab held in, instead I had to create a child to the material prefab to ensure that the starting position of the animation would be where the material was currently residing in the 2D plane. Having to create individual animations for every different swap was also a hassle. I encountered several problems on the way, most of them was because I did not know unity well enough. The animation editing part did not feel user friendly at all, the buttons for the UI were exceptionally small and didn’t do what I imagined they would.

Wednesday: The quest for animations continued as I worked towards fixing a problem that caused the animation to continue even though it should have stopped. I tested so many different things over the course of the day but I could not for the life of me figure out why it was happening. I then got help from my fellow coders and we eventually found that there was a setting for blending animations together, essentially having them play at the same time. I tried changing those parameters but it didn’t help as much as I had hoped. Turns out I just forgot to turn of the looping of off the most recent animations I had made, although I could have sworn I turned it off. 

During the evening we got some good advice from Mattias of Digital Tuna, and he told us that we had to get rid of the tags that I had utilized when coding the bejeweld clone, as it was just not efficient enough if we were gonna port the game to a mobile platform. He also hinted that the animation editing with unity was probably much more of a hassle than just moving the matching materials in code Back to the drawing board I went.

Thursday: Let the remake begin. I made a new board script copying only the most integral from the previous one and got to work. Instead of using the built in tag system I instead decided to use shorts and an enum to represent the different materials that each material object would hold in. Instead of calling the command GetComponent every frame to access the material object’s scrip I added every material script into a list where I was cloning the original material prefab. 

Then it was time to implement animations with code. Lots of headaches were had, both from Philip, who helped me and from myself along the way. The if statements were huge and the for loops just as well. Looking at your own code for too long makes you blind to the small mistakes that start to slip in when you get more and more tired. After many many hours of testing different combinations of statements and functions we managed to get decent animations through. The clock was a few minutes over two in the morning, suffices to say that we were quite tired.

Friday:  The day after the crunch. I was tired, but that didn’t stop me from bettering the board script a whole bunch. I began with formatting it a lot better, with comments and descriptions of every variable I declared. I did this because I realized that things are never as clear for someone else as they are to me. When they look at something they might not see what I see so commenting should at least help a bit on the way. Commenting in general is something I do very little of, and when I read others code I often wish there would be comments explaining why things are structured as they are. In addition to adding relevant comments to the board script I also rewrote the matching algorithms to make them more friendly toward the garbage collector. Previously I had just tried and caught when I looked inside the list list of material objects, creating lots of bug logs when going out of range from the list, giving the garbage collector a whole load of trash to collect.

I also added variables for the falling speed of the materials on the board and also the speed materials have when they swap positions. 

The last thing I did for the day was to add the match four powerup which clears a row or a column depending on how you use it. I encountered a bug with the falling function that made the game freeze, but I localized it and squashed it halfway through the mini testing session we had. 

There is still some more work to do to be back where I were before the whole remake of the board, but I feel that things will be more stable now.

 

Coin

One of the matching materials: A coin!