Collision problem

Game Editor comments and discussion.

Collision problem

Postby pixel4all » Tue Jan 06, 2009 11:15 pm

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!
pixel4all
 
Posts: 7
Joined: Tue Jan 06, 2009 9:35 pm
Score: 0 Give a positive score

Re: Collision problem

Postby jimmynewguy » Tue Jan 06, 2009 11:49 pm

do you have this turned on?
if no do it thats the most likly problem
Attachments
a.PNG
Working on a probably too ambitious project! Wild-west-adventure-RPG-shooter-thing.
User avatar
jimmynewguy
 
Posts: 1137
Joined: Sat Mar 31, 2007 6:27 pm
Score: 89 Give a positive score

Re: Collision problem

Postby Kalladdolf » Thu Jan 08, 2009 10:56 am

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.
User avatar
Kalladdolf
 
Posts: 2427
Joined: Sat Sep 08, 2007 8:22 am
Location: Germany
Score: 120 Give a positive score

Re: Collision problem

Postby pixel4all » Thu Jan 08, 2009 9:42 pm

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 :)
pixel4all
 
Posts: 7
Joined: Tue Jan 06, 2009 9:35 pm
Score: 0 Give a positive score

Re: Collision problem

Postby Kalladdolf » Fri Jan 09, 2009 8:21 am

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.
User avatar
Kalladdolf
 
Posts: 2427
Joined: Sat Sep 08, 2007 8:22 am
Location: Germany
Score: 120 Give a positive score

Re: Collision problem

Postby pixel4all » Sun Mar 08, 2009 8:56 pm

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...
pixel4all
 
Posts: 7
Joined: Tue Jan 06, 2009 9:35 pm
Score: 0 Give a positive score

Re: Collision problem

Postby skydereign » Sun Mar 08, 2009 9:30 pm

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
}
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Collision problem

Postby pixel4all » Tue Mar 10, 2009 10:25 pm

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 :)
pixel4all
 
Posts: 7
Joined: Tue Jan 06, 2009 9:35 pm
Score: 0 Give a positive score

Re: Collision problem

Postby skydereign » Tue Mar 10, 2009 11:42 pm

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.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Collision problem

Postby pixel4all » Thu Mar 12, 2009 6:19 pm

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...
pixel4all
 
Posts: 7
Joined: Tue Jan 06, 2009 9:35 pm
Score: 0 Give a positive score

Re: Collision problem

Postby skydereign » Thu Mar 12, 2009 11:38 pm

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
}
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Collision problem

Postby pixel4all » Tue Mar 24, 2009 5:50 pm

thanx for all help skydereign :D sorry for reply delay...i had a prob with my account ...
pixel4all
 
Posts: 7
Joined: Tue Jan 06, 2009 9:35 pm
Score: 0 Give a positive score

Re: Collision problem

Postby pixel4all » Tue May 12, 2009 11:10 am

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 :?:
pixel4all
 
Posts: 7
Joined: Tue Jan 06, 2009 9:35 pm
Score: 0 Give a positive score

Re: Collision problem

Postby skydereign » Tue May 12, 2009 11:05 pm

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.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score


Return to GE - General

Who is online

Users browsing this forum: No registered users and 1 guest

cron