Java-Gaming.org    
Featured games (91)
games approved by the League of Dukes
Games in Showcase (581)
games submitted by our members
Games in WIP (500)
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 474 times)
0 Members and 1 Guest are viewing this topic.
Offline Troncoso

JGO Coder


Medals: 20



« Posted 2013-06-17 01: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 opiop65

JGO Kernel


Medals: 124
Projects: 7
Exp: 3 years


Team Alluminum


« Reply #1 - Posted 2013-06-17 01: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.

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

00000
01210
00000

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 02: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 02: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
etc...

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 05: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 16: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.

 

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

The first screenshot will be displayed as a thumbnail.

xsi3rr4x (53 views)
2014-04-15 18:08:23

BurntPizza (51 views)
2014-04-15 03:46:01

UprightPath (65 views)
2014-04-14 17:39:50

UprightPath (48 views)
2014-04-14 17:35:47

Porlus (65 views)
2014-04-14 15:48:38

tom_mai78101 (89 views)
2014-04-10 04:04:31

BurntPizza (149 views)
2014-04-08 23:06:04

tom_mai78101 (245 views)
2014-04-05 13:34:39

trollwarrior1 (203 views)
2014-04-04 12:06:45

CJLetsGame (210 views)
2014-04-01 02:16:10
List of Learning Resources
by SHC
2014-04-18 03:17:39

List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30
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!