Hi !
Featured games (87)
games approved by the League of Dukes
Games in Showcase (672)
Games in Android Showcase (194)
games submitted by our members
Games in WIP (727)
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 2081 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: 422
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: 726
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.

IanParcs (48 views)
2016-04-18 14:18:53

KaiHH (46 views)
2016-04-18 08:35:41

KaiHH (76 views)
2016-04-15 12:43:58

theagentd (79 views)
2016-04-14 02:16:17

theagentd (94 views)
2016-04-14 02:15:43

IanParcs (106 views)
2016-04-12 03:51:16

IanParcs (48 views)
2016-04-12 03:50:03

IanParcs (44 views)
2016-04-12 03:49:54

IanParcs (39 views)
2016-04-12 03:49:52

IanParcs (49 views)
2016-04-12 03:49:52
Website offering 3D Models specifically for games for free
by vusman
2016-04-29 12:56:17

List of Learning Resources
by SilverTiger
2016-02-05 09:39:47

List of Learning Resources
by SilverTiger
2016-02-05 09:38:38

List of Learning Resources
by SilverTiger
2016-02-05 09:35:50

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 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!