Page 1 of 2

Tanks - terrain question

PostPosted: Mon Jul 20, 2009 5:14 pm
by Camper1995
Hi all, I just wanna know If can I make with Game Editor terrain like in this game,

So when the game start, computer will random generate the terrain and when you fire and the shot hit the terrain,
it will make hole in to it... Is this possible with GE?

http://www.webgames.cz/tanks/289-1/

Thank you,

CAmPeR. :)

Re: Tanks - terrain question

PostPosted: Mon Jul 20, 2009 8:43 pm
by Fuzzy
Its possible. Its not trivial but i did it a few years ago. I dont have the ged any more.

Re: Tanks - terrain question

PostPosted: Tue Jul 21, 2009 5:49 am
by Bee-Ant
Its very possible and easy enough :P

Re: Tanks - terrain question

PostPosted: Tue Jul 21, 2009 12:03 pm
by Camper1995
Well, can you tell me how to do this please? :) thx

Re: Tanks - terrain question

PostPosted: Tue Jul 21, 2009 3:24 pm
by Bee-Ant
The first way,use the "load map from external file" system.there's a demo at Game Demos section.
Then,make some different maps for different terrain.
Finally,use a random variable to load the map randomly :D

Re: Tanks - terrain question

PostPosted: Tue Jul 21, 2009 6:15 pm
by Camper1995
Yea, but how to do when the shot hit the terrain make the hole in that terrain.

Thx

Re: Tanks - terrain question

PostPosted: Tue Jul 21, 2009 9:16 pm
by skydereign
If you notice in that demo you gave, the holes were set in animation. So if you are doing what Bee-Ant suggested, then you should just have a collision event. Upon collision with the destroying object, increase the animpos, or change animation, so it is more beat up looking. Eventually the terrain will get destroyed, just like the game.

Re: Tanks - terrain question

PostPosted: Wed Jul 22, 2009 1:49 am
by Bee-Ant
skydereign wrote:If you notice in that demo you gave, the holes were set in animation. So if you are doing what Bee-Ant suggested, then you should just have a collision event. Upon collision with the destroying object, increase the animpos, or change animation, so it is more beat up looking. Eventually the terrain will get destroyed, just like the game.

Thats right, set the animation direction of all terrain sprites to be stopped. And set the animation from the most intact to the most broken. And then you just increase the collide.animpos anytime your bullet collide with the terrain.

Re: Tanks - terrain question

PostPosted: Wed Jul 22, 2009 11:31 am
by Camper1995
Ok, but I was searching and I cant found where is that most intact and most broken.. :(

So I have a objet called Ground and object called Bullet. So, when Ground collide with bullet ? Destroy Actor bullet and what more.. ?

Thank you,

CAmPeR :)

Re: Tanks - terrain question

PostPosted: Thu Jul 23, 2009 12:30 am
by skydereign
Well, instead of immediately destroying the ground, you would increase its animpos. Something like this.
bullet->Collide(ground)->Script Editor
Code: Select all
if(animpos==5)
{
    DestroyActor("Collide Actor");
    animpos++;
    DestroyActor("Event Actor");
}

Re: Tanks - terrain question

PostPosted: Thu Jul 23, 2009 1:22 am
by Bee-Ant
Sky, it seems this guy need a demo...
A demo could tell him better than words.

Well,what view do you want?top view?side view?

Re: Tanks - terrain question

PostPosted: Thu Jul 23, 2009 2:04 am
by Bee-Ant
Here's the demo...
Is this what you mean?

Re: Tanks - terrain question

PostPosted: Thu Jul 23, 2009 5:31 am
by Fuzzy
There is a more realistic way. You need an array as big as the max x of the screen. use things like sin and cos to generate some values, storing them in the array, after multiplying them by the max height you want. If you use random you will have to smooth the array values.

Step through the array, drawing lines to a canvas from the number in the array down to the bottom.

Thats your height field.

Next, whenever the tank gets hit, check to see if he is higher than the pixels at his x value. if so, make him fall.

When firing, trace the shot, figure out where it will be next draw. if that is a value that is greater than the value stored at that point of the array, then you have struck the ground.

To draw a pit, go back several pixels from the collision point and take some points out of that array box. then do the same, closer to the collision point. and so on, for a few pixels past the collision. next, redraw the ground using the array, and decide of any tanks are in the air.

Re: Tanks - terrain question

PostPosted: Thu Jul 23, 2009 6:04 am
by Bee-Ant
Fuzzy wrote:There is a more realistic way. You need an array as big as the max x of the screen. use things like sin and cos to generate some values, storing them in the array, after multiplying them by the max height you want. If you use random you will have to smooth the array values.

Step through the array, drawing lines to a canvas from the number in the array down to the bottom.

Thats your height field.

Next, whenever the tank gets hit, check to see if he is higher than the pixels at his x value. if so, make him fall.

When firing, trace the shot, figure out where it will be next draw. if that is a value that is greater than the value stored at that point of the array, then you have struck the ground.

To draw a pit, go back several pixels from the collision point and take some points out of that array box. then do the same, closer to the collision point. and so on, for a few pixels past the collision. next, redraw the ground using the array, and decide of any tanks are in the air.

????????????????

Re: Tanks - terrain question

PostPosted: Thu Jul 23, 2009 6:12 am
by Fuzzy
Bee-Ant wrote:
Fuzzy wrote:There is a more realistic way. You need an array as big as the max x of the screen. use things like sin and cos to generate some values, storing them in the array, after multiplying them by the max height you want. If you use random you will have to smooth the array values.

Step through the array, drawing lines to a canvas from the number in the array down to the bottom.

Thats your height field.

Next, whenever the tank gets hit, check to see if he is higher than the pixels at his x value. if so, make him fall.

When firing, trace the shot, figure out where it will be next draw. if that is a value that is greater than the value stored at that point of the array, then you have struck the ground.

To draw a pit, go back several pixels from the collision point and take some points out of that array box. then do the same, closer to the collision point. and so on, for a few pixels past the collision. next, redraw the ground using the array, and decide of any tanks are in the air.

????????????????



I hate making demos. But I will! For this.