Destructible terrain (kind of like Worms)

1 favourites
From the Asset Store
Best car suspension with spring effect and very cool terrain generation.
  • 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).

    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.

    I'm interested in any advice or idea ! <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile">

  • 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

  • i really like what you have so far. good job

  • I dont really understand what kind of advices or feedbacks you want here ^^"

    For example, like this !

    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

  • Wow, this is great! Thank you for sharing the project. :)

  • 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 (mousewheel for explosionradius)

  • Thank you <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile">

    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 :

    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.

  • 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.

  • Basically, you can't.

    If you really want to, you can check this message : destroy-objects-parts_p636126?#p636126 <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile">

    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 : ... 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. <img src="{SMILIES_PATH}/icon_e_biggrin.gif" alt=":D" title="Very Happy">

  • Hi again,

    I used a faster algorithm based on 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 :

    slow algorithm :

    (to be sure the first one is properly updated, clear the cache of this URL : , 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.

  • im pretty sure the fast algorithm is really faster (not so much but faster), try to make >10 fast clicks, you can see the slow one really hang a while

  • le Canapin if you're doing testing, you should really just have a button that always fires the destruction code in the same area, while you count ticks between the start and end of the algorithm.

    Do that for multiple areas on the screen, refresh, do it all again, and average through a few runs.

    Then do that for your "new" algorithm.

    Because honestly I don't notice a difference between the two.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I measured the duration of each event using wallclocktime function and clicking like mad, and it appears that the first algorithm is faster.

    0.12s vs 0.15s, the results are constant over my tries.

  • Well cool. Good to know. Any updates on the game you're working on?

  • Not much.

    Damage calculation has some glitches (with the 2nd weapon), players can't move and some badly optimized events cause too much CPU work.

    Plus, I didn't implemented the proportional particle effect.

    Actually I'm refactoring my engine from A to Z because it was a complete mess. I'll create a thread about it when I have something to show.

    My project is creating a multiplayer game inspirated mostly by Gunbound, which had an incredibly amazing gameplay until the developper ruined it. I could talk about it for hours.

    That said, I've never finished any project, with Construct 2 or not. But I enjoy trying year after year <img src="{SMILIES_PATH}/icon_e_biggrin.gif" alt=":D" title="Very Happy">

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)