If you want a nice looking background you can create lots of objects and
build your rooms from these objects. This however takes a lot of work and
makes your game slow because of the large number of objects.
The best way to make good looking backgrounds is to use tiles. Tiles
are bits and pieces of an image that can be placed in different places on the
background. Memory usage is much less, and as tiles are not game objects
and don't have collision checking your game will run much faster.
First you need to get a suitable tile set to use. You can
download some from the resources section of the official Game Maker site
at
http://www.gamemaker.nl/resource.html
I will be using this one from the Game Maker site:

 |
Start with a new empty room Add a background and name it
bgrTiles. Load one of the tiled images you downloaded.
Click the 'Use as Tileset' option:

You then need to adjust the Tile
Properties (width, height etc) until the grid lines match those
on the image.

Add another regular background, such
as sky.gif to go behind your tiled picture.
Now go to your room, select the
tiles tab. Click on a tile, then click to place it in your
room. Build your world.
Now go to the backgrounds tab,
choose the sky background.
Untick the Draw background colour
option.
 |
| |
This causes a problem though. How does
your game know when something has collided with a object that is just part of
the background picture? The secret is to place plain wall objects wherever there
are walls (exactly the same size and in the same place as the background pictures) but make the plain
objects invisible. When you play the game you don't see the plain
invisible wall objects, you see the attractive background. |
 |
Create a new sprite sprPlatform that is just a square
block of colour the same size as your grid. Untick transparent. Create an object objPlatform and
attach the sprite to it. Untick Visible.
Place the objPlatform blocks on top of your tiled image
platforms. Don't worry that your platforms seem to be
hidden. The objPlatform blocks are invisible, so you won't
see them when you try the game, but you can collide with them.
 |
| By using tiled backgrounds, you can make a platform game with only one platform object, but it looks
like the player is walking along all sorts of different things, such as fences,
castles, grass, water etc. |
|
 |
| You can create blocks smaller than your
grid size to get more accurate positioning for your
characters when they land. Create half size blocks: a 16x8 block
and call it objPlatform_horiz and an 8x16 block called
objPlatform_vert Make the objPlatform block the parent
block for each of these. That way they will inherit the
same behaviours, so you do not need to set events for them.
Now you can place them where only half a grid square is
covered by the background. eg for the end of clouds etc.
 |
|
|