Hi !
Featured games (85)
games approved by the League of Dukes
Games in Showcase (636)
Games in Android Showcase (178)
games submitted by our members
Games in WIP (685)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Efficiency with tiled maps  (Read 2000 times)
0 Members and 1 Guest are viewing this topic.
Offline jammas615

Junior Devvie

Projects: 1

« Posted 2011-12-28 05:16:33 »

 Just curious,
Is having a tile class which controls what it renders and an instance of that class for EVERY tile bad design.
Is there a better way?

Offline Mads

JGO Ninja

Medals: 26
Projects: 3
Exp: 6 years

One for all!

« Reply #1 - Posted 2011-12-28 05:26:59 »

If you're storing a picture of the tile on every object, when most of them are similar, you could just give it a stamp and retrieve the image corresponding to that stamp when drawing.

Offline ra4king

JGO Kernel

Medals: 409
Projects: 3
Exp: 5 years

I'm the King!

« Reply #2 - Posted 2011-12-28 05:28:46 »

That's the best and easiest design if you want each tile to control its own data. This way you could also take advantage of polymorphism and have subclasses of Tile that have specialized features.

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline jammas615

Junior Devvie

Projects: 1

« Reply #3 - Posted 2011-12-28 08:02:43 »

But memory-wise it would get ridiculous if you had massive maps all loaded at once, which could he solved by loading tiles as you need them, but would that slow things down?

Offline tw0v

Junior Devvie

Medals: 1
Projects: 1

« Reply #4 - Posted 2011-12-28 08:05:50 »

not if it's a small-scale project.

edit: you could just load the images from a map class while each tile references that object, saves a lot of memory.

Programming for better games.
Offline theagentd

« JGO Bitwise Duke »

Medals: 575
Projects: 4
Exp: 8 years

« Reply #5 - Posted 2011-12-28 08:48:56 »

not if it's a small-scale project.

edit: you could just load the images from a map class while each tile references that object, saves a lot of memory.
Assuming there is no per-tile data, yes.

Offline ReBirth
« Reply #6 - Posted 2011-12-28 12:52:47 »

Sometime people store data per tile like what item on that tile or effect of a tile to character.

Offline sproingie

JGO Kernel

Medals: 202

« Reply #7 - Posted 2011-12-29 02:23:08 »

I've been playing with various tile engine designs, and I've settled on Tiles being simple immutable value objects, just an index into a Tileset, which both holds the TileTexture and maps names to Tile instances (the TileTexture is basically a spritesheet that the tile is indexing).  A Tile can also contain color information if I want to override the color on any specific tile, but otherwise it's a simple lightweight affair.  

All the actual opengl drawing commands are issued by a DisplayLayer, which contains a Tileset and a list of tiles.  This keeps the drawing code in one place, which makes it easier to optimize.  DisplayLayers can also contribute other things like a default color and blend mode, which makes stuff like moving a semi-transparent cursor around a simple matter of making a UI display layer I can enable and disable.

Tiles are strictly graphical in purpose for me, they don't contain game information, so I maintain separate 2d arrays for the game state, and just define a function to render a region of that gamestate array onto a tile display.
Pages: [1]
  ignore  |  Print  
You cannot reply to this message, because it is very, very old.

Dwinin (58 views)
2015-11-07 13:29:08

Rems19 (72 views)
2015-10-31 01:36:56

Rems19 (63 views)
2015-10-31 01:32:37

williamwoles (101 views)
2015-10-23 10:42:59

williamwoles (87 views)
2015-10-23 10:42:45

Jervac_ (102 views)
2015-10-18 23:29:12

DarkCart (128 views)
2015-10-16 00:58:11

KaiHH (112 views)
2015-10-11 14:10:14

KaiHH (148 views)
2015-10-11 13:26:18

BurntPizza (162 views)
2015-10-08 03:11:46
Rendering resources
by Roquen
2015-11-13 14:37:59

Rendering resources
by Roquen
2015-11-13 14:36:58

Math: Resources
by Roquen
2015-10-22 07:46:10

Networking Resources
by Roquen
2015-10-16 07:12:30

Rendering resources
by Roquen
2015-10-15 07:40:48

Math: Inequality properties
by Roquen
2015-10-01 13:30:46

Math: Inequality properties
by Roquen
2015-09-30 16:06:05

HotSpot Options
by Roquen
2015-08-29 11:33:11 is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!