Worms-style terrain

Monkey Forums/Monkey Programming/Worms-style terrain

misterSquare(Posted 2012) [#1]
Hi all - I'm fairly new to Monkey, so apologies in advance for any daft questions!

I'm interested in creating a Worms-style terrain engine for the game I'm currently working on - so you'd have a big land mass that you can dynamically blow chunks out of. Doing a bit of research online, and there seem to be quite a few suggested techniques for achieving this - the simplest being to punch holes in an image by explicitly masking out pixels in the source texture. Having had a dig around in the monkey code, it doesn't appear like there's any support for anything like that (ie. directly manipulating pixels in a texture) at the generic language level, although it could feasibly be added with a bit of modification to the various native platform code files.

Before I continue down this road, I was just wondering if anyone else ever tried tackling these problems in Monkey before? (either the terrain issue, or runtime texture modification). If so, do you have any advice/tips/warnings/words of wisdom?


Raz(Posted 2012) [#2]
I could be completely wrong here, but this is based on my own understanding of Monkey and the types of things I believe it can let you do (this obviously ignores modifying targets etc).

Image manipulation isn't possible.
Per pixel collisions are not possible.

You could generate a map in a 2d array and modify each pixel as required (you could artificially texture the world by applying colours to each pixel). I imagine this would be very slow to render, but would be a nice simple way of managing collisions.

You could do things in reverse. Have a solid repeating texture for the whole level/screen and then draw "holes" on top of it. All of the in game items would be free to move as long as they are overlapping a hole, if they are not, they've hit a solid edge/wall.

Over all though I wouldn't say Monkey is a realistic target (yet?) for such a game.


Paul - Taiphoz(Posted 2012) [#3]
Before I started Term, I was planning to port my Sheep Blaster game over to monkey, which was my worms clone but with sheep, when I realized what I would have to do I opted for another project.

I looked at drawing holes, but your left with big black circles all over the place, which render over the top of your backdrop which looks daft, I was left with sky with black holes all over it.

Another option I looked at was to render my world in 3*3 blocks, I draw a world/level, and then used loadanim to chop it up into a strip, I then took this into an array to render it out on the game world, this worked and I could set visible true or false for any of the array elements so I could blow the crap out of it.

But it was just not the same, and I really didnt like the feel it game to the game, but this might not be something your bothered with so could be a possible solution for you.

I dont really know the deep background and under the hood stuff with monkey but I recall laughing when I realized that a brand spanking new language like monkey could not do something that I guess I was taking for granted with max and blitz3d, pixel drawing and pixel perfect collisions.

maybe mark will surprise us at some point with a cool update to allow such things, in the mean time good luck with what ever method you go for, and be sure to let us know if you actually manage to get it working.


misterSquare(Posted 2012) [#4]
Thanks for the replies guys - I was suspecting as much. Yeah, Taiphoz, that seemed to be the other sort of approach that people were suggesting - as you say though, its less than ideal, and doesn't sound particularly friendly towards mobile devices (from a memory/rendering point of view). Will mull the idea over and post back here if I decide to pursue it.

cheers!


Gerry Quinn(Posted 2012) [#5]
The issue is with mojo not Monkey. mojo targets only things that work on all target platforms. If you want something else you will have to write native code for your target platforms (unless someone has already done so, have a dig around just in case). Then you can probably hack it into mojo if you want to use them simultaneously.

Of course the code related to modifiable terrain is likely to be only a small part of any given game, so you could still do everything else in Monkey/mojo if you wanted.