Friday, 11 April 2014

GameMaker - Simple Player Movements Coding (Windows)

Coding GML is simple, but can be in such depth when you're creating a game with many sprites and objects. Obviously the first thing you need to know about coding is the player movements. Most beginners generally use the drag and drop variables to create movements, however, I find it easier to use simple coding (GML) and I'm going to share with you how I do it.

First of you'll want to open GameMaker and start a new project or open the one you want to create player movements for. Then double click on the player, from here you need to add a 'Step Event' (just a normal step event will do). Drag in from the 'Control Tab' the 'Execute Code' icon; when this has opened, type the following code:

The coding above shows you how to create left and right movements via the arrow keys on the keyboard.
Normally, when you create a game you have two separate sprites for each direction you move. So when you change from going in the right direction you need to change the sprite to look the other way. To do this, all you need to do is copy the code you've just typed and paste it in a separate line BUT at the end of this, add the following:

As you can see, I've added sprite_index = SPRITE NAME to the end of the movement code because this changes the sprite when the movement key is pressed.


Flappy Bird Sprite Design

Do you have an artistic side? Do you have an interest in Flappy Bird character design? If so, this post is for you. Flappy Bird was such a big game, it practically blew up on the App Store in minutes. It's definitely the most addictive game that I've ever played. I think, after Flappy Bird was taken down, game designers thought it was a good idea to jump on their game design program and create a Flappy Bird prototype for them or their company to go big. I'm not looking to go big, but Flappy Bird is one of the simplest platform games to create. With a small bit of code and a few designs you're set to go. 

See, I'm more of the artistic side to creating games, but I can actually code some GML (GameMaker Language). I'm currently creating a 3 level platform game as a preview as to what I can do, so be sure to check that out when it drops.
In this post I'm going to show you how I created my Flappy Bird character in the GameMaker sprite designer.

I started by downloading a picture from the internet as a reference to work from. Also, opening the program and creating a sprite.

I made an outline with the finest pencil preset, as the game is pixel based you can see the image isn't in the best detail but I still managed to get a good outline.




Next I added a white shading to give myself a reference as to where the lighter colour will be, depending on what colour I'd like my character. 

I used right click when using the pencil preset, when clicked this gives us a white colour pixel instead of a drop down menu. 


I added some colour, experimenting, trying to make it a bit different to the actual game character. I used a dark pink where I made the shading reference and a lighter pink for the rest. In the top corners I used the same pink and just turned down the opacity to 174 and lightened the corners a tad. For the mouth/beak, I used an orange colour and then changed the opacity to 180 with the same orange and filled the rest.

Download the final image (32x32px).