Asset - Scripts Destructible Terrain

Nocturne

Friendly Tyrant
Forum Staff
Admin

This GameMaker Studio 2 asset provides a complete and dynamic resource for creating destructible terrain. Unlike most other destructible terrain assets, this one does NOT use surfaces or shaders and relies instead on a textured polygon approach, meaning that you can create and destroy the terrain in real--time. This also means that it is incredibly fast, especially when compiled using the YYC. The asset also has simple save and load scripts, permitting you to create levels and save them out as files which can then be loaded at any time... give your game a level editor!

FEATURES:
  • Complete set of debugging tools
  • Game editor Demo where you can create and destroy terrain and see how it all works
  • Multiple "quality of life" scripts to make using the asset a breeze
  • Scaleable resources that will adapt to any size graphic used
  • Highly optimised code that culls to the view and (when compiled using the YYC) is blindingly fast
  • Heavily commented scripts and a complete demo to show how it can be used
  • One script saving and loading, so you can create in-game editors, or create your levels and save them to be loaded later

Screenshot 2019-04-24 09.05.17.png Screenshot 2019-04-24 09.16.49.png Screenshot 2019-04-24 09.17.21.png
Screenshot 2019-04-24 09.17.45.png
 
Last edited:

Nocturne

Friendly Tyrant
Forum Staff
Admin
Can you make it look "pixel arty"?
It absolutely can! Simply make sure that texture filtering is disabled, and also call display_reset() with an AA level of 0 and you'll get crisp pixels on the edges (ignore the tank and HUGE button :p )...

Did a very quick and dirty test to make sure, and as you can see, it's fine:

upload_2019-4-24_18-15-38.png

However, there is no option in the asset to set this as on/off so I'll update the asset to include this feature too. :)
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
Thank you very much ❤×1! I always try to make my assets as well commented as possible, specifically so they can be used as a learning tool as well as a game making tool. I hope you have fun with it and that it doesn't disappoint... :)
 
M

mjadev

Guest
very nice !
but I have one problem with html5 demo: sometimes, when pressing the space bar, a small yellow bar is displayed but nothing more and it's not possible to shoot.
It seems that putting the web browser in background (I'm using Chrome) and switching back to it => space bar works again

question: can this asset work in physical and non-physical worlds ?
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
The HTML5 issue is just with input focus... the demo wasn't really designed for Web use, so sorry about that! Simply mouse clicking the canvas when the spacebar doesn't respond should be enough to fix the issue without tabbing away and back though.

As for the physics stuff, I think it _could_ be used in a physics environment, as it simply generates an array to hold the terrain data and not any actual instances... So you could potentially map the terrain to fixtures, although I think that it would be quite difficult to do. So, I guess, the answer is not really, unless you're prepared to put in a fair a bit of work...
:(
 
M

mjadev

Guest
no problem for me
I am more interested in using it in a non-physical world.
and more than use it in a game, it's to understand how it works that interests me :)
 
T

Taddio

Guest
This looks incredibly cool, the collisions seems to be really neat and precise, which is always the problem when I try to do something like that. Will pick it up back at home, you had me with those jumping Panzers, anyway:D

@Nocturne havent they fixed the bug to import .yymp files? Grabbed the asset via itch, but it still doesn't want to drag in the IDE?!? I thought that bug was fixed months(years?) ago? Do you know of a way I can stitch the project together (I have access to every assets if I unzip the yymp)? Using IDE 2.2.2.413 and runtime 2.2.2.326
 
Last edited by a moderator:

superJ

Member
Nice Work! I have bought this asset and I am trying to figure out how to make the damage effect smaller; as if it was hit by a bullet instead of shot by rocket. Any Ideas? thanks : )
 

superJ

Member
Nice Work! I have bought this asset and I am trying to figure out how to make the damage effect smaller; as if it was hit by a bullet instead of shot by rocket. Any Ideas? thanks : )
never mind.. I found it
GML:
terrain_remove_circle(x, y, holesize);
thanks : )
 

superJ

Member
Sorry because I have to ask again.. but this time with a new question.
I am wondering how can I change the behaviour of the rocket to be like a grenade... so instead of destroying itself immediately when it collides; I want it to bounce or slip or just settel depending on the terrain situation

I can understand the code under the step of the object obj_terrain_demo_bomb but as I said, it just destroy it self whenever it collide.
GML:
vspeed += 0.1;

if terrain_collision(x, y)
    {
    var holesize = terrain_get_scale() * 1.5;
    var holesize = terrain_get_scale() * 0.1;
    terrain_remove_circle(x, y, holesize);
    var _o = instance_create_layer(x, y, "Instances_Effects", obj_Terrain_DEMO_Explosion);
    _o.image_xscale = holesize * 3 / sprite_get_width(_o.sprite_index);
    _o.image_yscale = holesize * 3 / sprite_get_height(_o.sprite_index);
    _o.image_angle = random(360);
    var _s = audio_play_sound(snd_Terrain_DEMO_Explode, 0, false);
    audio_sound_pitch(_s, 0.8 + random(0.4));
    
    for (var a = 0; a < 12; ++a;)
        {
        with (instance_create_layer(x, y, "Instances_Effects", obj_Terrain_DEMO_Pieces))
            {
            image_index = a;
            tile_sprite = terrain_get_texture();
            tile_index = 0;
            }
        }
    
    
    instance_destroy();
    }

image_angle = point_direction(xprev, yprev, x, y);

xprev = x;
yprev = y;
I would appreciate any help
cheers!
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
Hello! right now I'm actually on holiday and have no access to GameMaker or my assets... and it's been a while since I worked on this!!! On a general note I can say that you will need to change the contents of the "terrain_collision" check to be able to bounce. Like, check for a collision, then get the collision normal and use that to calculate the angle of reflection for the bounce. Maybe have a counter variable that increments each bounce then explodes the instance when it reaches 5 or something.

Hopefully that can help push you in the right dircetion, but if you are still having problems I'll be back home in about 5 days and can sit down with the asset code in front of me and craft you a more explicit answer.

All the best!
 
Top