Jump to content


Photo

Terrain Dll (destructible Terrain)


  • Please log in to reply
23 replies to this topic

#1 39ster

39ster

    GMC Member

  • GMC Member
  • 898 posts

Posted 27 June 2009 - 05:25 PM

This dll can be used to create games that require destructible terrain. It is best used with surfaces (as demonstrated in the example).

How it works:
You create a new terrain with terrain_create(width, height); width/height would usually refer to the pixel resolution
You can remove parts of the terrain with terrain_unset_point, terrain_clear_circle, terrain_clear_rect, terrain_clear_line.
You can check for collisions with terrain_get_point, terrain_collision_circle, terrain_collision_rect, terrain_collision_line.

Features:
-Small memory foot print. Uses 1 bit for 1 point (pixel).
-Pretty fast.
-Make holes for rectangles, circles and lines.
-Check collisions with rectangles, circles and lines.
-Liero style example included.

Posted Image

EDIT: New update:
New scripts terrain_fill_rect, terrain_fill_circle, terrain_fill_line
You can also save the terrain to a file with terrain_save and load a terrain from a file with terrain_load
The example is also updated and has more features including a mini gun (ctrl to shoot. bullets destroy terrain). You can save the level by pressing F12 and load the level by pressing F11 (this will save both an image of the surface and the terrain file)

...and it's a .zip file instead of .rar

Edited by 39ster, 28 June 2009 - 09:54 AM.

  • 0

#2 TheMagicNumber

TheMagicNumber

    GMC Member

  • GMC Member
  • 5247 posts
  • Version:Unknown

Posted 27 June 2009 - 05:56 PM

Wow, that's pretty awesome. It was actually fairly fast for my computer, running at just under 40FPS. Your example could use some work. :D

Also, upload a ZIP for the people without WinRAR.
  • 0

#3 Revel

Revel

    ɹǝqɯǝɯ ɔɯƃ

  • GMC Member
  • 4935 posts
  • Version:GM8

Posted 27 June 2009 - 06:04 PM

Yet another amazing release by 39ster:) Great job!


I think this is the first destructible terrain demo that works on my computer!

Edited by Revel, 27 June 2009 - 06:06 PM.

  • 0

#4 MitchGraham

MitchGraham

    GMC Member

  • Banned Users
  • 524 posts

Posted 27 June 2009 - 08:38 PM

I'm a little confused. Other than lower memory management, what does this offer over using a surface and grid combination to handle visuals and collisions?

Unfortunately you have a .rar, probably with a .gmk inside, neither of which this computer can or will ever be able to use. Because of this, I can't hazard a guess. However, I'm making logical assumptions off of your description as to how it works. (Which, in itself, is a good clue that you wrote a respectable opening post for it, by the way.)

#5 MrOpposite

MrOpposite

    Yesterdays games

  • New Member
  • 744 posts

Posted 27 June 2009 - 08:42 PM

I'm a little confused. Other than lower memory management, what does this offer over using a surface and grid combination to handle visuals and collisions?

Unfortunately you have a .rar, probably with a .gmk inside, neither of which this computer can or will ever be able to use. Because of this, I can't hazard a guess. However, I'm making logical assumptions off of your description as to how it works. (Which, in itself, is a good clue that you wrote a respectable opening post for it, by the way.)

Just downloaded it, the files inside are GM6... PM me if you want me to send it to you "zipped"

Well the dll works really well, and it ran at 60fps. Good work!
  • 0
I'm working on a new project. The project name is "Timeline"

Reinventing the wheel is stupid, but stealing a car is illegal.

#6 Nixa

Nixa

    GMC Member

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

Posted 27 June 2009 - 09:18 PM

Works great, 60 fps!

For some reason blend mode in dig script didn't work...

I think this is the first destructible terrain demo that works on my computer!

Totally ^^
  • 0

Any questions related to GM? PM me ;)

Sudoku Puzzles [Download]


#7 WadeMcGillis

WadeMcGillis

    wademcgillis.com

  • GMC Member
  • 971 posts

Posted 28 June 2009 - 12:46 AM

That was quick. It ran at 60 fps on my computer

Specs:
Vista Home Premium
1 GB RAM
2.1 Ghz dual-core processor
  • 0

#8 39ster

39ster

    GMC Member

  • GMC Member
  • 898 posts

Posted 28 June 2009 - 02:49 AM

