Thursday, July 25, 2013

Fresh Air Is Knowledge

I came across a problem in my work today that had me very frustrated. In the card game I am programming, there were cards placed out on the screen and when you put the cursor over them, it would display the card’s information on a text field next to it. The problem was it was only showing the information for the last card in the loop. I was checking it by looping through every card and checking collisions with an if/else statement (Rectangle intersection collisions). So, I double checked and triple checked and quadruple checked my rectangles and collisions. Everything was fine! Why wasn’t it working!?

I figured it was too much for me right now, so I went outside. I just sat down on the porch and sipped some ice cold water, watching the cars pass by. I kept thinking of what the problem might have been. What else could I do to debug this? XNAFramework debugging is so difficult sometimes because you deal with objects that you just can’t output to the console and update/draw loops that execute 30 times a second. Even the console output is erased as soon as you stop debug mode (with Visual Studios).

After a while of being outside, I walked back inside, this time with confidence. I sat down and just walked through my code, specifically the loop, by simply looking at it. I couple sense a logic error somewhere. There! All the cards before the last would not display the contents because the loop wouldn’t end until the last card! If the mouse was over the first card, it would show the stats for a split second and then end with the stats of the last card which was nothing because the mouse was not on it.

So, in conclusion, I cannot have these collision checks in loops. If you are ever stuck and can’t focus, just go for a walk. Take the opportunity to go outside and enjoy not having to worry about the problem. When you come back, it’ll all work out for you. Also, plan for this to happen - don’t plan to program for 8 hours straight. Figure you’ll program for two hours and probably get stuck. Go for a 30 minute walk every 2 hours. That’s about an hour and a half to two hours of breathing time. Take it and use it sparingly. With this tool on your belt, you will be able to solve any problem you come across.

Wednesday, June 19, 2013

Readers and Writers are Amazing!

Today I built a character file reader as part of my card C#(XNA) card game engine. I learned the importance and usefulness for reader and writer classes. They are my favorite!

Summary:
Each character in my card game has a deck of cards and each deck of cards has a list of cards. To do this, I started by creating a file reader object that read in text from a text file and a text parser which broke up a string into variables wherever it saw the ‘#’ symbol. Then I created three reader classes; one for characters, one for decks, and one for cards. The reader classes used the file reader and text parser to pull in data from a text file and create an object with it. For example: the card reader created a full card object from the data in a text file. After I had a way to create the objects, I made three writers classes, one for characters, one for decks, one for cards, and used them to fill a list of objects.

So, in the end, I have a card writer fill a list of every card in the game, a deck writer fill a list of every deck in the game, and a character writer fill a list of every character in the game.

Why is this method amazing?

This method is amazing because it’s safe and efficient. Every variable is protected and accessible with getters, some with setters. Each object is a utility that can be used on its own (does not rely on the other classes, independent). All your data is in text files and even non-programmers can edit them and change them and create them! Adding content to the game now is as simple as mass-producing text files and some graphics.


Comment about a time when you worked hard to build a tool that made content creation a breeze!

Thursday, June 6, 2013

Flash Is Fast Like Flash

Making some great progress on the Tip The Cows game when I realize why I chose Adobe Flash Professional as my engine of choice.

I'm currently added some achievements and upgrades to the screens and it is going very quickly. All I'm doing is organizing a bunch of buttons on a MovieClip and setting the MovieClip as the source of a ScrollPane. Now you can scroll through all the achievement buttons and click on them! I figured this would be a lot more difficult, but this is why Flash Professional is here. It is made for projects like this. I am so grateful for it because of that.

Perhaps, on a bigger project with a team, we would have our own scroll functionality classes and button-type class to inherit the achievement buttons from, but I just don't have the time for that as a single developer.

I figured these two screens would take a couple days each, but it looks like they will both be finished before today is over! The next part is the hardest, of course; all the achievements owned, data for achievement progress, and upgrades owned must be stored in the database.

Comment any stories where the power of Flash Professional or any other engine greatly surprised you and sped up the development process (the biggest stress reliever on a project).

Thursday, May 30, 2013

Road Block!

So, I've completed all the documentation and refracted all my code and set up a pretty development environment. My next step was to figure out how to show friends playing Tip The Cows and allow players to invite more. It took about five minutes to figure out how to invite friends, but displaying the friends who have played is taking forever. Can't seem to find any information about it. I'm sure you all understand that frustration. You've seen it done, you know it's possible, but you can't find anything that explains how to go about it!

First thing I need to do is find out how to fill an object in Javascript with a list of user ID's that are friends with the user and have played the game. Then I have to go and get the profile picture for each user ID. Then I have to send all of the data to flash. I have no idea how I'm going to send the pictures and get them into graphics. Then I have to go and grab all the personal high scores from the database by searching each user ID and get the user's name. Then I have to format it all nice and pretty in a window on the side of the menu.

Lots of work, but I'm hoping I can break it down step by step and get it accomplished.

Comment your similar stories below and how you overcame the challenge.

Monday, May 27, 2013

Ready to Start Programming? Wrong. Design Document Time.

Well, time to get busy on the commercial copy of the Tip The Cows Design Document. There's a lot of thing to be written and a lot of planning to be done. All I want to do is get right to work, but the key to success here is to have a plan of attack. Can't wait to get started! I know this is going to get big.