Game Maker: Top Down Car Game (Part 1)
In this tutorial I will teach you how to make a simple top down car game, in Game Maker 8. The game will look similar to anyone who saw the early GTA games. The game will consist of a car which can be driven around a track.
For this game, you should have a basic knowledge of Game Maker Drag & Drop, and a version of Game Maker eight Pro.
If you have made a sprite yourself, make sure the car is facing right. If you have loaded a premade sprite we will need to make the car face right. To make a car face right we simply press the edit sprite button, and then press transform
(On the top bar) and select rotate. Do it so the car is facing right
If the sides of your sprite are being chopped up, you will need to re size the canvas first.
Before we leave the sprite we must click the centre button on the sprite settings, just under ‘edit’ and ‘load’ sprite. After all of this is done we press the OK button and the menu should close leaving you with your room on show (or a blank background if you closed your room)
Step 4: Creating a Object
Press the blue ball on the top bar to create a new object. Name this object car_obj and set the sprite to car_spr. To set the object a sprite, click the blue picture next to ‘sprite’ and select car_spr.
Now to make the car actually drive. Press ‘add event’ and press step, and step again
On the right hand side of the screen you should see all the things you cab do to that object. Select the ‘control tab’ and drag the code logo into the big white box (labelled ‘actions’). Before you all start screaming in fear and closing this web page, let me just tell you that coding, or GML, is really quite easy once you get the hang of it. I am going to tell you exactly what to write in the code.
We want our car to drive forwards and reverse, while being able to steer left and right. The car will be controlled with the directional arrow keys on the keyboard. Type this code into the box that opens when you drag code into the event.
if keyboard_check(vk_down) and speed<2
if speed>0 and keyboard_check(vk_left)
if speed>0 and keyboard_check(vk_right)
if keyboard_check(vk_down)and keyboard_check(vk_left)
if keyboard_check(vk_down) and keyboard_check(vk_right)
Basically what this means is that when a specific button on the keyboard is pressed, the car moves in the corresponding direction.
In the create event, be sure to set the ‘friction’ to 0.5. Otherwise your car will not stop once the key is released.
Step 5; Placing the Object
Finally open up the room again that we made all the way back at the start. You can do this by pressing the room folder on the left hand side, and double clicking your room. Click on the objects tab and select car_obj in the drop down list (it should already be selected). Click anywhere in the room to place your car.
Now press the green arrow on the top bar to test play your game
I hope it all worked correctly, but by any standards this game is a little tame. In my next tutorial I will be continuing this tutorial. I will explain how to add other object to the game which will make the game more fun to play, e.g. coins to collect and dangers to avoid
As this is my very first Game Maker Tutorial I am not sure if it is detailed enough, or indeed too detailed. If you need any more help you can email me at ‘Jeswan_500@hotmail.com’