K
khaledzaw
Guest
Here is the code:
Create:
hsp = 0;
vsp = 0;
grv = 0;
walksp = 10;
Step:
key_left = keyboard_check(vk_left) || keyboard_check(ord("A"));
key_right = keyboard_check(vk_right) || keyboard_check(ord("D"));
//Calculate Movement
var move = key_right - key_left;
hsp = move * walksp;
vsp = vsp + grv;
//
if (place_meeting(x,y+vsp,Ground0))
{
while (!place_meeting(x,y+sign(vsp),Ground0))
{
y = y + sign(vsp);
}
vsp = 0;
}
y = y + vsp;
//Horizental Collision
x = x + hsp;
//Animation
image_speed = 1;
if (hsp == 0)
{
sprite_index = ZawS;
}
else
{
sprite_index = ZawW;
}
The Difference between the two positions showed in the .png attached to the thread is just one click.
Create:
hsp = 0;
vsp = 0;
grv = 0;
walksp = 10;
Step:
key_left = keyboard_check(vk_left) || keyboard_check(ord("A"));
key_right = keyboard_check(vk_right) || keyboard_check(ord("D"));
//Calculate Movement
var move = key_right - key_left;
hsp = move * walksp;
vsp = vsp + grv;
//
if (place_meeting(x,y+vsp,Ground0))
{
while (!place_meeting(x,y+sign(vsp),Ground0))
{
y = y + sign(vsp);
}
vsp = 0;
}
y = y + vsp;
//Horizental Collision
x = x + hsp;
//Animation
image_speed = 1;
if (hsp == 0)
{
sprite_index = ZawS;
}
else
{
sprite_index = ZawW;
}
The Difference between the two positions showed in the .png attached to the thread is just one click.
Attachments
-
98.2 KB Views: 3