Wow, that's pretty awesome. It was actually fairly fast for my computer, running at just under 40FPS. Your example could use some work. :D

Also, upload a ZIP for the people without WinRAR.



40FPS? If i change the room_speed to 9999, it runs at 2500FPS when not digging and moving, 2000FPS when both digging and moving. That's on a 4 year old pentium 4...

MitchGraham


I'm sorry i don't know of any surface + grid combination in GML. This rar comes with two .gm6 file (one is a liero style example), the dll,. gml file and C++ source code. I don't know why you can't open .rar but there is no .gmk

Edited by 39ster, 28 June 2009 - 03:18 AM.

  • 0

#9 Postality

Postality

    GMC Member

  • New Member
  • 244 posts

Posted 28 June 2009 - 03:12 PM

This is a very nice addition to my add-ons collection for GM.

Thanx alot 39ster

Edited by Postality, 28 June 2009 - 03:13 PM.

  • 0

#10 TheMagicNumber

TheMagicNumber

    GMC Member

  • GMC Member
  • 5247 posts
  • Version:Unknown

Posted 28 June 2009 - 04:52 PM

40FPS? If i change the room_speed to 9999, it runs at 2500FPS when not digging and moving, 2000FPS when both digging and moving. That's on a 4 year old pentium 4...

I have a 1.7GHz P4, about six years old. :P Yes, I do need a new computer.

It's still fairly good for my horrible computer.
  • 0

#11 Revel

Revel

    ɹǝqɯǝɯ ɔɯƃ

  • GMC Member
  • 4935 posts
  • Version:GM8

Posted 28 June 2009 - 04:56 PM

My computer is worse than yours GMREC, and my fps was 10 more than yours :P
  • 0

#12 cloudcry

cloudcry

    GMC Member

  • New Member
  • 154 posts

Posted 29 June 2009 - 02:20 PM

7zip is a free program that can extract just about anything, espicallt RARs, just search it on google. I'm surprised more don't know about it. :D
  • 0

#13 MrOpposite

MrOpposite

    Yesterdays games

  • New Member
  • 744 posts

Posted 30 June 2009 - 01:34 PM

7zip is a free program that can extract just about anything, espicallt RARs, just search it on google. I'm surprised more don't know about it. :P

What's wrong with winrar :P
  • 0
I'm working on a new project. The project name is "Timeline"

Reinventing the wheel is stupid, but stealing a car is illegal.

#14 freko

freko

    The Professional

  • GMC Member
  • 504 posts
  • Version:GM8

Posted 07 July 2009 - 09:11 AM

This is a great dll. I like it.

7zip is a free program that can extract just about anything, espicallt RARs, just search it on google. I'm surprised more don't know about it. ;)

What's wrong with winrar :)


Nothings wrong with winrar. Its just that these folks are old fashioned.
  • 0

#15 IamCalle

IamCalle

    GMC Member

  • GMC Member
  • 444 posts

Posted 12 July 2009 - 03:07 AM

Your engine is great and the fastest I have come over, yet. Good work.
Earlier (some weeks ago, I guess), the terrain was rendered invisible in the example, but all works well now. :P
When removing the 60 fps limit (I got a steady 60 fps btw), I got app. 3400 fps while doing nothing, and app. 200 fps when destroying parts of the terrain by "shooting" it, definitely a nice engine. :P

Edited by IamCalle, 12 July 2009 - 03:08 AM.

  • 0

#16 ydawg314

ydawg314

    GMC Member

  • New Member
  • 901 posts
  • Version:Unknown

Posted 13 July 2009 - 05:40 PM

While this is a great engine which is super fast, I wish that it had some better physics. For example there are no slope physics.
  • 0
Check out my newest game Redesigned from scratch!
Posted Image
Download Mobile Suit Grunt Wars.zip W.I.P 7-26
TEST YOUR MECH PILOTING SKILLS!!!
Spoiler

#17 RamboFox

RamboFox

    Tainted Fortune

  • New Member
  • 992 posts

Posted 21 July 2009 - 02:45 AM

Thanks. Now my project for fast DT is not needed anymore :P

:D

Very nice - makes my DT method useless now that you have a faster method.

Still, scripts can be ported into this one (as you have collision checking scripts and such) - so my project isn't completely dead.

While this is a great engine which is super fast, I wish that it had some better physics. For example there are no slope physics.

This is about DT, not physics.

Edited by RamboFox, 21 July 2009 - 02:47 AM.

  • 0

