I'm Coding a Game!!!

Through history there has been many great game makers. To name a few:

There was this guy...

Shigeru Miyamoto - Creator of Donky Kong

And this guy...

Sid Meier - Creator of the Civilization series

...and now there is ME!!!

I'm the one on your left, in case there was any confusion. RIP Captain Whiskers!

After the 30 day CBC ended I had no idea what I was going to blog about, and then it came to me. I've been wanting to code a game for awhile now, and I thought it would be fun to document the process.

I bought Game Maker Studio version 1.4 almost 3 years ago, and totally forgot that I had it. When I got this idea to see if I could code a game, I scoured the internet to see what was a easy/cheap programming language to make games and my search lead me to Yo-yo games which are the makers of Game Maker Studio. Seeing as I had already purchased the software, I just downloaded the program, and I've been toying around all morning. I found a great tutorial series on the internet by
Shaun Spalding. If you're new to GameMaker Studio and want to dive right in, watch this guys videos.

What Did I Program Today?

Today I just wanted to get familiar with the program and see if I could make anything work. Blogging about what I learned helps me remember it. I created two sprites, and created their object counterparts. A sprite is an entity in the game, and the object is the action of that entity. Try to think of the sprite as the noun, and the object as the verb. The two sprites I created were the action figure:

Here's a close up of the main character:

and the Wall/Floor:

You're thinking, "Man he can play music, write, and DRAW TOO?"

Next I wrote code to assign to these sprites, in their objects. I created two objects and assigned them to the Splayer sprite. The two objects created were create, and step. Create code is applied on startup of the game, and step is created each and every frame in the game.

Did you get all that?

This was the create object window. Here I assigned 4 variables to the splayer sprite. This means when the game starts the character has these attributes assigned to it.

The variables I assigned to it were:

hspeed = horizontal speed

vsp = vertical speed

grv = gravity

walksp = walk speed

That wasn't too bad... then came the step object window. That's where the main code for the game takes place:

I'll try to break it down the best I can, cause this is still making my head spin.

//Input Assignment

This takes information from your keyboard. It tells the program, “Every frame that passes, check to see it the play is pushing down on any three of these buttons.”

//Calculate movement

This code calculates the movement. Var is a function built into Gamemaker studio that says this is a variable only lasts for one frame of the game. The main line is very clever in it's logic:

Var move = key_right – key_left;

So let's break this down because this code is pretty important. Every time the left arrow or the right arrow is pushed, the code gives that variable a “1” and if it's not pushed it gives it a “0”. It's binary code.

If we push the right arrow key we get:

1 = 1 – 0

If we push the left arrow we get:

-1 = 0 – -1

and if we push nothing we get:

0 = 0 – 0

It's really clever in it's simplicity.


//Vertical Collision

//Horizontal Collision

I'm still staring at these codes trying to make sense of them. GIVE ME A BREAK, I'VE BEEN DOING THIS FOR A DAY!!!

Continue reading with a Coil membership.