Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (522)
Games in Android Showcase (127)
games submitted by our members
Games in WIP (590)
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 1692 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: 355
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: 361
Projects: 2
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.

Myomyomyo.
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.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

trollwarrior1 (29 views)
2014-11-22 12:13:56

xFryIx (71 views)
2014-11-13 12:34:49

digdugdiggy (50 views)
2014-11-12 21:11:50

digdugdiggy (44 views)
2014-11-12 21:10:15

digdugdiggy (38 views)
2014-11-12 21:09:33

kovacsa (62 views)
2014-11-07 19:57:14

TehJavaDev (67 views)
2014-11-03 22:04:50

BurntPizza (64 views)
2014-11-03 18:54:52

moogie (80 views)
2014-11-03 06:22:04

CopyableCougar4 (80 views)
2014-11-01 23:36:41
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
java-gaming.org 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‑gaming.org
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!