Skip to content

Instantly share code, notes, and snippets.

@dyerrington
Created January 24, 2014 02:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dyerrington/8591021 to your computer and use it in GitHub Desktop.
Save dyerrington/8591021 to your computer and use it in GitHub Desktop.
Basic setup for GML top/down player control
if(keyboard_check(vk_nokey)) {
image_speed = 0;
}
if(keyboard_check(vk_left)) {
sprite_index = spr_right;
image_speed = 0.2;
image_xscale= 1;
x -= 4;
}
// Flip image (image_xscale) to save sprite animations
if(keyboard_check(vk_right)) {
sprite_index = spr_right;
image_speed = 0.2;
image_xscale= -1;
x += 4;
}
if(keyboard_check(vk_up)) {
sprite_index = spr_up;
image_speed = 0.2;
y -= 4;
}
if(keyboard_check(vk_down)) {
sprite_index = spr_down;
image_speed = 0.2;
y += 4;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment