deform terrain example - is this useful ?

BlitzMax Forums/BlitzMax Beginners Area/deform terrain example - is this useful ?

QuietBloke(Posted 2007) [#1]
I was just mucking about this evening trying stuff out on my oldest machine mostly to work out whether I could do realtime deforming of a terrain ( like the worms games ) and I ended up with this test code showing how not to do it ( using 1 huge image ) and how it could be done ( using tiled images ). Move the mouse around while pressing left mouse button to erase parts of the image.
Constants define the size of the tiles and how big a block to erase so I could try various combo's.

Is this something anyone else might find useful ?.. I was just gonna shove it up in the code archives but I thought Id see whether its actually worthy.. or whether it would be a waste of space.




ImaginaryHuman(Posted 2007) [#2]
1. I get 1116fps non-drawing and 23fps drawing
2. I get about 980fps non-drawing and around 650fps drawing

Your second one is definitely faster because you're only capturing and changing small images, it's a much better scheme.

I think that because the mouse input does not update faster than whatever its hz rate is - 60Hz like the desktop? - when your framerate is over 60hz on the drawing it is actually drawing the same rectangle to the same coordinates for several frames, rather than having enough fine-grained mouse input to draw lots of inbetween positions. So you can't really get a feel for how much faster the second routine is since the mouse input speed makes it seem slower than it is.

I think in general its a pretty decent method for handling this kind of modification to land, and you're on the right track with modifying portions of various images by drawing across image boundaries. The question is now how many image tiles are you going to use and are you going to keep them all in video ram at the same time?


rockford(Posted 2007) [#3]
I get a Compiler error -

"Compile Error
Identified 'ClearPixels' not found"

What am I missing? I'm using BMax 1.24


Perturbatio(Posted 2007) [#4]
ClearPixels is part of BRL.pixmap, a standard module.

You could try rebuilding the modules...


tonyg(Posted 2007) [#5]
... and a syncmods


QuietBloke(Posted 2007) [#6]
I guess my next test will be to create a tilemap larger than the screen and allow scrolling as well.
Im afriad I dont quite understand how I can decide how many images I will store in Video Ram.
Could someone point me to a 'simple to understand' example of doing this ?
I assumed when you create a TImage it automatically gets sent to video ram and the video card determines which old / unused images it will discard internally if it runs low on space. I didnt know there was a way to force images to be held in the video ram.

The compile error is a mystery to me. The code is not doing anything fancy.. in fact I always try to make a point of only ever using the built in functions. As suggested it may be you are not using the latest modules.


ImaginaryHuman(Posted 2007) [#7]
Please be aware that the minimum size for an `image` in video ram is 64x64 pixels. If you have tiles which are small, like say 32x32, it will use 4 times as much memory as it needs to to store that image tile.

Any images you create will be stored in video ram, up to the available video ram space.

There is no simple to understand example. What you want to do is not simple. You really need to distribute your tiles across multiple images and have `sub images` within each to represent individual tiles. You then need a way to modify individual tiles within images. If you want a game world which is much larger than the screen it's possible you wont have enough video ram to store it.


MGE(Posted 2007) [#8]
140fps on both demos in non erase mode. Other wise 57 for first and 130fps on the 2nd. 640x480 is very small. 800x600 or greater full screen rendering is more realistic, and then you have graphics on top, sprites, huds, etc, etc. Like the idea, though, very nice!