|
-
Apr 23rd, 2010, 01:36 PM
#1
Thread Starter
Addicted Member
I think I am, therefore, I am. I think.
-
Apr 23rd, 2010, 02:02 PM
#2
Re: 2D Terrain Without using 500 000 kB of Memory
An array of that size and data type will take up that much memory... but so would the non-tile alternative of a picture file of 11550*11550 pixels (roughly 10 monitors wide and high).
If memory is a concern, either make the map much smaller, or use tiles of a "decent" size. If you want people to be able to make maps, create a tile based map editor (possibly allowing them to create their own tiles too).
-
Apr 23rd, 2010, 02:25 PM
#3
Re: 2D Terrain Without using 500 000 kB of Memory
I'm not sure why you couldn't use tiles anyway. Let's say your tiles were 16x16 and a user gave you a 100x100 image to use. Well, 16 doesn't divide into 100 evenly, but it does divide in to 112 evenly... Draw their image over a 112x112 default background, split that new image into 16x16 tiles and use those new tiles. Just an idea.
Last edited by LaVolpe; Apr 23rd, 2010 at 02:28 PM.
-
Apr 23rd, 2010, 05:57 PM
#4
Re: 2D Terrain Without using 500 000 kB of Memory
Just to add...
I imagine games such as Worms don't use 1x1 tiles, rather they use a monochrome 1bpp (bits per pixel) mask. If an arbitrary bit of landscape is destroyed nothing happens to the tiles (which could be quite big) instead a hole is cut in the mask. Using a monochrome mask gives you 8 pixels for every byte, that's 32 times smaller in memory than using a 32bit Long for each pixel.
There are many raster operations that can be used to render graphics. Normally if a graphic and mask are matched then it can be rendered in two phases (AND & OR). If the graphic and mask are not matched (i.e. the bits of the graphic not to be rendered are not black) then you need to pre-render the graphics to a buffer, apply an inverted mask (to make the bits not to be rendered black), then do the usual AND OR rendering to the screen buffer.
make any sense?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|