How it works.
Ok I double tap the directional pad and then I hold it and the character runs and the sprite changes into a running sprite.
The walking script.
Create Event
global.facing="D"
image_speed=0.5
moving=0
movestep=0
movespeed=3 // Link's walking speed, pixels per step
Step Event
// LINK MOVEMENT SCRIPT by GOODNIGHT
var fholdd, fholdu, fholdl, fholdr, cc;
// Check keys
holdd=keyboard_check(vk_down)
holdu=keyboard_check(vk_up)
holdl=keyboard_check(vk_left)
holdr=keyboard_check(vk_right)
// Cancel opposing keys
if holdu && holdd {
holdu=0
holdd=0
}
if holdl && holdr {
holdl=0
holdr=0
}
// This is where you may want to add other conditionals which keep you from [CODE]moving,
// such as if you are using an item, or you are in a menu.
// Just add the conditions to the end of this next "if" line.
// example:
// if (holdd ||holdu || holdl || holdr) && !usingshield {
if holdd ||holdu || holdl || holdr {
// Change sprites if you haven't already
if !moving {
if holdd { sprite_index=sprLinkRunD; global.facing="D" }
else if holdu { sprite_index=sprLinkRunU; global.facing="U" }
if holdl { sprite_index=sprLinkRunL; global.facing="L" }
else if holdr { sprite_index=sprLinkRunR; global.facing="R" }
}
moving=1
// Sprite correction
if (holdd && !holdl && !holdr) { sprite_index=sprLinkRunD; global.facing="D" }
else if (holdu && !holdl && !holdr) { sprite_index=sprLinkRunU; global.facing="U" }
else if (holdl && !holdd && !holdu) { sprite_index=sprLinkRunL; global.facing="L" }
else if (holdr && !holdd && !holdu) { sprite_index=sprLinkRunR; global.facing="R" }
if (holdd && holdl && sprite_index!=sprLinkRunD && sprite_index!=sprLinkRunL) { sprite_index=sprLinkRunL; global.facing="L" }
else if (holdd && holdr && sprite_index!=sprLinkRunD && sprite_index!=sprLinkRunR) { sprite_index=sprLinkRunR; global.facing="R" }
else if (holdu && holdl && sprite_index!=sprLinkRunU && sprite_index!=sprLinkRunL) { sprite_index=sprLinkRunL; global.facing="L" }
else if (holdu && holdr && sprite_index!=sprLinkRunU && sprite_index!=sprLinkRunR) { sprite_index=sprLinkRunR; global.facing="R" }
} else { moving=0 }
if moving {
// Determine the delay between movement steps
// (or how many times to move per step).
if (holdd || holdu) && (holdl || holdr) { movestep+=(movespeed/sqrt(2)) }
else { movestep+=movespeed }
// Start doing the movement.
while movestep>=1 {
movestep-=1
fholdd=0; fholdu=0; fholdl=0; fholdr=0;
// Corner-cutting loop.
// Feel free to change the initial "cc" variable for corner sensitivity.
// Between 4 and 8 is recommended, use 0 for none.
for (cc=6; cc>0; cc-=1) {
if holdu {
if !place_free(x,y-1) {
if place_free(x-cc,y-1) && !(holdr || fholdr) { fholdl=1 }
else if place_free(x+cc,y-1) && !(holdl || fholdl) { fholdr=1 }
}
} else if holdd {
if !place_free(x,y+1) {
if place_free(x-cc,y+1) && !(holdr || fholdr) { fholdl=1 }
else if place_free(x+cc,y+1) && !(holdl || fholdl) { fholdr=1 }
}
}
if holdl {
if !place_free(x-1,y) {
if place_free(x-1,y-cc) && !(holdd || fholdd) { fholdu=1 }
else if place_free(x-1,y+cc) && !(holdu || fholdu) { fholdd=1 }
}
} else if holdr {
if !place_free(x+1,y) {
if place_free(x+1,y-cc) && !(holdd || fholdd) { fholdu=1 }
else if place_free(x+1,y+cc) && !(holdu || fholdu) { fholdd=1 }
}
}
}
// End corner-cutting loop.
// Determine the movement direction, and move.
xstep=(holdr || fholdr)-(holdl || fholdl)
ystep=(holdd || fholdd)-(holdu || fholdu)
if place_free(x+xstep,y) { x+=xstep }
if place_free(x,y+ystep) { y+=ystep }
}
} else {
// Get the right sprite when you stop moving.
switch sprite_index {
case sprLinkRunD: sprite_index=sprLinkStandD; break;
case sprLinkRunU: sprite_index=sprLinkStandU; break;
case sprLinkRunL: sprite_index=sprLinkStandL; break;
case sprLinkRunR: sprite_index=sprLinkStandR; break;
}
movestep=0
}
depth=-y
// end of script
Thanks![/code]