#18 databot

databot

    admin of moonlight games

  • New Member
  • 309 posts

Posted 22 July 2009 - 05:06 PM

Holy crap DT that's GM6 compatible!
You sir have my up most respect.

Greta job and a fantastic DLL.
  • 0
Completed:
Scrip - Command line engine in the palm of your hands Get it Here
XML - XML simplified

#19 databot

databot

    admin of moonlight games

  • New Member
  • 309 posts

Posted 10 August 2009 - 07:28 PM

sorry for the double post, (last one was 18 days ago).

I have finally finished a little dev tool for terrain building I've made using the dll and vb .net.

Posted Image

To use:

1) create a bitmap for your backbround, how ever you want.
2) generate a mask version with a single color for open areas, and color the bottom left pixel this color.
3) use the tool and load the mask bitmap, and select a file to save to.
4) click encode and wait for it to finish.
5) your done!, use the terrain file along side the background bitmap in your game!.

notes about the program:

- While the main loop took 5 minutes to write, It took 3 days squashing bugs in pixel->terrain x,y translation to perfect.
- no error catching code was written, .net framework will catch them but force program failure, sorry.
- The program uses brute force encoding, so on the example image thats 4,000,000 code cycles to encode it, this means it may take a few minutes to encode on low end machines. I have an idea to decrease time but its not worth debugging unless needed.
- the program is not threaded, and due to the way .net handles the UI freezes because of this. Deal with it or ask for source and i'll upload it for you to tinker with.

comments and constructive critisism welcome.

Edited by databot, 10 August 2009 - 07:28 PM.

  • 0
Completed:
Scrip - Command line engine in the palm of your hands Get it Here
XML - XML simplified

#20 qw5628

qw5628

    GMC Member

  • GMC Member
  • 7 posts

Posted 06 March 2010 - 03:44 PM

uh.. I've got some problem.

If bullet is slow, it okay with terrain_collision_circle. but if fast, bullet sometimes just pass terrain by without collision. So I have to check its movement pixel by pixel, like move contact or collision_line. yeah, there's terrain_collision_line. but beause it doesn't return point of intersect, I have to use terrain_get_point with loop. and it's slower. well.. if there aren't many bullets, it isn't so slow. but in my game, they are many, about 300 instances with speed of 20(total 6000 calls per step, with this way).

As I think, if there's a function that returns point of intersect between line and terrain, it'll be much faster. Thus, would you mind adding such function in Terrain Dll? If you do so, I'll really appreciate you.

Anyway, It's the best Destructible Terrain example I've seen. It's really cool!

Edited by qw5628, 06 March 2010 - 03:52 PM.

  • 0

#21 Salmonman

Salmonman

    GMC Member

  • GMC Member
  • 512 posts

Posted 06 March 2010 - 05:33 PM

is it able to make a terrain at the beginning that is a transparent background? Meaning that if i have a transp;arent background with mountains and stuff on it where there is open space above that, is it possible to use it? Other terrain systems have that.
  • 0
My 3D MMORPG. Its coming. You'll see. YOU'LL ALL SEE!

#22 shawn_mo_mo

shawn_mo_mo

    GMC Member

  • New Member
  • 1 posts

Posted 23 October 2010 - 09:36 AM

The terrain doesn't seem to save properly. When I load it back into my game it comes out jagged. I had a look at the source but I couldn't find a problem. However I think the problem has to do with the RLE encoding.

this is just the surface by itself (green)
http://img145.images...us/i/pic1ea.jpg

this is the surface (green) overlayed with the dll terrain (red)
http://img407.images....us/i/pic2t.jpg

By the way my surface and terrain are 4000*1500 but I hope that's not the problem :unsure:
  • 0

#23 brett14

brett14

    GMC Member

  • GMC Member
  • 1151 posts
  • Version:GM8

Posted 29 October 2010 - 06:10 AM

If I'm not mistaken, there is a maximum resolution of 2048x2048 on your images. That's all GM supports, and this dll was built for gm so...
  • 0

P3DC V6.00 | Editor14 | Large 3D Terrain

GML programmer since 2005, C/C++ programmer since 2009, Java programmer since 2012


#24 Tyrannosaurus rex

Tyrannosaurus rex

    GMC Member

  • GMC Member
  • 498 posts

Posted 31 January 2012 - 08:00 AM

Would there be a way to get this for GM 8.1?
  • 0