It's more then just personal preference.It is entirely down to personal preference. I never put anything into the builtin speed, hspeed, vspeed, gravity variables. I always use my own (hsp, _hsp, whatever) just so that I know that I have complete control over these without anything being affected by the inbuilt movement variables.
if (can_move) {
hsp = keyboard_check(vk_right) - keyboard_check(vk_left);
vsp = keyboard_check(vk_down) - keyboard_check(vk_up);
x += hsp;
y += vsp;
}
Yes I understood your example perfectly, and I hadnt seen this way of doing keyboard check before, very interesting!You wouldn't reference hspeed and vspeed, and most likely wouldn't use hspeed and vspeed at all. You'd apply changes to the x and y values directly from hsp and vsp. For example, in the step event:
In my example, hsp and vsp aren't speeds so much as directions (which could be multiplied by a movement speed variable if you like), but hopefully it makes sense what I did. hspeed and vspeed are basically doing this behind the scenes in the step event, but like others have said, not letting you control the specifics of when and how it happens.Code:if (can_move) { hsp = keyboard_check(vk_right) - keyboard_check(vk_left); vsp = keyboard_check(vk_down) - keyboard_check(vk_up); x += hsp; y += vsp; }
What do you say about the gravity variable? Should I do something similar to your previous answer, likeYou wouldn't reference hspeed and vspeed, and most likely wouldn't use hspeed and vspeed at all. You'd apply changes to the x and y values directly from hsp and vsp. For example, in the step event:
In my example, hsp and vsp aren't speeds so much as directions (which could be multiplied by a movement speed variable if you like), but hopefully it makes sense what I did. hspeed and vspeed are basically doing this behind the scenes in the step event, but like others have said, not letting you control the specifics of when and how it happens.Code:if (can_move) { hsp = keyboard_check(vk_right) - keyboard_check(vk_left); vsp = keyboard_check(vk_down) - keyboard_check(vk_up); x += hsp; y += vsp; }
Basically, yes and for the same reasons. There's nothing inherently wrong with using the built-in movement variables if they're meeting your needs, but many users find that they become more of a hindrance than a help for projects of any real complexity.What do you say about the gravity variable? Should I do something similar to your previous answer, like
grav=4; // in the create event
y+=grav;// in the step event
instead of working directly with the gravity variable?
Gravity doesn't work that way. You add it to vspeed, not y. I mean, you could do it that way, but that will not give you the results you want.What do you say about the gravity variable? Should I do something similar to your previous answer, like
grav=4; // in the create event
y+=grav;// in the step event
instead of working directly with the gravity variable?