R
roboapple
Guest
Im doing a sideview platformer, trying to get the character to walk up a slope, but the issue im having with the place_free command, if im testing for collisions on the right side of the play, place_free(x+1,y) checks the entire players right side, from top to bottom, so i decided to use the collissions_circle command to detect a small area in front of the player, and have the character move upwards when colliding with an objects, heres what i have so far.
my issue is trying to find a way to get it to detect all solid objects instead off just a single object.
you can see ive tried all.solid and just solid by itself, but it does not work.
//keypress detection
if keyboard_check(vk_left)
for (var i = 4; i > 0; i--)
{
if !collision_circle( x-14-i, y, 1, all.solid, false, true)
{
x-=i;
hdir = -1;
break;
}
}
else if keyboard_check(vk_right)
for (var i = 4; i > 0; i--)
{
if !collision_circle( x+14+i, y, 1, all.solid, false, true)
{
x+=i;
hdir = 1;
break;
}
}
else hdir = 0
//simulated gravity
y += grav * -1;
if place_free(x, y + 1)
{
grav -= .3;
}
else
{
grav = 0;
hspeed = 0
in_air = false;
}
//if colliding with block, move up, thus simulating walking up slope
if !place_free(x, y)
{
y -= 3;
}
my issue is trying to find a way to get it to detect all solid objects instead off just a single object.
you can see ive tried all.solid and just solid by itself, but it does not work.
//keypress detection
if keyboard_check(vk_left)
for (var i = 4; i > 0; i--)
{
if !collision_circle( x-14-i, y, 1, all.solid, false, true)
{
x-=i;
hdir = -1;
break;
}
}
else if keyboard_check(vk_right)
for (var i = 4; i > 0; i--)
{
if !collision_circle( x+14+i, y, 1, all.solid, false, true)
{
x+=i;
hdir = 1;
break;
}
}
else hdir = 0
//simulated gravity
y += grav * -1;
if place_free(x, y + 1)
{
grav -= .3;
}
else
{
grav = 0;
hspeed = 0
in_air = false;
}
//if colliding with block, move up, thus simulating walking up slope
if !place_free(x, y)
{
y -= 3;
}