Hi !
Featured games (84)
games approved by the League of Dukes
Games in Showcase (604)
Games in Android Showcase (171)
games submitted by our members
Games in WIP (654)
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 Based RPG Resource Management and Loading  (Read 762 times)
0 Members and 1 Guest are viewing this topic.
Offline Troncoso

JGO Coder

Medals: 20

« Posted 2013-06-16 23:29:11 »

I've started work on a Tile Based RPG (Link To The Past kind of deal). The way my world is setup is that I have 3 or 4 levels, and within each I have a bunch of areas that are free roam. So, when the player moves off the screen it transitions to a new area, rather than having the screen scroll with the character.
I would like to ask about loading resources. As far as a tilemap goes, the layout of the tiles would be stored in a file, and loaded from that. That's simple enough. What I'm unsure about though, is loading objects into the maps. Say collectible items, or objects the player interacts with. Are these items typically represented by tiles as well? I'm not sure how to handle this.

For example, say I have a Key class. Within the key class it has an ID of the door it unlocks. Say one level has some 20 doors to unlock. I could load these into the game the same way as tiles (via a file), but how do I decide which key is which and where it should go?

This question has gotten kind of confusing. Please ask for clarification if it is needed.
Offline Opiop
« Reply #1 - Posted 2013-06-16 23:40:42 »

I would use some sort of XML system to define a specific key's attributes. How are you currently loading maps? Using a text file or through a image? If you're using a text file, just create a new number that corresponds to a tile with a key on it.

0 = void tile
1 = grass tile
2 = grass tile w/ key


Your program will then loop through and find the 2, create a new grass tile (or whatever you need) and then create a new instance of a key and place it at that tile's location. It's pretty much the same for a map loaded through an image, you just use a different color and when the game finds that color in the map, it creates a new tile and key and adds the key to the tile. That's at least how I would do it!

For the actual key attributes, I think you should think some more about how you could accomplish this. Hint, you need to give the key class a door object.

Offline Troncoso

JGO Coder

Medals: 20

« Reply #2 - Posted 2013-06-17 00:14:44 »

That's how I'm loading the tilemaps, yes. That's no issue. I think loading the actual objects through a file would work well, too. Let me refine my example to explain the issue a little better.

I have a key class. In my file, if there is a key on a tile, I'll place a 1 on it.

Now, I go to parse the file, and I come across a 1. So, my parser creates a new key (via new Key()Wink
I come across another 1, and do new Key(); again.

How would I assign doors to these keys, considering my parser is creating the objects? Basically, how do I differentiate 2 different instances of the same class? I figure an ID, but how can my parser assign these ID's? And in my opinion for the door, rather than giving the key a door object, the key and door just need to have the same "key code" (A number that has to match).
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline tyeeeee1
« Reply #3 - Posted 2013-06-17 00:30:47 »

I kinda-sorta get what you're saying. The way I'd do it, which is probably a bit too long, would be to have a text file that looks like this:

KeyID, DoorIDForDoorThatKeyOpens, WhereKeyIsOnMap
KeyID, DoorIDForDoorThatKeyOpens, WhereKeyIsOnMap
KeyID, DoorIDForDoorThatKeyOpens, WhereKeyIsOnMap

Just load and parse the text file for the information then do whatever you need to with that information. The WhereIsKeyOnMap decides where the key is on the map, DoorIDForDoorThatKeyOpens decides which door the key opens and the KeyID is for something that I forgot while typing this.

Hopefully this gives you some ideas for different approaches to solve your problem.
Offline Troncoso

JGO Coder

Medals: 20

« Reply #4 - Posted 2013-06-17 03:07:25 »

Hm. I guess that'd be the most appropriate choice. Is that fast? Should I just load all the assets at the start of the game?
Offline tyeeeee1
« Reply #5 - Posted 2013-06-17 14:18:55 »

Hm. I guess that'd be the most appropriate choice. Is that fast? Should I just load all the assets at the start of the game?

I doubt you'd even notice any difference in loading time as long as your text file isn't absurdly long (a few thousand lines). Load it whenever you want; if you're putting the keys on the map right away then load the text file right away.
Pages: [1]
  ignore  |  Print  
You cannot reply to this message, because it is very, very old.

bilznatch (27 views)
2015-08-04 11:03:17

SHC (44 views)
2015-08-01 03:58:20

Jesse (25 views)
2015-07-29 04:35:27

Riven (48 views)
2015-07-27 16:38:00

Riven (26 views)
2015-07-27 15:35:20

Riven (28 views)
2015-07-27 12:26:13

Riven (19 views)
2015-07-27 12:23:39

BurntPizza (42 views)
2015-07-25 00:14:37

BurntPizza (56 views)
2015-07-24 22:06:39

BurntPizza (35 views)
2015-07-24 06:06:53
List of Learning Resources
by gouessej
2015-07-09 11:29:36

How Do I Expand My Game?
by bashfrog
2015-06-14 11:34:43

List of Learning Resources
by PocketCrafter7
2015-05-31 05:37:30

Intersection Methods
by Roquen
2015-05-29 08:19:33

List of Learning Resources
by SilverTiger
2015-05-05 10:20:32

How to: JGO Wiki
by Mac70
2015-02-17 20:56:16

2D Dynamic Lighting
by ThePixelPony
2015-01-01 20:25:42

How do I start Java Game Development?
by gouessej
2014-12-27 19:41:21 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!