Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[GML] Side scroller movement


Jumbofile
 Share

Recommended Posts

This is an easy tutorial

Go to or make you player object.

make the player object be visible and the depth -5

make a left facing and right facing sprite and set the right sprite as default

add a step event: add an execute code action and insert this code

```

if (place_free(x+0,y+1))

gravity_direction=270;

gravity=0.5;

else

gravity_direction=270;

gravity=0;

if (vspeed>12)

vspeed=12;

```

add a key press event for the key up: add an execute code action and insert this code

```

{

if !(place_free(x+0,y+1))

vspeed=-10;

}

```
Now jumping should work

Make a left walking animation for your character.

Add a key press event for the key left: add an execute code action and insert this code

```

hspeed=-4;

sprite_index= name of sprite for left walk;

image_index=0;

image_speed=1;

```

Make a right walking animations for your character

Add a key press event for the key right: add an execute code action and insert this code

```

hspeed=4;

sprite_index= name of sprite for right walk;

image_index=0;

image_speed=1;

```

Make a key release for left key: add an execute code action and insert this code

```

hspeed=0;

sprite_index= name of sprite facing left

image_index=0;

image_speed=1;

```

Make a key release for right key: add an execute code action and insert this code

```

hspeed=0;

sprite_index= name of sprite facing right

image_index=0;

image_speed=1;

```

You now have to add make a platform so the dont fall out of the screen

Make a sprite 32x32 or 16x16 and fill the square a solid color

make an object called platform and put the default sprite as the sprite you just made.

Add a collision event: add an execute code action and insert this code

```

move_contact_solid(direction,12);

vspeed=0;

```

Paste your platform and you character in a room and you have a walking side scroll character!
Link to comment
Share on other sites

> GM's syntax sucks.

Syntax is fine, basically the same c++

Try to walk up a slope, there you will find the many many flaws of game maker. Also it ignores way to many errors. That sounds great. except them telling you something wrong is better then just having things go wrong.
Link to comment
Share on other sites

> Syntax is fine, basically the same c++
>
> Try to walk up a slope, there you will find the many many flaws of game maker. Also it ignores way to many errors. That sounds great. except them telling you something wrong is better then just having things go wrong.

lol Going up a slope isn't that hard, it's just a few lines of code and you got a perfect slope system
Link to comment
Share on other sites

> Syntax is fine, basically the same c++
>
> Try to walk up a slope, there you will find the many many flaws of game maker. Also it ignores way to many errors. That sounds great. except them telling you something wrong is better then just having things go wrong.

It doesn't have brackets, something that helps the code to look pretty and organized.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...