Page 1 of 1

Collision problem

PostPosted: Tue Jan 06, 2009 11:15 pm
by pixel4all
hi there people i'm new to GE and i want to ask 2 simple questions :

- i'm making a arcanoid style game and i have a problem with collision.. i make some rectangle cloned blocks on which the ball actor collide and i set 2 events for bounce on them and destroy them...so the problem is that the ball sometimes go through that blocks and destroy 2 or more of them before bounce.How can i avoid that?

-i also want to know how can i change level when all those cloned blocks destoy.

SORY FOR MY BAD ENGLISH :(

keep on good work people and happy new year!

Re: Collision problem

PostPosted: Tue Jan 06, 2009 11:49 pm
by jimmynewguy
do you have this turned on?
if no do it thats the most likly problem

Re: Collision problem

PostPosted: Thu Jan 08, 2009 10:56 am
by Kalladdolf
pixel4all wrote: -i also want to know how can i change level when all those cloned blocks destoy.

Put the following script on an actor (I'd suggest the player):
Code: Select all
if(block.cloneindex < 0)   //if there aren't any blocks left
{ level = level + 1;} // increases the level variable as long as there are no blocks left

make sure you add new blocks in the same function right away, otherwise you won't stop to reach a higher level forever.
If you didn't get this, I'd be happy to make a demo for you.

and if you're making a breakout style of game, I wouldn't use physical response, I'd more like use a change of xvelocity/yvelocity, that is, in the most cases, more reliable.

Re: Collision problem

PostPosted: Thu Jan 08, 2009 9:42 pm
by pixel4all
to jimmynewguy : turning on "repeate this event while actor is colliding" doesn't help with collision problem :(

to Kalladdolf : i'll try it thx for response :D a demo will help anyway..

can you help me with collision prob :?: i use "change xvelocity/yvelocity" for ball bounce and destroy actor event with collision on blocks, but sometimes ball goes through blocks before bounce...any ideas how to avoid that :?:
i also have an other weird prob when ball collide between 2 blocks it goes through blocks :!:
http://www.youtube.com/watch?v=Ckg7PNvvLWs

tnx u for help guys :)

Re: Collision problem

PostPosted: Fri Jan 09, 2009 8:21 am
by Kalladdolf
All right, I just came across a demo, makslane made a very long time ago, so I didn't have to make it myself, so that takes care of that.
You'll find it here.

Re: Collision problem

PostPosted: Sun Mar 08, 2009 8:56 pm
by pixel4all
when i use this script :

if(block.cloneindex < 0)
{ level = level + 1;}

i can't change level because i use same blocks in other levels so my question is how can i change level when all blocks in viewport are destoyed?

--- is there any way to change a block's colour with script? i must use different sprites for blocks with different colour or can i change the colour of these blocks with script?

sorry again for by bad english...

Re: Collision problem

PostPosted: Sun Mar 08, 2009 9:30 pm
by skydereign
To change color, you just set the rgb variables. So if you have a white sprite for your block, in its draw actor event
Code: Select all
r=255;
g=0;
b=0;

This makes it red. You change the values accordingly.
If you are reusing the blocks then you can do this,
Code: Select all
if (ActorCount("block")==0) // if the amount of blocks is 0
{
    level++; // goes up a level
}

Re: Collision problem

PostPosted: Tue Mar 10, 2009 10:25 pm
by pixel4all
tnx for help skydereign but i need some more :)

....i want to color blocks with script but i can't change the rgb values when i use clones of a block...rgb values change color for all cloned blocks is there any way to change color seperately for each block?

thn again :)

Re: Collision problem

PostPosted: Tue Mar 10, 2009 11:42 pm
by skydereign
Yeah, it depends on when you want the color changes. You could use timers, though I would suggest a switch. This example assumes they change color by level.
tile->DrawActor->Script Editor
Code: Select all
switch(level)
{
    case 0: // this means blocks will be white if level is zero
    r=255;
    g=255;
    b=255;
    break;
    case 1: // blocks red if level 1
    r=255;
    g=0;
    b=0;
    break;
    // and so on
}

If they are supposed to change not by level, and you still need help, just ask.

Re: Collision problem

PostPosted: Thu Mar 12, 2009 6:19 pm
by pixel4all
to be more specific i want to do this:

i want to use a single block for every level ---> level1_block,level2_block,level3_block...

in level 1 i want to use clones of level1_block and i want to change the color of these blocks thus i have in level 1 green,blue,red or whatever color i want...

Re: Collision problem

PostPosted: Thu Mar 12, 2009 11:38 pm
by skydereign
The switch statement will still work. You would need to change the variable inside the () to be cloneindex. That way, your clones will be different colors.
level_1_block->DrawActor->Script Editor
Code: Select all
switch(cloneindex)
{
    case 0: // this means block.0 will be white
    r=255;
    g=255;
    b=255;
    break;
    case 1: // block.1 will be red
    r=255;
    g=0;
    b=0;
    break;
    // and so on
}

Re: Collision problem

PostPosted: Tue Mar 24, 2009 5:50 pm
by pixel4all
thanx for all help skydereign :D sorry for reply delay...i had a prob with my account ...

Re: Collision problem

PostPosted: Tue May 12, 2009 11:10 am
by pixel4all
just an other question :

ball.actor destroy when it 's out of vision and number of lifes decrease by 1... this happen also when level change...how can i avoid life decrease at level change :?:

Re: Collision problem

PostPosted: Tue May 12, 2009 11:05 pm
by skydereign
Not sure on the context of this, one way is to destroy the actor before that, or manage it with a variable. Or if it happens every level change, in the level change code, increase life by one. These aren't necessarily the best way, so if you want a different approach, please explain the other factors.