Sunday, 24 June 2012

Post 1 - Object creation

I will illustrate this first section of the post step by step for you to get a basic understanding of where to click, where that leads, what this button does etc. After this section my explanations will be less illustrated.

Let's start off by creating a tile. Tiles are blocks of which your level exists.

CREATING A SPRITE
If you open Game Maker you will be presented with a list of folders on the left side of the screen. The top folder is the Sprites folder. Right click this folder and select Create Sprite.


You are now presented with the Sprite Properties screen. First lets give the sprite an appropriate name. In the top left of the Sprite Properties screen you can change the name of your sprite. I call mine 'spr_tile'. All my sprite names will start with 'spr' for the sake of consistency and easy reference. 

Next we'll draw the sprite. We do this by clicking Edit Sprite. This opens the Sprite Editor. Once in the sprite editor click the empty page icon Create A New Sprite




You will be prompted to fill in the height and the width of the new sprite. As we are making a tile it is generally good to keep to a square. In my case my tile will be 16 by 16, but any size will suffice, as long as width and height are the same. When you click OK Image 0 will be added to the Sprite Editor. Double click Image 0 to start drawing your sprite in the Image Editor.



When the Image Editor is opens it might look like there is nothing to edit. Just scroll your mouse wheel forward and you will see the editable sprite enlarge. Once it is large enough for your taste, grab the Fill An Area tool (looks like a paint bucket) and give your tile a color by clicking on the empty sprite with it. Afterwards click the green check button in the upper left corner of the Image Editor to accept your changes. Click the green check button in the upper left corner of the Sprite Editor as well. 


CREATING AN OBJECT
So now you have a sprite. To be able to use this sprite as an object in the game we must first create an object and assign the sprite to it. To do this right click on the Objects folder in the list of folders at the left of the screen. Select Create Object. This will open Object Properties. We will make this object our tile object, so lets give it an appropriate name again. I've called mine 'obj_tile'. Just like how I start all my sprites names with 'spr' I'll start all my object names with 'obj'.

Now you must assign the correct sprite to this object by clicking on the box that says <no sprite> and selecting 'spr_tile'. Afterwards check the Solid box and click OK. You have now created a tile object. Next let's build a level out of this tile.

CREATING A ROOM
In the list of folders on the left side of the screen, right click on Rooms and select Create Room. This will open the Room Properties window, Game Maker's level editor. In the left column you'll see the following tabs: Objects, Settings, Tiles, Backgrounds and Views. In the settings tab you can change the name and size of the room if you desire.

Click the Objects tab and click on the empty space below it and select 'obj_tile'. With this object selected you can now build a little level by clicking on the grid on the right. Keeping shift down while clicking will allow you to easily draw with the selected object.

ASSIGNMENT: CREATE TWO CHARACTER SPRITES
Now create 3 new objects, one for player 1, one for player 2 and one for the enemy, following the steps above. The width of these sprites should be the same as that of the tile, the height should be twice as much. So in my case that would be 16x32. Don't forget about name consistency. Also: the objects must not be solid. When the objects are created, place them in the room you have created.

Take a look at how I did it (including assignment answers) here.

Introduction

Hello and welcome,

Over the next few weeks I'll be trying to duplicate the main mechanics of my final exam project (designed but not programmed by me) in Game Maker. I do this in an effort to teach myself simple programming and get acquainted with the many features of Game Maker.

On this blog you can follow my efforts and findings. If you as new to programming or Game Maker as I am, you will be able to learn along with me by following my steps.

The game I will be reproducing is a two-player offline co-op 2D sneaking game played with Xbox360 controllers.

When we are done we ill have:
  • 2 players with movement, jumping and ducking.
  • A tile with which we can create levels.
  • Patrolling enemies with sightcones which kill on collision.
  • A hiding mechanic for the players.
  • Collectibles and scores.
Good luck!