Jump to content


Photo

Destroyable Terrain


  • Please log in to reply
9 replies to this topic

#1 Rani_sputnik

Rani_sputnik

    GMC Member

  • GMC Member
  • 482 posts
  • Version:GM:Studio

Posted 27 October 2015 - 09:56 PM

s4pdnq.jpg

 

Easily add 2d destructible terrain to any game with this library. Lightning fast performance and tonnes of flexibility makes this library the perfect choice for anyone wanting more than just blocks out of their terrain. Get started quickly and easily;

var cell_size = 16; 
global.terrain = terrain_create(cell_size); 

Make sure to draw it;

terrain_draw(global.terrain);

Add a starting block of land;

// Density is between 0 (no ground) and 1 (ground)
var density = 1; 
// Create terrain over the bottom half of the terrain grid
var left = 0;
var top = terrain_grid_get_height(global.terrain) / 2;
var right = terrain_grid_get_width(global.terrain);
var bottom = terrain_grid_get_height(global.terrain);
terrain_density_set_region(global.terrain,left,top,right,bottom,density);

Set a texture for the ground;

terrain_image_set_background(bgDirt);

Simple as that!

 

Links

Roadmap

  • v0.2 - Initial release
  • v0.3 - Terrain edge tracing and physics volume (for use with box2d)
  • v0.4 - Redraw speedups by limiting redraws to a single pass per frame
  • v0.5 - HTML5 support
  • v1.0 - Show time!

Why free & paid?

 

You may be asking "Why pay for this when I could just get it free from Github?" I hate keeping code behind a paywall but I also have to eat too! Think of this offering as a try-before-you-buy situation. It would be great if you can buy the extension, it supports me and helps me keep giving away code but if you feel you can't afford it, you could always fork the project, make improvements and help bug fix! Any support is appreciated.

 

Credit

 

Based on the foundation work of Ilari Lähteinen (TeBe). See the original post here.


Edited by Rani_sputnik, 30 October 2015 - 03:26 AM.

  • 6

My games - In DecemberBoy Goes to Space

Utilities & Extensions - FloxGM, Destroyable Terrain

Check out my website: ryanloader.me, or follow me: twitter.com/RaniSputnik


#2 jaimitoes

jaimitoes

    GMC Member

  • GMC Member
  • 247 posts
  • Version:GM:Studio

Posted 28 October 2015 - 12:23 AM

Amazing! possibilitys are a lot! Worms gameplay style and more!!


Edited by jaimitoes, 28 October 2015 - 12:24 AM.

  • 0

#3 JeffJ

JeffJ

    GMC Member

  • GMC Member
  • 527 posts
  • Version:GM:Studio

Posted 28 October 2015 - 04:34 AM

This is awesome - and I greatly respect that you've made it freely availabe. That's amazing.

 

Upon trying the demo, the first thing I did was to alt+enter the game into fullscreen, which immediately removed visibility of all terrain. I'm assuming this is due to the use of surfaces, but is there any way around this? It wouldn't be optimal to be unable to switch between screen modes without losing visibility of all terrain data. It's still there, as it will regain visibility if I "paint" over it once again, but it would be nice if the engine handled that automatically.


  • 0

spoileralertsignature.png     jefftwittersignature.png


#4 Rani_sputnik

Rani_sputnik

    GMC Member

  • GMC Member
  • 482 posts
  • Version:GM:Studio

Posted 28 October 2015 - 09:14 PM

Thank you both for the kind comments,

 

@Thaudai, thanks for pointing that out! I'll jump on it. I planned to have a redraw triggered when you tried to draw the terrain with no surface present, but it was tied up in optimising the way redraw is handled (currently the same patch of terrain may be redrawn multiple times in a single frame, I hope to fix that at the same time.)

 

@Jaimitoes, there certainly is lots you can do! I plan to do a mini-map example, a cortex command style cutaway style and a box2d collisions example. If you have some other ideas as to what you'd like to see, please do let me know!

 

Cheers, Ryan.


  • 1

My games - In DecemberBoy Goes to Space

Utilities & Extensions - FloxGM, Destroyable Terrain

Check out my website: ryanloader.me, or follow me: twitter.com/RaniSputnik


#5 JeffJ

JeffJ

    GMC Member

  • GMC Member
  • 527 posts
  • Version:GM:Studio

Posted 30 October 2015 - 02:39 AM

Sounds awesome man.

 

