Here:
Walking:
//If global position is equal to nothing or walking
if global.position = 0 or global.position = 1{
scr_link_sprite_index(spr_link_walking_right,spr_link_walking_up,spr_link_walking_left,spr_link_walking_down,global.direction); //Set links sprite index
//Optomize the keys for this scripts
keydown = keyboard_check(global.keydown)
keyright = keyboard_check(global.keyright)
keyleft = keyboard_check(global.keyleft)
keyup = keyboard_check(global.keyup)
//Turn off the key variables
if !keydown and !keyright and !keyleft and !keyup{
global.position = 0
image_speed = 0
image_index = 0
}
else
{
image_speed = 0.4
}
//Cancel out the keys
if keydown and keyright and keyleft and keyup{
global.position = 0
}
//Walking down
if keydown and !keyright and !keyleft and !keyup{
global.position = 1
global.direction = 270
repeat(3)
if place_free(x,y+1){
y += 1
}}
//Walking up
if keyup and !keyright and !keyleft and !keydown{
global.position = 1
global.direction = 90
repeat(3)
if place_free(x,y-1){
y -= 1
}}
//Walking left
if keyleft and !keyright and !keydown and !keyup{
global.position = 1
global.direction = 180
repeat(3)
if place_free(x-1,y){
x -= 1
}}
//Walking right
if keyright and !keydown and !keyleft and !keyup{
global.position = 1
global.direction = 0
repeat(3)
if place_free(x+1,y){
x += 1
}}
//Walking down-left
if keydown and keyleft and !keyright and !keyup{
global.position = 1
global.direction = 225
repeat(2)
if place_free(x,y+1){
y += 1
}
repeat(2)
if place_free(x-1,y){
x -= 1
}}
//Walking down-right
if keydown and keyright and !keyleft and !keyup{
global.position = 1
global.direction = 315
repeat(2)
if place_free(x,y+1){
y += 1
}
repeat(2)
if place_free(x+1,y){
x += 1
}}
//Walking up-left
if keyup and keyleft and !keyright and !keydown{
global.position = 1
global.direction = 135
repeat(2)
if place_free(x,y-1){
y -= 1
}
repeat(2)
if place_free(x-1,y){
x -= 1
}}
//Walking up-right
if keyup and keyright and !keyleft and !keydown{
global.position = 1
global.direction = 45
repeat(2)
if place_free(x,y-1){
y -= 1
}
repeat(2)
if place_free(x+1,y){
x += 1
}}}
Sprite index:
//Sets links sprite index to whatever the arguments tell it
//Technicly, this could work for anything
//That use directions to find the sprite index
//Arguments:
//Arg 0: Walking right sprite index
//Arg 1: Walking up sprite index
//Arg 2: Walking left sprite index
//Arg 3: Walking down sprite index
//Arg 4: The variable that has to equal a certain number to have that sprite index
if argument4 = 0{
sprite_index = argument0
}
if argument4 = 90{
sprite_index = argument1
}
if argument4 = 180{
sprite_index = argument2
}
if argument4 = 270{
sprite_index = argument3
}
Also:
Create event:
global.position = 0
global.direction = 0
global.resource_pack = 1
global.keydown = vk_down
global.keyright = vk_right
global.keyleft = vk_left
global.keyup = vk_up
Don't ask how efficiant it is since I ripped it streight from my old game.