The Daily Click ::. Forums ::. Klik Coding Help ::. 3 million tiles?
 

Post Reply  Post Oekaki 
 

Posted By Message

Darkstar



Registered
  27/01/2002
Points
  12
24th June, 2004 at 07:26:44 -

Something I'm working on requires storing just over 3 million tiles (1800x1800) and as of yet I can't sort a way of even filling an array that large. I'm sure somehow you could, so if anyone can think of it, add me on MSN conformnow@hotmail.com talk to me on IRC (]Darkstar[, in #K&p, on irc.blitzed.org) or just reply to this message. Don't ask why I need 3 million tiles, because that's irrelevant and perhaps if you help and become more involved you'll find out anyway. Thanks.

 
-]Darkstar[

Ashman

Possibly Insane

Registered
  12/06/2002
Points
  3974
24th June, 2004 at 07:29:48 -

Holy Crap... that's one big bathroom.

 
Show me the power child,
I'd like to say,
That I'm down on my knees today,
Gives me the butterflies,
Gives me away,
'Til I'm up on my feet again,
I'm feeling outshined.


"Outshined" - SoundGarden

Tigerworks

Klik Legend

Registered
  15/01/2002
Points
  3882
24th June, 2004 at 07:44:18 -

Don't ask why I need 3 million tiles

Why do you need 3 million tiles?

 
- Tigerworks

ChrisB

Crazy?

Registered
  16/08/2002
Points
  5457
24th June, 2004 at 08:00:13 -

Mmm, 12mb of tiles... I recommend you go down the C++ or assembly route if you want to do that in under a minute

 
n/a

Darkstar



Registered
  27/01/2002
Points
  12
24th June, 2004 at 08:39:57 -

I guess I'll have to limit the amount, what's the biggest feasible amount? (Only 10,000 or so will be displayed at any one time, but I need the array to store all the information)

 
-]Darkstar[

Tigerworks

Klik Legend

Registered
  15/01/2002
Points
  3882
24th June, 2004 at 08:41:45 -

What are you doing this for? It sounds VERY inefficient. If you tell us what you are trying to do, we can suggest more efficient ways to do it.

 
- Tigerworks

Darkstar



Registered
  27/01/2002
Points
  12
24th June, 2004 at 08:58:45 -

I sorted out a way to do it, by storing 9 values in each array, the array can be 200x200 (200*9 = 1800, 1800x1800=3,240,000). It's hard to explain what it's for. Basically, it's a tile engine. Each tile is 10x10, each 'sector' is made up of 12 tiles by 12 tiles, and each 'map' is made up of 150 sectors by 150 sectors. That's the size we wanted and so it looks like it'll work out now

 
-]Darkstar[

Cazra

Crazy?

Registered
  24/07/2002
Points
  4472

Game of the Week WinnerVIP Member
24th June, 2004 at 09:19:32 -

You could try a quick backdrop

 
n/a

Muggus

Possibly Insane

Registered
  31/07/2002
Points
  2958
24th June, 2004 at 10:33:52 -

Could you explain in more detail what you want done with so many tiles or whatever?
By the sounds of it you're over complicating something that should be simple.

 
MUGGUS
Come and annoy me more at
www.muggus69.tk
STOUT ANGER!!!

Darkstar



Registered
  27/01/2002
Points
  12
24th June, 2004 at 10:52:47 -

Less a game, more an organizer for a campaign of a tabletop game I play called Micro Armour (WW2 Based). We play it on a map of 4 inch tiles put together to form a 48 inch map, so 12x12. 150x150 of these, 3 million tiles. Although even though I can represent 22,000 sectors that may be a little excessive but atleast I've found a means to do so.

 
-]Darkstar[

Shen

Possibly Insane

Registered
  14/05/2002
Points
  3497
24th June, 2004 at 12:17:15 -

What sort of stuff will go in these tiles? It shouldn't be too hard if you only need to store 5 different values, more so if you need to store 255

 
gone fishin'

Cazra

Crazy?

Registered
  24/07/2002
Points
  4472

Game of the Week WinnerVIP Member
24th June, 2004 at 13:05:41 -

Why not make the tiles from a quick backdrop and then use a grid-based coordinate system?

 
n/a

Kramy



Registered
  08/06/2002
Points
  1888
24th June, 2004 at 13:22:48 -

I think I get what you mean. There's a better way though I think. Professional games like Diablo II and Dungeonsiege load the tiles as you move, so they don't need nearly as much memory.

In Jamagic you could do this by the following method:

Tile = 10x10
Sector = 12x12 tiles (so 120x120)

Load 25 arrays of "sectors" (covering a 600x600 zone)
Assuming you're using 320x240 resolution, and assuming that sectors are labeled like this...

01|02|03|04|05
06|07|08|09|10
11|12|13|14|15
16|17|18|19|20
21|22|23|24|25

As soon as you pass halfway though sectors 02,07,12,17,22, etc., it scraps sectors 05,10,15,20,25, and loads new sectors into memory to the left or 01,06,11,16,21, etc.

In such a way you can avoid having so many tiles in memory at once. Also, only store values in the arrays, then link the values to a tileset.

If you have a 120x40000 tileset, for example, then you would use the following:

TileNum = 43;
XCoord = TileNum%12; // 12 = XSize/Tilesize
YCoord = TileNum/12;

Then copy XCoord*10,YCoord*10 to the screen.

Hope this helps. Oh, and if you actually need 3 million unique tiles, then you're screwed. I don't think even C++ would be able to help you with that very efficiently.

Image Edited by the Author.

 
Kramy

Mr Icekirby



Registered
  18/12/2003
Points
  846
24th June, 2004 at 16:38:39 -

have fun trying though!

 
Mr Icekirby says so!
OBEY ME!

Teapot

Does he even go here

Registered
  02/10/2003
Points
  2631

VIP Member
25th June, 2004 at 21:05:24 -

"Holy Crap... that's one big bathroom."

Ashman is back...probably not though...

 
n/a

Kris

Possibly Insane

Registered
  17/05/2002
Points
  2017
26th June, 2004 at 07:42:23 -

dave, i thought you used blitz? that should be able to handle 3m tiles easily

 
"Say you're hanging from a huge cliff at the top of mt. everest and a guy comes along and says he'll save you, and proceeds to throw religious pamphlets at you while simultaniously giving a sermon." - Dustin G

Tigerworks

Klik Legend

Registered
  15/01/2002
Points
  3882
26th June, 2004 at 09:19:11 -

Even assembly would have a tough time with 3 million tiles. Even if they were small, 16x16 tiles (256 pixels), that's 768,000,000 setpixels to draw them all.
Mind you, you wouldn't draw them all at once. Assembly might be able to iterate all the tiles in a reasonable amount of time (<1ms) but something like Darkbasic is going to be way slower, a lot of speed is lost in interpretation.

Image Edited by the Author.

 
- Tigerworks

Kris

Possibly Insane

Registered
  17/05/2002
Points
  2017
26th June, 2004 at 09:51:15 -

he's not drawing them all at once. He could just code it to only deal with the tiles on the screen

 
"Say you're hanging from a huge cliff at the top of mt. everest and a guy comes along and says he'll save you, and proceeds to throw religious pamphlets at you while simultaniously giving a sermon." - Dustin G

Tigerworks

Klik Legend

Registered
  15/01/2002
Points
  3882
26th June, 2004 at 14:59:50 -

As I said, you would probably still need to iterate all tiles to check which are on screen. Maybe a short wait in assembly but interpretation really kills the speediness of loops (unless you're using something like Java with compile on-the-fly)

 
- Tigerworks

Kris

Possibly Insane

Registered
  17/05/2002
Points
  2017
26th June, 2004 at 18:37:45 -

no you wouldn't

let's say there's a 640x480 screen with 20x15 tiles visible at once (32x32 pix each)


first_blockx = camerax / 32
first_blocky = cameray / 32

last_blockx = first_blockx+20 // not 19, in case there are blocks that are only just on screen
last_blocky = first_blocky+15

for x = first_blockx to last_blockx
for y = first_blocky to last_blocky
...
next
next


Edit: woo lots of edits

Image Edited by the Author.

 
"Say you're hanging from a huge cliff at the top of mt. everest and a guy comes along and says he'll save you, and proceeds to throw religious pamphlets at you while simultaniously giving a sermon." - Dustin G

Kramy



Registered
  08/06/2002
Points
  1888
28th June, 2004 at 12:46:01 -

Because that would use a minimum of 183.10546875mb of ram.

 
Kramy

ChrisB

Crazy?

Registered
  16/08/2002
Points
  5457
28th June, 2004 at 14:43:42 -

Wow, I'd hate to see how you allocate your memory. Anyway, I thought he wanted to do something with EVERY tile, not just the ones on screen which is easy-peasy to do?

 
n/a

Kramy



Registered
  08/06/2002
Points
  1888
29th June, 2004 at 00:08:53 -

10x10 tile. That's 100 pixels, which is roughly 400 bytes.(int for each colour value?)

Ok...you want 3 million of those loaded into memory at once? Not a good idea...

 
Kramy
   

Post Reply



 



Advertisement

Worth A Click