Site menu
Login form
Who's Online?

Total online: 1
Guests: 1
Users: 0
Rate our Site!
Rate my site
Total of answers: 8
Sunday, 06.29.2025, 7:47 PM
Welcome Guest

File Catalog

Main » Files » My files

Perfect Platform Walking tutorial with example
[ Download from this server (15.2 Kb) ] 05.24.2013, 9:35 AM
  • Title: Perfect Platform Walking tutorial with example
  • Description: Perfect Platform Walking Code easy to understand with explanation.
  • GM Version: GM8.1
  • Registered: Yes
  • File Type: .zip and gmk.
  • File Size: 14.5Kb
  • File Link: .Click "Download Form This Server" above
  • Required Extension: none
  • Required DLL: none
  • Tags: tutorial, make, platform,help, guide,beginner,
Summary

This tutorial shows the right code for walking with animation easy to understand with explanation.

Solves the following problems : Moonwalking, the problem when you walk to a direction and then you turn reverse direction the object stops, 



Im also a beginner i tried many codes myself until i created this code.

This is the code i made.

you need to put this under step event of your player object.



// this is for the key press event 

if keyboard_check_pressed(vk_left)      // if you press the left key
{
hspeed = -2                       // you will move to the left Note: You can modify this depending on the speed you want when going left
image_speed = 0.1           // this is the animation speed of your sprite     
}
if keyboard_check_pressed(vk_right)     // if you press the right key
{
hspeed = 2                       // you will move to the right Note: You can modify this depending on the speed you want when going right
image_speed =0.1           // this is the animation speed of your sprite
}
//This is for the key release event


if keyboard_check_released(vk_right)    // if you release the right key
{
if hspeed >= 0                // this is to check if youre moving (if horizontal speed is larger than 0 )
{
hspeed = 0                    // this will make your object stop, since were using hspeed(horizontal speed) i set this to hspeed
image_index = 0           // this will set the frame number or index of your animated sprite to 0 
image_speed = 0         // this sets the animation speed of your sprite to 0 
}
}



if keyboard_check_released(vk_left)     // if you release the left key
{
if hspeed <= 0              // this is to check if youre moving (if horizontal speed is larger than 0 )
{
hspeed = 0                    // this will make your object stop, since were using hspeed(horizontal speed) i set this to hspeed
image_index = 0           // this will set the frame number or index of your animated sprite to 0 
image_speed = 0         // this sets the animation speed of your sprite to 0 
}
}





//this sets the correct sprite.


if hspeed = -2           // if you are moving (left) note : if you modify the hspeed above you also need to change this
{
sprite_index = spr_playerleft  //sets the sprite to left note: you can change this depending on your sprite's name mine is spr_playerleft 
}
if hspeed = 2           // if you are moving (right) note : if you modify the hspeed above you also need to change this
{
sprite_index = spr_playerright

//sets the sprite to right note: you can change this depending on your sprite's name mine is spr_playerright
}


Hope this helps..
thank you for your time
if you ever had questions or parts that you did not understand im willing to read comments.

//chestertagat
Category: My files | Added by: Chestew | Tags: Make, Tutorial, Guide, help, platform, beginner
Views: 894 | Downloads: 267 | Comments: 1 | Rating: 0.0/0
Total comments: 1
1 Dan  
0
I hope this helps me, thanks

Name *:
Email *:
Code *:
Section categories
My files [6]
Adfly