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.
No comments:
Post a Comment