sLuke
0
-1
0
0
<undefined>
<undefined>
1
603
7
0
0
-1
2
self
0
0
1
///Initialize variables
//For movement
moving = 0;
//For running the animation
image_speed = 0;
imageSpeed = 0;
imageIndex = 0;
dir = 0;
//Other things
name = "";
1
603
7
0
0
-1
2
self
0
0
1
///Grid based movement with arrow keys
//Count down the timer before player can move again
if(moving) {
moving--;
imageSpeed = 4/8; //Run the animation
}
if(!moving) {
//Set the hspeed/vspeed to arrow keys. Replace with ord('w'), etc. for wasd controls
hspeed = (keyboard_check(vk_right) - keyboard_check(vk_left)) * 4;
vspeed = (keyboard_check(vk_down) - keyboard_check(vk_up)) * 4;
//If moving, prevent the player from changing direction
if(hspeed != 0 || vspeed != 0) {
moving = 32 / 4;
} else {
//Otherwise stop the animation
imageSpeed = 0;
}
}
//Use this method of running the animation to limit the frames to just one direction
imageIndex = (imageIndex + imageSpeed) % (image_number / 4); //imageIndex is the frame
if(vspeed > 0) { //Dir holds the directions
dir = 0;
} else if(vspeed < 0) {
dir = 9;
} else if(hspeed > 0) {
dir = 6;
} else if(hspeed < 0) {
dir = 3;
} else if(imageSpeed == 0) {
//If not moving, choose the standing pose
imageIndex = 1;
}
//Add them together for the correct animation
image_index = imageIndex + dir;
1
603
7
0
0
-1
2
self
0
0
1
///Talk to people
if(instance_exists(_NPC)) {
inst = instance_nearest(x, y, _NPC);
if(distance_to_object(inst) < 32) { //If in a space next to an NPC
//Show their messages
//Note that this is just one way to do it, and there are certainly other ways it could be done better.
with(inst) {
if(array_length_2d(message, 0) < 5) {
//Manually if the dialog is entered manually
var i;
for(i = firstMessage; i < messageCount + firstMessage; i++) {
dialog_msg(message[i, 0], message[i, 1], message[i, 2], message[i, 3]);
}
} else {
//From array if there is a fifth element
dialog_from_array(firstMessage, firstMessage + messageCount - 1);
}
if(firstMessage + messageCount < array_height_2d(message)) {
firstMessage += messageCount;
}
}
}
}
0
0
0
0.5
0.100000001490116
0
0.100000001490116
0.100000001490116
0.200000002980232
-1
0
0,0
16,16