Friday, June 30, 2017

TOE week 44: Parallax Distractions



Wednesdays are typically my free days and for whatever reason it was really hard to work that day. I got sick this week. Who gets sick in the summer? Me apparently. That wasn’t the only thing distracting me either. Cool person I know bought me a game off of steam cause it is currently the hid your wallets summer sale.

 So I spent a fair amount of time trying to get a small group of colonists to build a spaceship to escape the Rimworld that they all live on. It is like playing The Sims except you’re stranded on an alien world. Usually I am pretty good about working during the day and playing in the evenings but something about Rimworld made me want to constantly play. 

I also got legitimately distracted by a great TV show that NO ONE watched. (Myself included) Braindead a show about government gridlock and tiny insects from outer space that take over human bodies by eating the host’s brain. Sounds ridiculous on paper but is a fantastic show. Most shows can be described by mentioning another show. “It is like Lost but with fairytale characters.” = Once Upon a Time. I was at a loss for a show that Braindead is like. 

The thing is even with all of these wonderful distractions I was still able to get a fair amount of work in this week. I coded parallax scrolling for my background objects. I also was able to paint two mountains for my parallax scrolling code. 



The closer brown mountains scroll faster than the larger grey mountain. This is a super old trick from NES days used to create the illusion of depth. The more parallax layers you make the more depthy the illusion can feel. 



I had a really happy accident while painting the foreground mountains. I was using the filter difference clouds to add some texture to the mountains when I accidentally difference clouded the entire mountain layer. Suddenly it looked really good. The thing is that I couldn’t replicate the process even in the original file. As I understand how difference clouds works is that it takes the two colors in the color pallet and applies them more or less based on how close the colors in the image are too the two selected colors. If you have a flat color this just results in a wavy cloud like structure on the canvas. If however your apply it to some mountains you made the results can be unexpected. 
 
I can’t really say I was at my best this week. Fighting a cold, fighting to survive the climate of an alien world and fighting to not just binge watch ALL of my new favorite show. The happy accidents and the work I put in may not exceed my guilty pleasures, but I think they are at the very least equal to them.

Friday, June 23, 2017

TOE week 43: Can't sleep until it works



Have you ever made a UI before? Yeah me neither. I had made a basic UI HUD that displayed all of my player meters with just text. It worked but was not pretty.

I started work with the thing I thought would be the easiest. I made the artwork for the can teleport. Then if the ‘can teleport’ flag was true an object appeared and when the flag was false this object disappeared. The effect was basically a light turning on and off. Simple enough. For the player Ammo Counter I just had to change the font for the amount of Ammo then position it over the Ammo Counter. Also pretty simple. Then I had to set up the Player’s life meter… 

My life meter is basically the life meter from Zelda but one heart is equal to one heart (in Zelda one equals four). I didn’t exactly know where to start so I went to YouTube and found a tutorial from a guy that I had seen some videos from before. I watched his video that was in Unity 4 and some of the things he was doing have been deprecated in Unity 5. So I opened a different tutorial and watched basically 80 percent of it and figured out that the way he was doing it was basically crazy. Damn. Opened another tutorial from a thirteen year old watched two minutes closed it and said ‘if you want something done do it yourself!’ 

I learned some things for both of the first two tutorials. I kept those things. I spent like all of Wednesday working on this Life Meter. It now works but it is the most convoluted Life Meter in code by far. Here is how it works. 

Deleted all heart containers
Draw all heart containers
Deleted all hearts
Draw all hearts

You can’t see this happening because it happens at a speed of one thirtieth of a second. I was super tired when I finished this on Wednesday but I had one more thing to do for the UI. That was display the current secondary weapon. I made four symbols to represent a secondary weapon and the text system worked pretty well so I copied that object then edited the code. (HUGE MISTAKE FOR MY SANITY, but too tired to realize that.) 

I deleted all of the text objects because this thing didn’t need them. Hooked up the images to display on a case system.  If case 1 display this case 2 display this and so on. Run it worked great YES UI done! Then looked at my console log. Null reference line 29. What?

I looked at line 29. It was fine. The UI object was hooked up in Unity. I comment out all of the code in the case 1. Run the game. Null reference line 37. What the?!

Repeat this process until all of the functionality of the code is gone and then the Null reference is gone. What the hell?! 

I uncommented all of my code I restarted Unity because I thought it was a Unity bug. Nope still a Null reference. There is no Null reference! NONE! This shouldn’t be happening!

I should go to bed I thought. The game works you just have something stupid happening. I went to bed. I couldn’t sleep. I just kept thinking about this stupid thing that should work! I got out of bed. I turned my laptop back on and stared at it for about five minutes and found the problem. The duplicate object, the original object that just displayed the text it had four image references that were empty, as in the opposite of full. These image references were supposed to be full! Anyone care to explain?

Yeah I deleted that object as it was no longer needed anyway. Problem solved. Then I could go to bed and sleep soundly. 



Friday, June 16, 2017

TOE week 42: Handing Over Control