As for other ideas - this isn't really an "idea" as such, but if it's something you would be up to doing at some point, I would love to see how you'd make the player movement and collision compatible with an easily scalable movement system that is based on acceleration ad de-acceleration rather than static movement. I realize this may be out of scope as your focus is obviously on the terrain, so that's totally cool - just a suggestion. It could even be a switch, just to show that the terrain can collide with both styles of movement.

 

Other than that, my initial thoughts are Minecraft-like games that finally breaks completely free of the whole block-based nature, and roams into a much more dynamic style. By the way, on that subject, how big would you recommend as a maximum room size using this? And would it be possible to build a big open world terrain with this by "deactivating" parts of the terrain when not visible? Because I'm thinking that a large, procedurally generated open world terrain for a 2d sidescroller would be freaking awesome using something like this. Especially if you could get a nice smooth and flexible movement system up and running with it. You know, something that uses speed for movement and is easy to modify (things like how steep a hill the player can climb, with the de-acceleration in speed it would mean for his movement and so on).

 

EDIT:

Come to think of it, being able to use this with the box2d physics system would be incredible, although that's probably a tad unrealistic. :P


Edited by Thaudal, 30 October 2015 - 02:41 AM.

  • 0

spoileralertsignature.png     jefftwittersignature.png


#6 Rani_sputnik

Rani_sputnik

    GMC Member

  • GMC Member
  • 482 posts
  • Version:GM:Studio

Posted 30 October 2015 - 03:26 AM

@Thaudal It's really gratifying to hear your suggestions, we are right along the same line of thinking!

 

Right now you totally can do something like a Minecraft chunk style in a couple of different ways. The most common (and easiest) way to use the library is to have a single terrain object. But there's one problem, if you're doing a massive world your drawing surface gets really big. Enter a really handy script terrain_set_visible_view. You give it a view, it will ensure that only the terrain inside your view is actually redrawn! Awesome!

 

If you want a truely infinite world, then you can actually create more than one terrain object and activate / deactivate as necessary - that would actually make a really sick example so I'll note it down. I haven't actually tested how well this works yet, but I will make sure that it's all up and running for v1 of the library.

 

As for the box2d physics, that's coming up soon, I just gotta get the ground work laid first.

 

Also added full api docs to the topic.


  • 1

My games - In DecemberBoy Goes to Space

Utilities & Extensions - FloxGM, Destroyable Terrain

Check out my website: ryanloader.me, or follow me: twitter.com/RaniSputnik


#7 JeffJ

JeffJ

    GMC Member

  • GMC Member
  • 527 posts
  • Version:GM:Studio

Posted 31 October 2015 - 12:16 PM

Holy **** man, I wasn't really expecting that. I really can't wait to see those changes! Keep us posted. :)


  • 0

spoileralertsignature.png     jefftwittersignature.png


#8 john73

john73

    GMC Member

  • New Member
  • 1 posts
  • Version:GM:Studio

Posted 16 March 2016 - 09:43 AM

As for the box2d physics, that's coming up soon, I just gotta get the ground work laid first.

 

 

Any update regarding the physics ?


  • 0

#9 Rani_sputnik

Rani_sputnik

    GMC Member

  • GMC Member
  • 482 posts
  • Version:GM:Studio

Posted 19 March 2016 - 06:14 AM

Hey John, 

 

unfortunately my schedule isn't as flexible as it once was. I'm not sure of a timeframe but I don't expect I'll get this done any time soon, I don't want to make a promise I can't deliver!

 

For the record the implementation plan is as follows;

  • Implement common vertices - so neighbouring vertices that occupy the same position know about one another
  • Landmass formation - follow the path of joined vertices to create enclosed shapes from the terrain
  • From there generating box2d static colliders becomes trivial - difficulty will be handling new terrain painting and dealing with the whacky collisions that result from it.

I'll let you know if/when I have any updates.

 

Cheers, R.


  • 1

My games - In DecemberBoy Goes to Space

Utilities & Extensions - FloxGM, Destroyable Terrain

Check out my website: ryanloader.me, or follow me: twitter.com/RaniSputnik


#10 JeffJ

JeffJ

    GMC Member

  • GMC Member
  • 527 posts
  • Version:GM:Studio

Posted 19 March 2016 - 07:05 PM

Sure hope to see more updates in the direction of what we discussed earlier in this thread. I would easily drop a good chunk of money on a complete package solution like that.


  • 0

spoileralertsignature.png     jefftwittersignature.png