;

PDA

Click to See Complete Forum and Search --> : help with a game


GeeB
12-15-2002, 05:41 PM
I'm having troble with a little game i am making. You drop bombs and the ground gets blasted away. This is what happens..

A movie clip is duplicated and accelerates downward. when it contacts the ground it goes to a different frame with a black color (the same as the background) and stops. This gives the effect of the ground being blasted away (like worms). The problem i have is when the bomb hits the ground the others need to test the ones that have blasted the ground away and therefore travel through them as well. I used a loop to detect the ones on the ground already, but i cant figure out how to make them pass through the others smoothly.

go Here (http://home.attbi.com/~geeb/grounddestruct.html) to see the swf.

johnie
12-15-2002, 05:50 PM
Instead of switching the MC to show black you could just remove it assuming that the background is black.

the Action to do that is RemoveMovieClip().

GeeB
12-15-2002, 05:53 PM
If i remove it though, then it dosn't appear that the ground is being blasted away.

johnie
12-15-2002, 06:02 PM
You could compose the ground of multiple overlaping MC's that way one one is removed it leaves a whole.

Other than removing the clip how are you using Hit Test? You could do this in several ways. One way is to use a Var in each MC. The bomb checks fore the Value. If the Value is true it turns black and removes the bomb. Once it is flagged true change it to so that it no longer flags true.

Another way is to check for the Hit test using a Frame. The use Goto and Stop Frame without the Hitest for the ground.

GeeB
12-15-2002, 08:44 PM
heres the code for the bomb mc:

onclipevent (load){
this.gotoandstop(1);
yvel=0;
inc=.4;
rand=math.ceil (math.random() *4);
cc=_root.c; //just finding out the # of this mc so i dont collision
} //detect for itself later



onclipevent (enterframe){
if (_y>412){removemovieclip();} // mc falls too far and gets deleted
yvel+=inc;
_y+=yvel;




if (_root.ground.hittest(_x,_y,true)){ //mc hits ground


yvel=0; //velocity and the number it is
inc=0; //increased by is set to 0
if (rand==1){this.gotoandstop(2);} // random black craters
if (rand==2){this.gotoandstop(3);}
if (rand==3){this.gotoandstop(4);}
if (rand==4){this.gotoandstop(5);}
} else {

for (i=0 ; i<cc ; i++){ //testing for a collision with
if (i==cc){i=i+1;} //other mcs already stoped at ground
if (hittest(_root["mc"+i])){
this.gotoandstop(1); //this is where i need help <--
yvel+=inc; // <-- if it collides with other mcs,
_y+=yvel; // <--ignore vel set to 0
} // but when it collides with multiple
} // the vel gets doubled each time
}



}

johnie
12-15-2002, 08:55 PM
Simple fix here.

take this;

if (_root.ground.hittest(_x,_y,true)){ //mc hits ground


yvel=0; //velocity and the number it is
inc=0; //increased by is set to 0
if (rand==1){this.gotoandstop(2);} // random black craters
if (rand==2){this.gotoandstop(3);}
if (rand==3){this.gotoandstop(4);}
if (rand==4){this.gotoandstop(5);}
} else {

for (i=0 ; i<cc ; i++){ //testing for a collision with
if (i==cc){i=i+1;} //other mcs already stoped at ground
if (hittest(_root["mc"+i])){
this.gotoandstop(1); //this is where i need help <--
yvel+=inc; // <-- if it collides with other mcs,
_y+=yvel; // <--ignore vel set to 0
} // but when it collides with multiple
} // the vel gets doubled each time
}


from the onclip event. Create 2 frames with 0 tweens. Add them to the first frame and add a gotoand Play frame back to the frame with your action. You will also have to shift your MC. What that will do is make it so that the Random Black chunk will not execute a hit test and your bomb should pass through.

GeeB
12-15-2002, 09:01 PM
ahh, good idea. I'll try it now.

GeeB
12-15-2002, 09:26 PM
came across somthing else.

if (_root.ground.hittest(_x,_y,true)){ //mc hits ground


yvel=0; //velocity and the number it is
inc=0; //increased by is set to 0



if the bomb hits the ground. even when the bomb is passing through the black mcs these properties are still being applied.

johnie
12-16-2002, 01:10 AM
As you are removing the bomb if it hits a section of ground it would not need to have its velocity set to 0 as its gone.