K
Kaan Yılmaz
Guest
I placed the walls with tiles. And then added a collision object. İt has a invisible sprite and collision mask. Solid box is checked. First, I tried to set the players speed 0 when player hits the wall. But I'm using josytick controller with theese codes;
global.xx=device_mouse_x(0);
global.yy=device_mouse_y(0);
global.xx1=device_mouse_x(1);
global.yy1=device_mouse_y(1)
x = view_xview + 174;
y = view_yview + 342;
if (device_mouse_check_button(0,mb_left)and position_meeting(global.xx,global.yy,obj_yon)) or (device_mouse_check_button(1,mb_left)and position_meeting(global.xx1,global.yy1,obj_yon))
{
global.dir = point_direction(x,y,global.xx,global.yy);
obj_player.image_angle=global.dir;
obj_player.direction=global.dir;
obj_player.speed = 5;
}
else
{
obj_player.speed=0;
}
And if I set the speed 0 when player touches the wall, it feels very veird and uncomfortable with these controls. Because when I hit the wall with an angle it still stops. Kinda like sticking into the wall. Player can still turn around and then move, but I don't want that, it just takes all the fun away.
I want it to start sliding when I hit the wall with an angle. So, is there any way to do this?
Also I tried the checking if the front of the player is empty.
if (place_free(x + lengthdir_x(32,direction), y + lengthdir_y(32, direction)))
{
draw_text(64,64,"Free");
}
else
{
draw_text(64,64,"Closed");
}
This is the code that I write to see how it is works. Then I applied it to the joystick and it worked like the other way because I was have to set the speed 0 again.
global.xx=device_mouse_x(0);
global.yy=device_mouse_y(0);
global.xx1=device_mouse_x(1);
global.yy1=device_mouse_y(1)
x = view_xview + 174;
y = view_yview + 342;
if (device_mouse_check_button(0,mb_left)and position_meeting(global.xx,global.yy,obj_yon)) or (device_mouse_check_button(1,mb_left)and position_meeting(global.xx1,global.yy1,obj_yon))
{
global.dir = point_direction(x,y,global.xx,global.yy);
obj_player.image_angle=global.dir;
obj_player.direction=global.dir;
obj_player.speed = 5;
}
else
{
obj_player.speed=0;
}
And if I set the speed 0 when player touches the wall, it feels very veird and uncomfortable with these controls. Because when I hit the wall with an angle it still stops. Kinda like sticking into the wall. Player can still turn around and then move, but I don't want that, it just takes all the fun away.
I want it to start sliding when I hit the wall with an angle. So, is there any way to do this?
Also I tried the checking if the front of the player is empty.
if (place_free(x + lengthdir_x(32,direction), y + lengthdir_y(32, direction)))
{
draw_text(64,64,"Free");
}
else
{
draw_text(64,64,"Closed");
}
This is the code that I write to see how it is works. Then I applied it to the joystick and it worked like the other way because I was have to set the speed 0 again.