Thursday, December 11, 2008

Slot Robber - What went right, what went wrong

Now it is time to make the famouse post that every game developer makes - the right and wrong stuff in my code.

Because this was my werry first game in SDL and the evnt handling and many thing ware new to me I made manny mistakes. So let's count them down (most of them).

1. The biggest mistake at a game.
First let me tell you how a game is made ( well the code ). As the code goes it goes through a process called event handling. That is where all the input from the keyboard and mouse are handled. Then the logic comes in, and on the end enything is rendered on the screen. So shown in a simple way it loosk like this:

while ( theGameIsRunning )
hande_events; //Here all the events are handled
do_logic; //Here the logic takes care of that what the user wanted to do by input
render_all; //Then it shows all ot the things on the screen

And this loops as long the game runs. It shows really nice that the game does all of these thing all the time, nothing of these important steps is let out.

But because my lack of experiance and knowlage I programmed my game a other way. This is how my game looked like:

while ( theGameIsRunning )
if (handle_events)
while (there_is_logic_to_do)

In my game as you can see, the game waits for a event to hand (the user clicks on a button). Then, according to the button that was pressed does all the logic (in my game that was change the slots, and adding money) and render all that while it does the logic. But because the logic parts ware long and it needed to change the slots many times - so it didn't hande event while doing it. That is why while the game is changing slots, you cannot: exit the game, move ste windows on the screen. All those events happened after the logic was done.

So that is the big mistake. I hope i won't do it in my next game because it will be fatal (it is a real timer)

2. Hmm well. There aren't many thing to put out in a game that small. Well the music is a BIG file.

Now for some good things:

1. Werry important: I completed my first game

This is good because many people don't finish a game that they start. It is good for the morale to finish it and you will be happy.

2. I learned a lot of things through the process. I searched a lot on the internet, through the documentation and found interesting things that you don't find in tutorials.

3. The game was accepted my other people even if it was totaly simple. This gave me additional boost for further work.

Well here I end my post. And i won't probably whrite anything new for this game because I whrote anything I could without beeing too much booring.

The link againg:

Now let's start on my new project. :D

No comments:

Post a Comment