YoYo Games Wiki

How to make a side scroller

From YoYoGames Wiki

This article (or section) may need to be wikified to meet The YoYo Games Wiki quality standards.
Please help improve this article, especially its categories, and wiki-links.

This tutorial works with...

{{{1}}}


How to make a side-scroller using Game Maker

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

First, you will need to make gray square and black square sprites. The black square is the player. The gray square is the ground. You can make the player look however you want, but the ground can only be a different color.

So NOW are you ready to start? Hopefully you are! So load a background, create a room and put the background in the room. Now make an object and name it obj_player. Then make 2 more and name them objblock1 and objblock2. Now go to the obj_player window. By now you should know how to add an event. If you don't, you click on the "Add Event" button. Add a create event. Click on the "Set Friction" button in the move tab. Set the friction to 0.4. In the same move tab, click on "Set Gravity". Set the direction to 270 and set the gravity to 0.6. That sets the friction and gravity. Now create a collision event. Set the collision to objblock1. /!\ ///Do NOT edit anything in objblock1 and objblock2! They need to be left empty!/// Click on "Speed Vertical". Set it to 0. Now make another collision event and set it to objblock2. Drag in a "Move Towards" D&D. Set the x to objblock1.x, the y to objblock1.y, and the speed to 4.

Now add a Left Keyboard event. Now we don't have to do this, but we will do a bit of GML. Click on the Control tab. In the code section, click on the Execute Code D&D. Not the one with the green arrow. In the script editor, type hspeed=-4.

Now, create a Right Keyboard event. Click on Execute Code again. In the code editor, type in hspeed=4.

Now add a keyboard up event. Put in the Test Variable D&D. Set the variable to vspeed, the value to 0, and the operation to equal to. Now again, do the execute code D&D. Type in the code editor the GML code vspeed=-11. Now you have your accurate player...almost.

Now on the very left in the sprite section, set the sprite to your player sprite. Now open up objblock1 and objblock2 and make them solid. I just noticed you don't need objblock2, but I was too lazy to delete it so just delete it yourself, ok? :) Now open up that room you made.

Click on the view tab. In the view in room section, set W to 640 and H to 480. In the port on screen section, set it to 320 for W, and 240 for H. In the Object Following section, set it to your player object. Now in the same section, set the Hbor to 20 and the Vbor to 10. /!\ AGAIN, I JUST NOTICED THIS DOESN'T WORK! SORRY!!!!!!