How to make a side scroller

How to make a Side-Scroller using Game Maker Pro
(Please SAVE your work as you go along!)

In this tutorial, you will learn how to make a simple jumping player that controls the camera, making it scroll.

Note: This tutorial uses code and if you are genuinely interested in making good games, you will have to learn some basic coding so make sure the "Advanced Mode" is checked under the "File" menu. It is not that hard and is universal so it can be used in any side scroller game.

First, you will need to make a player and block sprite. You can make the player look however you want, be creative! Just make sure for now that the dimensions are 32 x 32. As for the ground, you have to decide if your background needs a physical floor or an invisible one if the background picture has a floor in it. So for now make a player object and a floor object (Leave them empty for now.)

Next, make or load a background. This can be made yourself using the "Edit Background" button or you can load a picture that you already have. For ease, here is some good advise for side scrollers. Find or make a picture that 6400 x 480, this makes the picture technically 10 rooms long and is a decent size for a room that don't take too long to load.

Here is where the coding comes in. Now you need to make a script, the icon is a piece of paper with the green arrow on it at the top of the screen. This script sets the keys for control of the player which are left key for left, right key for right, and space for jump. Name it "script_move" (no quotations), paste this into it then click the green checkmark (because of the way this wiki displays information you have to edit the code and go to a new line ever time you see an (+) then erase the (+):

argument0 = 4 argument1 = 270 argument2 = 0.6 argument3 = 15

if (vspeed>argument3) vspeed=argument3; if (place_free(x,y+1)) { gravity_direction=argument1; gravity=argument2; } else { gravity_direction=argument1; gravity=0; } if (keyboard_check(vk_space) && not place_free(x,y+1)) motion_set(270,-10) if (keyboard_check(vk_left) && place_free(x-argument0,y)) x-=argument0 if (keyboard_check(vk_right) && place_free(x+argument0,y)) x+=argument0

Ok, now we need to link this script to the player object so it will control it. Open your player object, give it a name and set the sprite to the one you made or loaded. Next we need to make a "Step" event. Click "Add Event" and select "Step". Go to the "Control" tab and drag the "Execute Code" icon into the window. Copy and paste this into the "Execute code" window and press the green checkmark:

script_move;

While you are here, you can set the collision with the floor as well, so you don't fall off the screen. Add a "Collision" event and set it for the floor object then drag the same "Execute Code" icon into the window. Paste this in there and click the green checkmark (because of the way this wiki displays information you have to edit the code and go to a new line ever time you see an (+) then erase the (+):

move_contact_solid(direction, 15); vspeed=0;

Now your player movements and jumping are set and you won't fall through the floor into limbo!

Now onto the floor object. Here is where you have 2 options:

1: The background picture has a picture of the ground on it.

2: You need to make ground because the ground is flush with the bottom of the screen.

If your going with option one the only thing you have to do is open the floor object, set the name to floor and the sprite to your block sprite, make sure "Visible" is unchecked and "Solid" is checked, then click OK.

The only difference with option 2 is that both "Visible" and "Solid" are checked and press OK.

That is all for the floor object.

The Room:

Now it's time to create a room. The icon is a white square at the top of the page. The first thing you should do is maximize the window, this makes it much easier to do your editing. Go to the "Settings" tab and set the Width to 6400, the Height to 480, and the Speed to 30. You can also name the room here, I generally use "level_1".

Next go to the "Backgrounds" tab. You don't have to change anything here, just go to the drop-down menu right above "Tile Hor." and select your background. That is all you have to do here.

Next go to the "Objects" tab, this is where you will add all your objects. This is where you will have to put in your player and the floor. Make sure "Snap X" and "Snap Y" on the top of the window are both 32. If you went with option #2 from above for the floor, then all you have to do is add the floor objects all the way across the room on the bottom. If you went with #1, then you will make the floor across the room but just under where the floor is on the background picture. As for the player object, just make sure it is anywhere on the left of the room above the floor. If it is above the floor it will fall to it so don't worry. You are now done with this tab.

Finally, go to the "Views" tab. (If you do not see this tab then you are not in "Advanced Mode" or you need to make sure it is checked in the menu that drops down from the icon that looks like a magnifying glass.)

Here is where all the magic happens. It is simple. All you need is to set all these values:

1. Enable the use of Views: Checked

2. Visible when room starts: Checked

3. View in room: W = 640, H = 480

4. Port on screen: W = 640, H = 480

5. Object following: Drop down menu and select player object.

6. Hbor: 500

7. Vbor: 500

That is it! Now run the game and make sure the left, right and space keys work and the room scrolls when you pass the center of the room.

This tutorial is just how to make the room scroll and set your movements. There are still many things to be added such as the ability to shoot, platforms to jump on and enemies to fight.

This page will be updated with this information as it comes available so please bookmark and check back regularly. Thanks.