Trying to do something in a collision event

U

Uhfgood

Guest
well you guys probably know my problem by now, it was paddle/ball/wall collision problems

I'm working on a new problem. New problem is that when the ball is caught between the bat and the wall it will be stuck.

So what I'm trying to do, is when I determine when the ball gets stuck between the bat and the wall, I try to let it do nothing, so that it will bounce off the wall. (That is, it will follow ball-wall collision).

Here's a script from the coding breakout tutorial called scr_move_out:
Code:
while( place_meeting( x, y, argument0 ) )
{
    x += lengthdir_x( 1, argument1 );
    y += lengthdir_y( 1, argument1 );
}
Very simply if there' s a collision from the calling object, it will move that object backwards back out until it's no longer colliding.

So here's the ball-bat collision:
Code:
var is_touching = false;
var is_stuck = false;

if( place_meeting( x - ( sprite_width / 2 ), y, obj_LWall ) )
    is_touching = true;
else
if( place_meeting( x + ( sprite_width / 2 ), y, obj_RWall ) )
    is_touching = true;
    
if( is_touching == true )
{
    if( y + ( sprite_height / 2 ) > other.y - ( other.sprite_height /2 ) )
    {
        is_touching = false;
        is_stuck = true;
    }
}

if( is_stuck == false )
{
    var dir;
    dir = point_direction( other.x, other.y, x, y );
    scr_move_out( other, dir );

    move_bounce_all( true );
    motion_add( dir, 5 );
    speed = 5;
}
So here's what's going on... I check the left side of the ball with the right side of the left wall and the right side of the ball with the left side of the right wall. If they're touching then I go further and check to see if the ball intersects the bat's area basically checking y coord of the bottom of the ball and the top of the bat, then I set the is stuck flag to true.

Now, if it's false I let the collision go like normal, if not, it should just bounce off the wall but it's not doing so.

Here's the ball-wall collision:
Code:
var dir;
dir = direction - 180;
scr_move_out( other, dir );
move_bounce_all( true );
I don't know if event order matters, but let me know if it does. Problem here is, that the ball is still stuck. I put the is_stuck == false check around the whole ball-bat collision code, because I don't want it to execute unless the ball is not stuck. Not sure what's going on, anyone have any idea?
 
Top