S
stepup2000
Guest
i know this is some very basic stuff but cant seem to wrap my head around it. im making a top down game andtThis is the code i use for movement/collision:
vspeed = 0;
hspeed = 0;
if(keyboard_check(ord("W"))) vspeed -= 4
image_speed = 1
if(keyboard_check(ord("S"))) vspeed += 4;
image_speed = 1
if(keyboard_check(ord("A"))) hspeed -= 4;
image_speed = 1
if(keyboard_check(ord("D"))) hspeed += 4;
image_speed = 1
speed = clamp(speed, -4, 4);
if place_meeting(x + hspeed, y, obj_wall)
{
hspeed = 0
}
if place_meeting(x, y + vspeed, obj_wall)
{
vspeed = 0
}
this code worked perfectly until i changed the way my character works. because instead of rotating the image angle when the character had to rotate i made a draw event and let the character draw the correct sprite and then rotate it the right way. but because of this reason i dont use a sprite anymore so that means he doesnt have a hitbox anymore. So right now everything goed trough the character. so i added this code to add a collisionbox:
sprite_collision_mask(1, false, 0, x - 13, y -13, x + 17, y + 13, 1, 0);
but this doesnt solve the problem. does anyone has a idea? thanks in advance.
vspeed = 0;
hspeed = 0;
if(keyboard_check(ord("W"))) vspeed -= 4
image_speed = 1
if(keyboard_check(ord("S"))) vspeed += 4;
image_speed = 1
if(keyboard_check(ord("A"))) hspeed -= 4;
image_speed = 1
if(keyboard_check(ord("D"))) hspeed += 4;
image_speed = 1
speed = clamp(speed, -4, 4);
if place_meeting(x + hspeed, y, obj_wall)
{
hspeed = 0
}
if place_meeting(x, y + vspeed, obj_wall)
{
vspeed = 0
}
this code worked perfectly until i changed the way my character works. because instead of rotating the image angle when the character had to rotate i made a draw event and let the character draw the correct sprite and then rotate it the right way. but because of this reason i dont use a sprite anymore so that means he doesnt have a hitbox anymore. So right now everything goed trough the character. so i added this code to add a collisionbox:
sprite_collision_mask(1, false, 0, x - 13, y -13, x + 17, y + 13, 1, 0);
but this doesnt solve the problem. does anyone has a idea? thanks in advance.