Jump to content


jmejay

Member Since 18 Aug 2011
Offline Last Active Aug 22 2011 10:03 PM

Posts I've Made

In Topic: Bounce script help

21 August 2011 - 04:59 AM

jmejay, if you set the argument to move_bounce() to true, it will reflect correctly. Meaning, use move_bounce_all(true) instead of false. That should suit your needs, unless I've missed something specific about this case.

-IMP


Thanks.

In Topic: Bounce script help

21 August 2011 - 01:15 AM

As for your argument error, you "skipped" using argument5. You accessed 0123467 when it should have been 0123456.


Thanks man. Silly mistakes -.-

I just tried your move_bounce code and it works although is very limited as it only reverses the ball whereas I would like to refract it.
Not sure if thats the right terminology but hopefully you could understand via my bounce script what im trying.

Thanks a lot anyway!

In Topic: Bounce script help

20 August 2011 - 11:03 PM

Alright I think I may be getting somewhere, but I've hit an error.

Ball Step Event:
w = sprite_get_width(0); h = sprite_get_height(0);
bSpd = 4;
if(mouse_check_button_pressed(mb_left) || keyboard_check_pressed(vk_space)){connected = false;}
if(connected == true){x = objBat.x; y = objBat.y-16;}
else
{
    speed = bSpd;
    hitcube = collision_point(x,y,cube,false,true);
    if(hitcube > 1)
    {
        direction = Bounce(direction, x, y, hitcube.x, hitcube.y, w, h);
        hitcube = instance_destroy(); // or remove hp
        score += 1;
    }
    
    hitbat = collision_point(x,y,objBat,false,true);
    
    if(hitbat > 1)
    {
        direction = Bounce(direction, x, y, hitbat.x, hitbat.y, w, h);
    }

}

Bounce Script:
dir = argument0; //direction
xx = argument1; //ball x
yy = argument2; //ball y
othx = argument3;// other obj x
othy = argument4;// other obj y
w = argument6;// ball w
h = argument7;// ball h
hw = w / 2;
hh = h / 2;
// other objs width is assumed to be 16 hence othx + 8


if(xx + hw < othx - 8) // if hits left side
{
    retdir = 90 - dir; retdir *= 2;
    dir += retdir;   
    return dir;
}

if(xx - hw > othx + 8) // if hits right side
{
    retdir = 90 - dir; retdir *= 2;
    dir += retdir;   
    return dir;
}

if(yy - hh > othy + 8)// if hits from below
{
    retdir = 90 - dir; retdir += 270;
    dir = retdir;
    return dir;
}

if(yy + hh < othy - 8)// if hits from above
{
    retdir = 90 - dir; retdir += 270;
    dir = retdir;
    return dir;
}


Error message:
ERROR in
action number 1
of Step Event
for object objBall:

Illegal argument count calling script "Bounce".
Script requires 8 arguments, 7 have been supplied.

Anyone? Think i'll need to sleep on it again...

In Topic: Bounce script help

20 August 2011 - 08:53 PM

Sadly not. I'm fairly certain it needs to check the side of another object. Is this possible?

Think about it, The speed change (you've shown there as a and B) would still have different effects if the ball hit the side or hit the bottom.

Does anyone know how to check if you hit the bottom or side of an object?

In Topic: Bounce script help

20 August 2011 - 12:03 PM

Thanks unique - but,
It needs to be dependent on which side of an object it hits. So that wouldn't work, also I think you mean a directional change of 90 not 180.