Destructible Terrain? Better ideas than this?

Get help using Construct 2

Post » Wed Aug 01, 2012 6:01 am

Blackened Topiary

Made this over the course of about 10 hours. Pretty playable so far but the way Im doin the terrain is really bringin the system down. I doubt (given proper controls) itd be playable on mobile at all.

So Im lookin for some ideas on how to better do destructible terrain. Right now its generating a sprite object at each 8x8 location for the peak of the terrain. Then goin back thru and filling the locations below the peak with semi random terrain. I couldnt think of a better way to do it with c2 =/

Arrow keys: adjust angle/power
Space Bar: Shoot

Dont pay any attention to the numbers in the boxes on the first screen its there for debug stuff I just forgot to remove it in the uploaded version. Its local mp only 2 to 6 players. Should be pretty much fully playable. Last one left alive is the winner!
B
13
S
5
G
2
Posts: 306
Reputation: 3,262

Post » Wed Aug 01, 2012 9:07 pm

I answered on your other post, but figured I should copy it here since I came up with a possible answer while typing it.
---
I'm curious about a faster way to do terrain too, I was planning on trying a catapult game eventually.

One thing about your current method, it would be easy to turn on gravity for each of the dirt sprites, allowing you to drop enemies for damage.

Maybe slightly faster but not as interesting would be to use tall vertical sprites like columns of dirt, when they got hit, they could slide down so far. (or reduce in height) It would cut the number of sprites from around 2000 to 80.
B
201
S
52
G
30
Posts: 897
Reputation: 36,621

Post » Wed Aug 01, 2012 9:17 pm

if you did it that way you couldnt put holes inside it only reduce the overall height
B
13
S
5
G
2
Posts: 306
Reputation: 3,262

Post » Thu Aug 02, 2012 8:17 am

Might be complicated but, when the cannonball hits the sprite you reduce it's height to the position of the cannonball, (all dirt above the hit vanishes) minus a few extra pixels. Then you spawn a stretched sprite above it from the original height down to a few pixels above the cannonball hit. (draw in the overhang) or if the calculated bottom position is above where the surface was, then skip it as that means the crater is on the surface.

It would still look like your original animation, except the rocks couldn't be mixed in, as they would appear to shift down.
(hmm, maybe reverse it, the sky is the sprite columns, moving down hiding the destroyed dirt, rocks wouldn't shift that way.)

I didn't say it was a complete idea, I was trying to spark ideas to reduce the sprites. You would still have to figure how to handle the overhang sprites when they get hit.
B
201
S
52
G
30
Posts: 897
Reputation: 36,621

Post » Thu Aug 02, 2012 7:50 pm

Search for "worms" there is an example that uses the canvas plugin to do destructible terrain.

Another idea would be to set the bottom layer as transparent "use webgl" off, and "clear background" as no. That way anything that is drawn stays there until it's overdrawn. Then you could draw the terrain, and only redraw the parts where stuff is moving/changing. You can store the entire terrain in an array and juggle a small amount of blocks to do the drawing. So at any given time you'd have only say 100 objects being drawn per frame but you would see 1000s on screen.
B
79
S
24
G
54
Posts: 4,747
Reputation: 40,757

Post » Fri Aug 03, 2012 7:44 pm

B
79
S
24
G
54
Posts: 4,747
Reputation: 40,757


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 2 guests