Procedural destruction, anyone? (image warning)

0 favourites
  • 9 posts
From the Asset Store
500 monsters and creatures images for card games - Set 1
  • Anyone here played an indie game called Cortex Command?

    It's a pretty broken, albeit fun 2d side scrolling shooter with fully destructible terrains AND characters, which IMO is its main selling point that sets it apart from most of the other games in the genre. I won't delve into describing in detail how the game's engine works, since that wouldn't get the point across that well, so here, have a couple of random animated .gif images showcasing some of the destruction possible:

    Seeing as this game is 2D and that Construct 2 is also made specifically for creating 2D games got me wondering:

    Would it be possible to recreate a dynamic damage system like this in C2?

    Now, obviously none of us have 11 years to spend making an engine this sophisticated and detailed (yes, that game did take that long to be developed), but i think that with the current state of C2 it might just be possible to pull off something in the spirit of CC, but in a simplified manner.

    So, the question that remains is: "WAT DO???"

    Well, this thread is made for discussing methods of how one might implement this and what problems one would encounter while doing so, so here's my ideas so far...

    Terrain.

    Possibly the simplest part of the puzzle, should be pretty straightforward to do.

    1.) I would approach this by creating a tilemap which would represent the whole game map, and once some sort of deformation would need to occur, i would clear the affected tiles and create sprites which have a physics behaviour in their place, and apply force or rotation to them as needed. Once their velocity drops below a certain threshold, i'd detect their position relative to the tilemap, create the specific tile in their location and destroy the sprites.

    Pros: Relatively simple implementation, decent performance and not very high memory use, should be pretty easy to save the map too.

    Cons: No support for rotation of the static tiles (does this even matter at smaller resolutions?).

    Vehicles and characters.

    This is where the problems begin. While making or characters that are composed of multiple parts (e.g. skeleton animations) and can also be broken up as needed should be possible, albeit a bit tricky to implement, the hard part is creating layers of armor / flesh, that can be removed dynamically.

    1.) One way to accomplish this would be by creating a file of some sorts, which contains information of what your characters are composed of (e.g. which pixels should be made out of flesh, which out of bones, where the eyes should be, where the internal organs or whatever other meaning you can think of giving to slightly differently colored pixels) and once a bullet impact happens, compare the location of the hit with the file and spawn a small, possibly a couple of pixels wide sprite at the location of impact, change its animation frame to the needed one and pin it to the character.

    Pros: Good resolution, no need to change the base character sprite.

    Cons: Performance gets progressively worse as more of these sprites are spawned, no ability to "erase" pixels of the base sprite, this sort of system would also be pretty complicated.

    2.) Another way that one could solve this issue would be to adjust the base sprite by loading it into the canvas, then applying any needed transformations and replacing the base sprite with the adjusted one.

    Pros: Ability to adjust the original sprite, without creating additional ones.

    Cons: Because of how C2 manages sprites, each character would need to have their own sprite (frame?), which makes this option impossible to use without terrible memory management issues, as this would probably have some ridiculous limitations on character numbers.

    3.) Also, one could possibly create a system similar to one described in the first character creation method, just instead of using sprites that represent whole character parts, use many smaller sprites to represent the pixels of each of the character sprites (a bit like making a character out of voxels) and modify these directly, as needed. One way to explain how this would work is to imagine a character represented by a tilemap, that can be rotated and moved (like a sprite). Although probably the most sophisticated method to implement, it would probably be the most versatile and closest to the system in Cortex Command.

    Pros: The most versatile and complete of the approaches listed.

    Cons: Hard to implement, and probably higher base memory usage, would need more CPU resources due to more sprites to manage.

    Ideas on how to do this in other ways? Your suggestions, things to look out for? Example .capx files, even?

  • I think the best way for the death animation is just to make a heap of varied sprites, each enemy say have 5 death animation and you can cycle through that. It achieves visually whats there, this would be the least CPU intensive method.

    The other way is just to spawn a lot of physics objects, 4-5 different object types per mob, ie. helmet, shoe, body gibs etc... PC will handle it fine, mobiles, no way.

  • Most of those obejects gettin destroyed were not procedural. The object was replaced with a multi part version and used physics to fall apart and bounce.

    The little terrain I saw however was more dynamic.

    The terrain looked like it was destroyed using a pattern. You can do this using R0j0's Canvas or Paster. Just useCanvas and Paster objects instead of Sprites for your terrain. You will then have to use some one elses plugin to modify the collision poitns. However your going to have learn more advanced math and to handle the collision points.

    can the above be done. yes, but your going to have work outside the C2 basic pacakge.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Well, the gibs probably aren't procedural in the literal sense of the word (completely different fracture points each time), but the images representing the characters certainly are altered dynamically, as you can see in some of the images where gunshots take out whole areas of body parts (without severing them) and different layers "peel away".

    I might not have the latest version of the canvas plugin, but i feel that it is somewhat limiting, at least compared to what we had in CC. I'll have to check out the Paster plugin.

    If only we had the ability to properly manipulate files, then i could make my own custom file format that could contain character data and interpret it as needed. Webstorage / AJAX is just not the same, too many limitations, too much frustration

  • It doesn't look that way to me, just fancy death animations corresponding to the weapon type. The gibs are just heaps of physics objects.

    Could you do it? Yeah it just takes a very good animator.

  • Hmm... nothing too special imo...

    Ragdolls / Physics Objects

    LOTS of particles

    Sprites changing frames / animations based on impact type

  • Cortex command is...a frustrating game. It's compellingly bad in that very special way that really ambitious -- but very broken -- games are. There's nothing quite like it.

    I actually put together a mockup of this kind of terrain destruction using a tilemap with 2x2 pixels, and spawning physics objects which then turned back into tilemap blocks when they slowed down enough. Basically, the same approach However...when things got even the slightest bit crazy, my framerate was down in the single digits...and that's on my well clocked quad-core and just a tiny map.

    So...yeah, using tilemaps/physics doesn't cut it.

    Though, it would probably work for characters as they are quite small. Just use sprites with tilemaps to mask them. So, the tilemap erodes, and your sprite erodes, etc.

    Using the canvas plugin might work, never thought of that.

    Would love to see a cortex command-style game -- that was actually playable -- but I'm not convinced it would be possible in C2 at this time given the state of the technology.

  • I think it's possible but not worth the hassle. You could go just a couple steps back and do fully destructable terrain, (I think Rojohound made something like that, the discussion had started with cortex command at that time too, just search the forums and you could find it - hint: it uses tilemaps as suggested above) and basic sprite animations + optimized particle physcis. For the gameplay, you do not need each pixel of each character; you just need good hitboxes that represent them.

  • it reminds me of trespasser (the spinoff jurassic park game) in its awfulness. so much potential to do cool stuff; so much went wrong with the implementation.

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