Destructible terrain (kind of like Worms)

Show us your works in progress and request feedback

Post » Wed Oct 29, 2014 6:16 pm

Hi. I'm working on a game like Worms.
I made a destructible landscape you can destroy pixel by pixel, with the help of the Canvas plugin (and the precious advices of R0J0hound).

Image

This is quite easy ; the tricky part was that I wanted to have a number of generated particles according to the number of destroyed pixels.

I'm storing all my landscape pixels in an array. Then I check the pixels directly into the array instead of checking them directly on the canvas via the alphaAt method. Finally I update the array to remove all the pixels that were destroyed.

It still needs tweaks to be faster.

http://canapin.com/construct/worms/terrain/

I'm interested in any advice or idea ! :)
You do not have the required permissions to view the files attached to this post.
Last edited by Coin-coin le Canapin on Sat Nov 01, 2014 12:13 pm, edited 1 time in total.
B
12
S
7
G
7
Posts: 450
Reputation: 4,276

Post » Wed Oct 29, 2014 6:39 pm

I dont really understand what kind of advices or feedbacks you want here ^^" Do you want advices to make your events work faster? I'm not so good with construct, will not be any help for this, sorry!

Alhough, what about the particles being of the color of the pixel destroyed? That should be a bit better ^^
Otherwise your demo works pretty well, nice job on it :)

Anyway, I think the .capx could be helpful so thanks for sharing :)

have a nice day ;)
B
7
S
2
G
1
Posts: 51
Reputation: 679

Post » Wed Oct 29, 2014 7:02 pm

i really like what you have so far. good job
B
46
S
20
G
9
Posts: 541
Reputation: 9,307

Post » Wed Oct 29, 2014 7:26 pm

regisRquoi wrote:I dont really understand what kind of advices or feedbacks you want here ^^"

For example, like this ! :mrgreen:
regisRquoi wrote:Alhough, what about the particles being of the color of the pixel destroyed? That should be a bit better ^^

And technical advices too.

humanescape : thanks :)
B
12
S
7
G
7
Posts: 450
Reputation: 4,276

Post » Wed Oct 29, 2014 7:59 pm

Wow, this is great! Thank you for sharing the project. :)
ImageImageImageImage
B
62
S
19
G
51
Posts: 633
Reputation: 30,836

Post » Wed Oct 29, 2014 8:35 pm

wow, very nice!
im also in the process of making a worms like game, i used an other aproach which i found here on the forums with 1*1 tilemap and i added an overlay effect with another (bigger) tilemap and its a bit of overkill for the construct2 editor.
now i will also try your solution, i like very much that it just uses an real image, much nicer and diversified maps are possible with that, i always dreamed about that while building the maps with my two tilemaps!
Thank you for sharing that!

btw heres a prototype of my aproach
http://fldr.de/tanks1 (mousewheel for explosionradius)
B
38
S
11
G
5
Posts: 485
Reputation: 5,340

Post » Wed Oct 29, 2014 9:41 pm

Thank you :)
I also saw the 1*1 tilemap solution.

If you simply want to create a hole in a picture with no more effects like your tank game, the Canvas plugin itself can do that very well, just paste any sprite on your canvas with a "Destination out" blend effect.
It's very efficient and I think even with big holes. But maybe you've already tried this ?

My project is slower more complicated because I really want to count each pixel in order to have a proportional number of particles.

I need to use a faster algorith to count the pixels inside the explosion radius, and I'd also like to find a faster way to update my array, I don't know if it is possible.

BTW, I've also added an increasing/decreasing radius option with the mousewheel as you did, so you can see the actual (bad) performances with more pixels to remove : http://canapin.com/construct/worms/terrain/
Also, my canvas is quite small. I bet the performances decreases a lot with a bigger canvas.
Edit : well, they don't. Takes some time to put all the pixels into the array, thought.
B
12
S
7
G
7
Posts: 450
Reputation: 4,276

Post » Wed Oct 29, 2014 10:06 pm

maybe i didnt try enough with your example but it seems its not possible to use the terrain object as a platform, or am i wrong?
nonetheless i really like what youre done there! and i have many ideas to use this canvas/destination out solution for something else, great job! :)

btw i dont know if it helps but i learned last week at university that algorythms that have nested "for loops" take very much time, but unfortunately im not very good at optimizing them (yet) so i cant give advice on how to make yours different, but i can ask my colleague and lecturer at friday how to improve your algorythm, were doing nothing else then estimating how long algyrythms take and if its possible to optimize them in this class. are you familiar with "divide and conquer" method ? maybe you could use it or something likewise to optimize your algorythm.
B
38
S
11
G
5
Posts: 485
Reputation: 5,340

Post » Thu Oct 30, 2014 12:32 am

Basically, you can't.
If you really want to, you can check this message : destroy-objects-parts_p636126?#p636126 :)

For my game, I'll have to create custom movements from A to Z because of the Canvas landscape and I bet it won't be easy.

Regarding my algorithm, I'm using the one written in the second comment : http://stackoverflow.com/questions/1201 ... ed-circles
That's not very fast. I'll try to use the first one (I tried before but I was using it wrong so the results weren't as expected...).

I know nothing about maths so it's kinda hard for me to use all this stuff with numbers, letters and sometimes more. :D
B
12
S
7
G
7
Posts: 450
Reputation: 4,276

Post » Sat Nov 01, 2014 12:23 pm

Hi again,
I used a faster algorithm based on http://www.wikiwand.com/en/Midpoint_circle_algorithm to browse all the pixels contained in the radius of each explosion.
It's still kind of slow for large radius > 50.

I'm even not sure there is a noticeable difference :/

fast algorithm : http://canapin.com/construct/worms/terrain/
slow algorithm : http://canapin.com/construct/worms/terrain_slow/
(to be sure the first one is properly updated, clear the cache of this URL : http://canapin.com/construct/worms/terrain/c2runtime.js , ctrl-F5 on Chrome)

The first seems to be a litter faster than the other one. Anyone notices the same or I just want to believe too much ?

The slow things is updating all the pixels of the radius explosion in the array and I dont know how I can increase performances for this.
You do not have the required permissions to view the files attached to this post.
B
12
S
7
G
7
Posts: 450
Reputation: 4,276

Next

Return to Works in Progress/Feedback Requests

Who is online

Users browsing this forum: No registered users and 1 guest