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 (589)
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  
  Tile design problems  (Read 2135 times)
0 Members and 1 Guest are viewing this topic.
Offline opiop65

JGO Kernel


Medals: 159
Projects: 7
Exp: 3 years


JumpButton Studios


« Posted 2013-10-03 09:41:47 »

So I've been trying out this new system where you create a tile once and make it static, and then I set the tiles in an array to that static tile, so its the same instance of the tile. Then, I tried to do lighting, and it didn't work, because since its all the same tile, all the tiles have the same data, I can't modify individual tiles. I was wondering if there was a way to get around this? Or do I just have to suck it up and create a new tile instance for every position in the array?

Offline Jeremy
« Reply #1 - Posted 2013-10-03 11:03:36 »

Don't worry about the instance count of your Tile objects, as long as they don't carry around a lot of exclusive data with them. Just make sure they (the instantiated tiles) share references for their members wherever possible.

For example, if you have two grass tiles, they should both reference the same spritesheet from which they gather their tile graphic.

JevaEngine, Latest Playthrough (This demo is networked with a centralized server model)

http://www.youtube.com/watch?v=rWA8bajpVXg
Offline wessles

JGO Wizard


Medals: 74
Projects: 4
Exp: 4 years


Radirius Software


« Reply #2 - Posted 2013-10-03 11:11:12 »

Yeah, I wouldn't make them all the same instance. I would add in 'lighting tiles,' that is just a black tile with an alpha scale. Like if it is really dark, alpha of .9, if it is really bright, alpha of 0. Simple! However, this would require non-static lighting tiles. I think that it's not worth the trouble of making them static though. I would just make them seperate instances. I think that the resources spent wouldn't be too high. Like said before, just make sure you aren't loading the same resources more than once.

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

JGO Kernel


Medals: 159
Projects: 7
Exp: 3 years


JumpButton Studios


« Reply #3 - Posted 2013-10-03 11:42:28 »

Yeah, I just realized how much of an idiot I was for making my tiles static. It's a cool idea for terrain that doesn't need to be customized too much, but that's about it. I don't want to overlay light tiles either, I'd rather just create new instances and sort my tile creation calls so I only have a specific texture binded once. Thanks guys!

Offline lcass
« Reply #4 - Posted 2013-10-03 16:57:54 »

Store it in a 2 axis matrix such as  matrix[width][height] define your static object to each position and have your lighting either render the pixel or not render the pixel based on the system you are using.
Offline opiop65

JGO Kernel


Medals: 159
Projects: 7
Exp: 3 years


JumpButton Studios


« Reply #5 - Posted 2013-10-03 17:02:36 »

What you're using is an array, not a matrix, and that wouldn't work either because every tile has the same instance of the same sprite, which holds the rgb values for the texture. So every time I modify the sprite, it modifies all the the tiles.

Offline coltonoscopy

Junior Devvie


Medals: 2



« Reply #6 - Posted 2013-10-03 23:07:31 »

What you're using is an array, not a matrix, and that wouldn't work either because every tile has the same instance of the same sprite, which holds the rgb values for the texture. So every time I modify the sprite, it modifies all the the tiles.
2D arrays are often thought of as matrices, because they represent the same concept of a column-and-rows modeling of data. Speaking in abstract terms like lcass was doing, the argument is merely one of semantics.

Straight flippin.
Offline opiop65

JGO Kernel


Medals: 159
Projects: 7
Exp: 3 years


JumpButton Studios


« Reply #7 - Posted 2013-10-03 23:41:59 »

Ok, I've never thought of them like that, sorry Icass! I just dont like the term matrices for storing data because really arrays(at least in the case of my tile game) store instance of something, not numbers, so it really doesn't fit. If I was just storing numbers in the array, it would be different.

Still, there's no point in debating over this, so thank you all!

Offline lcass
« Reply #8 - Posted 2013-10-04 15:04:37 »

Wait you are actually modifying the graphics of each tile? if you are doing that have the object that holds the commands but overlay the graphics. Then you can modify different sections at a time without screwing with your objects.
Offline opiop65

JGO Kernel


Medals: 159
Projects: 7
Exp: 3 years


JumpButton Studios


« Reply #9 - Posted 2013-10-04 15:16:14 »

No, I don't want to use overlays because its easier to just create a new instance if my tile. With an overlay I'd need to render my tiles and the overlay, which would be modified at every tile, so I'd essentially be drawing twice the amount of vertices, and that's just wasteful. The static tile system is nice to use, but it's only good for tiles that are going to be exactly the same. I already moved my tile system over to just creating new tiles.

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

Junior Devvie


Projects: 2
Exp: 3 years


Satisfaction never guaranteed.


« Reply #10 - Posted 2013-10-04 22:25:16 »

make separate instances of your tile, holding the x and y coords, as well as light level as instance variables, and all other data, like textures and reacting to the player, static.

You will have to draw each instance each turn, but you can save on lighting updates by having them update only when changed or surroundings changed by the environment or player.

Signed- EmanP
Offline opiop65

JGO Kernel


Medals: 159
Projects: 7
Exp: 3 years


JumpButton Studios


« Reply #11 - Posted 2013-10-04 22:34:04 »

I know, thats how I had it originally, I just didn't think before I implemented the static tile system.

Offline lcass
« Reply #12 - Posted 2013-10-06 08:57:58 »

No, I don't want to use overlays because its easier to just create a new instance if my tile. With an overlay I'd need to render my tiles and the overlay, which would be modified at every tile, so I'd essentially be drawing twice the amount of vertices, and that's just wasteful. The static tile system is nice to use, but it's only good for tiles that are going to be exactly the same. I already moved my tile system over to just creating new tiles.
Ahh thats not what i meant, I meant dont draw the tile but rather have the tile graphics in the overlay then edit it in the overlay image.
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 (12 views)
2014-11-22 12:13:56

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

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

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

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

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

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

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

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

CopyableCougar4 (76 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!