Caio
Member
I'm a beginner to intermediate in the programming language part, and in GML, and I'm always trying different ways to program something.
I've watched different tutorials, and most use the variable "vspeed" for the "Y" in the gravity and jump part.
I tried to program using the same "Y" instead of a variable.
But the result was different at the time of the jump. I did not understand why.
As I am still learning the GML and programming language. I try to program the easiest way to understand first, then leave in the most advanced way.
I would like to know the reason for this difference:
Using a variable for "Y":
-Create Event:
-Step Event:
Using the "Y" without Variable:
-Create event:
Step Event:
Sorry my english I'm using google translate
I've watched different tutorials, and most use the variable "vspeed" for the "Y" in the gravity and jump part.
I tried to program using the same "Y" instead of a variable.
But the result was different at the time of the jump. I did not understand why.
As I am still learning the GML and programming language. I try to program the easiest way to understand first, then leave in the most advanced way.
I would like to know the reason for this difference:
Using a variable for "Y":
-Create Event:
Code:
image_speed = 0.5;
grav = 1;
vspd = 0;
-Step Event:
Code:
if not place_meeting(x ,y+1, obj_solid)
{
vspd += grav;
}
else
{
if keyboard_check_pressed(vk_space)
{
vspd = -16;
}
}
if place_meeting(x, y+ vspd, obj_solid)
{
vspd = 0;
}
y += vspd;
-Create event:
Code:
image_speed = 0.5;
grav = 1;
Code:
if not place_meeting(x, y+1, obj_solid)
{
y += grav;
}
else
{
if keyboard_check_pressed(vk_space)
{
y += -16;
}
}
if place_meeting(x, y+ 1, obj_solid)
{
y += 0;
}