T
Toxicosis
Guest
Greetings,
I'm still making a prototype. Go me. Anyway, I ran into some problems...
Thing is, I started using x=x+5 for movement (and the reverse for the right). Then I noticed it did not allow the player to go right up to a wall if it were within 5 pixels.
So I went with a FOR loop, which checks for a collision within 5 pixels, then within 4, then within 3, and so on, then increments the x by the number of pixels it can move without colliding. It worked, and I managed to get the character moving right up to a wall, leaving a zero pixels gap. It also worked pretty well for allowing the player to walk up slopes, but it seems like I won't be able to keep this one.
(The if inside the else handles slopes of up to 45°)
The problem is, I'd like some events to be triggered by collision (allowing the player to break some blocks by just walking up to them), and when I use this loop, collisions don't trigger. The move_contact_solid function produces the same error.
I tried adding an additional x++ at the end, which allows for colliding, but that creates another problem: when the character is falling, they can stop their fall by clinging to walls. It looks pretty cool, but I'd rather not adopt this glitch as a feature.
Any ideas?
I'm still making a prototype. Go me. Anyway, I ran into some problems...
Thing is, I started using x=x+5 for movement (and the reverse for the right). Then I noticed it did not allow the player to go right up to a wall if it were within 5 pixels.
So I went with a FOR loop, which checks for a collision within 5 pixels, then within 4, then within 3, and so on, then increments the x by the number of pixels it can move without colliding. It worked, and I managed to get the character moving right up to a wall, leaving a zero pixels gap. It also worked pretty well for allowing the player to walk up slopes, but it seems like I won't be able to keep this one.
Code:
//MOVING RIGHT
//step_move is a variable that allows me to alter the speed quickly.
for (mover=0; mover<step_move ; mover++)
{
//Checks for collision one square ahead.
if !place_meeting(x+1, y, obj_walls)
{
//Steps forward, if there is room.
x++;
}
else
{
//Checks for collision one square ahead and one up.
if !place_meeting(x+1, y-1, obj_walls)
{
//Steps forward and up if there is room.
x++
y--
}
//Stops checking if there isn't room neither ahead nor ahead and above.
}
};
The problem is, I'd like some events to be triggered by collision (allowing the player to break some blocks by just walking up to them), and when I use this loop, collisions don't trigger. The move_contact_solid function produces the same error.
I tried adding an additional x++ at the end, which allows for colliding, but that creates another problem: when the character is falling, they can stop their fall by clinging to walls. It looks pretty cool, but I'd rather not adopt this glitch as a feature.
Any ideas?