• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Android İs there any other way to make walls?

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.
 
If you want it to slide, then you shouldn't set your player's speed to 0. You should change its direction depending on the angle it hits the wall. For that, assign a variable to point_direction(x, y, oWall), then use this variable to get the collision angle. Then write a finite state system like, -imagining you are hitting a wall thats on the x = 0 on the angle table -360 degree system you know- if collision_dir is 135 degree for example, when you collide with the wall your direction will be set to (180-135) meaning that you'll store the collision degree to use it later. If you want further help, send a private message me so we can talk in our native language :)
 
Top