Crushing bugs! Bugs in the system and Game Development go hand in hand. You make something and test it and think ‘yep it works perfectly with no problems!’ Then you go on your way. Then you hand the game over to someone else and they break it. Or more correctly they show you that it in fact does not work perfectly. 

So my brother in law dropped by for a surprise visit almost immediately after my last post on Saturday. I was basically quickly typing up the blog right before he got here. So I hand him the controller and have him jump around in my game world and the Player’s head fell off. My player is basically a square that is the feet and a square that is the head. This was something that I had already fixed, weeks ago when a different friend was over playing the game. Clearly or so I thought. He passed me the controller and I restarted the game and played it myself for a second and sure enough the Player’s head again fell off. 

Then I tried to have him go over to one of my Teleport gates and open the portal to show off my cool Teleport FXs. And that didn’t work either. I was bummed that these things always seemed to happen when I was trying to show off the game. My brother in law thought the game was cool regardless of the bugs he was finding. 

Commonalties are the best way to isolate any bug. So the next morning I got up and thought about the commonalties of all of these play sessions. All people who are not me playing. Not really the most telling commonality but, it is true that a maker of a game will often play it in a way as not to break it. Then the real commonality burst into view. The controller. I usually play the game on the keyboard as it is faster than having to turn the controller on every time I need to test something. Alright need to test this hypothesis because science! And yep these bugs only occurred with use of the controller. 

Then came the hard part, the WHY of it. I mean the code for the controller is the same code statements as the keyboard. There is an if statement with an or for keyboard input or controller inputs. The same exact code! It didn’t work because I was syntaxing it all wrong!
Basically my code looked like this:

If( some set of requirements &&* input keyboard command ||** input controller command)

*&& means AND in code
**|| means OR in code

{
Do a thing;
}

If you know how to code you probably already know how I screwed up. To sum up though for those that don’t.

The || or statement above for the controller HAS no set of requirements. So if you’re playing with the controller it allows those requirements to be bypassed entirely. Bypassing requirements can result in your head being separated from your body in another dimension. The code needed to be written like this: 

If( some set of requirements && input keyboard command || some set of requirements &&  input controller command)

{
Do a thing;
}

The thing is that I should already know this. As I learned it in C++ class but choose to write the code the way I think the syntax should work as opposed to how it actually works. Well the correct way to do it is now reinforced. We shall see how long until I mess it up again. 

This week I made another parallax background element. 


And started work on the Graphics UI. Below is the life and can teleport UI elements. 


 

And that was the long and short of this week.

Saturday, June 10, 2017

TOE week 41: 52 = 41



So this week last year was the first ever TOE update. Week 41 that means I have missed 11 weeks of work on this thing. Some of that was dedicated to working on my Ninja game. Others were spent hiding under a rock because fighting with UVs was really aggravating. Some others were spent doing I’m not even sure what. It has been a whole year! The whole thing snuck up on me and I didn’t even know it. The only reason I am mentioning it is because Facebook memories brought it up. I was going to mention it when I got to week 52. Turns out I had been skipping weeks!



College Professor: You’re first design is never the best one.
College Me: LIES my first design WALKS ON WATER!
Me Now: This one is great. Oh and this one is great too. Then there is this one how can I choose!

I redrew the power plant for the future tower for about the eleventh time. I now have three different designs that I really like. So I have to choose one but that is difficult when I like them all. 

Speaking of redrawing this week I redrew and colored the Ziggurat again. It is going to be a parallax background element. Next week I’m working on the Factory in the future. I really only had two days to work this week. Again not as much as I wanted got done. Also not a lot to say about it either, I drew things and then I colored them.


Saturday, June 3, 2017

TOE week 40: Wasn't Train Enough



I finished the metal set two weeks later than I thought! Yay! The fact that it is done is the important part. Now I need to make two new backgrounds and some parallax scrolling objects. Still more arting to do! 


Last night I was digging through some old files of mine and I found a background that I drew in 2012. I had been thinking from time to time that I needed to open this file and finish it so I could put it in this game. When I opened it the artwork was much less good than I remembered… So I guess I’m improving!

In programming news I tried to fix something and may have wound up breaking something else or it was just always broken. My player’s duck height spawns the attack collision at the wrong height. It is too low. But my code was old before I knew better and changing it broke ducking altogether… Learning is great! But if I went back and recoded everything as I learned then nothing would ever get done because I would spend all of my time doing that. So I made a better ducking functionality and then found out that if you stop ducking while attacking the player character gets stuck at the end of the duck animation. It was probably always the case as I reverted to the old code and found this still occurred but I don’t remember ever seeing this. More than likely my animation system in Unity is a little wacky. 

Outside of the computer I was drawing this week. I have a villain who is the ‘train boss’. Not the boss of a train but an actual train. I am actually pretty happy with my sketch of this character but the head wasn’t train enough for me but I didn’t really know what to do so it was just left as is. At some point this week I saw in my mind’s eye what this robot face needed to become. Then I drew it on paper. 

Today I bought two new sketch books. One for figure drawing and one for this project. There is a lot of art needed so for the for seeable future it seems that I’m going to be drawing and scanning, drawing and scanning. Then painting it with Photoshop. Time to git gud!