woods
Member
so i have a weird thing going on.. my player moves just fine.. but when changing sprite to a werewolf, if i move more than 2 tiles.. he gets stuck moving in that direction. the only thing was a sprite change....
another thing i tried was copy the player and make a new object.. change the sprite to the wolfman... same issue.. when going left or right, the werewolf gets stuck moving in that direction...
sprite is 32x32 pxls
collision mask is full image
this one has me confused....
create event werewolf
step event werewolf
edit...
thought i fixed it, but nope ;o)
another thing i tried was copy the player and make a new object.. change the sprite to the wolfman... same issue.. when going left or right, the werewolf gets stuck moving in that direction...
sprite is 32x32 pxls
collision mask is full image
this one has me confused....
create event werewolf
Code:
/// movement
xspd = 6; // Move speed along x axis, must be less than gridx
yspd = 6; // Move speed along y axis, must be less than gridy
gridx = 32; // Grid cell x size, I recommend your player sprite width
gridy = 32; // Grid cell y size, I recommend your player sprite height
dir = 0; // Direction, must be between 0 and 3. 0=Right, 1=Down, 2=Left, 3=Up
key_right = ord("D"); // Key to move right. D is ord("D") vk_right is arrow
key_down = ord("S"); // Key to move right. S is ord("S")
key_left = ord("A"); // Key to move right. A is ord("A")
key_up = ord("W"); // Key to move right. W is ord("W")
// Do not change
xspd = gridx / (gridx div xspd); // Makes xspd work
yspd = gridy / (gridy div yspd); // Makes yspd work
Code:
/// snap to grid and movement
if !place_snapped(gridx,gridy)
{ // If you aren't snapped to the grid..
switch dir{ // Check the direction
case 0: // If it's 0 (right)
x += xspd; // Move right by the x speed
break; // Stop checking if it's right
case 1: // If it's 1 (down)
y += yspd; // Move down by the y speed
break; // Stop checking if it's down
case 2: // If it's 2 (left)
x -= xspd; // Move left by x speed
break; // Stop checking if it's left
case 3: // If it's 3 (up)
y -= yspd; // Move up by the y speed
break; // Stop checking if it's up
}
}
else
{ // If you are snapped to the grid..
if keyboard_check(key_right) && !place_meeting(x+32,y,obj_block) && !keyboard_check(vk_shift)
{
dir = 0; sprite_index = spr_werewolf_right; // Set the direction to 0 (right)
x += xspd; // Move right by the x speed
}
else
if keyboard_check(key_down) && !place_meeting(x,y+32,obj_block) && !keyboard_check(vk_shift)
{
dir = 1; sprite_index = spr_werewolf_down; // Set the direction to 1 (down)
y += yspd; // Move down by the y speed
}
else
if keyboard_check(key_left) && !place_meeting(x-32,y,obj_block) && !keyboard_check(vk_shift)
{
dir = 2; sprite_index = spr_werewolf_left;// Set the direction to 2 (left)
x -= xspd; // Move right by the x speed
}
else
if keyboard_check(key_up) && !place_meeting(x,y-32,obj_block) && !keyboard_check(vk_shift)
{
dir = 3; sprite_index = spr_werewolf_up; // Set the direction to 3 (up)
y -= yspd; // Move up by the y speed
}
}
//stop animation if not moving
if x == xprevious && y == yprevious
{
image_speed = 0;
image_index = 0;
}
else
{
image_speed = 0.3
}
// facing player with shift+WASD
if keyboard_check(key_right) && keyboard_check(vk_shift)
{
dir = 0; sprite_index = spr_werewolf_right;
}
else
if keyboard_check(key_down) && keyboard_check(vk_shift)
{
dir = 1; sprite_index = spr_werewolf_down;
}
else
if keyboard_check(key_left) && keyboard_check(vk_shift)
{
dir = 2; sprite_index = spr_werewolf_left;
}
else
if keyboard_check(key_up) && keyboard_check(vk_shift)
{
dir = 3; sprite_index = spr_werewolf_up;
}
edit...
thought i fixed it, but nope ;o)
Last edited: