So I've started my Text based RPG game however my room system is lacking depth. In basic I create a room object and add it to ArrayList I was looking into how to make a 2d array, but seems like that not an option. However I'm unsure how I can make an array that holds objects other then ArrayList.

?_? what do you mean it isn't possible to do a 2d array? 2d arrays are done as :

1

privateArray[][] map;

or

1

privateArrayMoney[][];

(can also be public instead of private, and various other things)

the '[]' doubled up make it into a 2d array, if there were 3, then it would be 3d array (there isn't a limit, but please note that the more dimensions it has, the more memory and processor usage it takes up)

Anyway, basically the map coding is pretty much the same for 2d games AND text based games, (if you actually mean the map when you say 'room object'. sorry, but there are dozens of things that 'room object' could mean, i'm assuming you mean a 2d text map with # as walls and things like that since you want to know about 2d arrays)

If that's not what you mean, then could you give us more information? (Ps. don't worry about being new, so long as you know the basics of java, we can help)

Your question is pretty confusing. You're "unsure how make an array that holds objects other then ArrayList?" What? Why is a 2d array not an option?What do you mean by "lacking depth"? 2d games don't use depth...

Don't use arrays for this stuff, use collections like List, which will let you do far more than arrays. If you need an extra dimension, use a List of Lists, and also look at things like Map while you're at it.

Don't use arrays for this stuff, use collections like List, which will let you do far more than arrays. If you need an extra dimension, use a List of Lists, and also look at things like Map while you're at it.

Arrays do have their uses, but not in a text-based game.

Actually, i think what they mean is that they want to make a text based roguelike, which usually IS made with 2d arrays (or 2d char arrays, at least). i think that the confusion is because there is also the old fashioned text based RPG games where it's just dialogue and you loosing hp. usually roguelike games have maps that look almost EXACTLY like this:

basically, you need to do that for each direction. (if down it should be y-1 and y--, if left it should be x-1 and x--, and if right it should be x +1 and x++)

there you go, you now have your character and map working together in perfect harmony. now you basically have to do the same for each mob, (basically, it's a for loop that checks if the slot is taken up by a mob, if it is, then an if statement to see if the player is near by, then if the player IS then you need to do the attack. if it's not, then either randomly move 1 (again, check if the mob can actually move).

basically, that's it. it's really easy and it's also the 'begginers programming to rpgs'. there are actually a LOT of online tutorials that will tell you how to code every single line. though not all use 2d arrays or 2d char arrays. anyway, here is one of the youtube tutorials i found in my favs, (though i have no idea if it uses arrays or not):http://www.youtube.com/playlist?list=PLB062D4D37FECD5A6

Yeah an array is appropriate for the actual map of a roguelike where all you need is direct access to 2d locations and aren't going to go inserting, deleting, searching, copying into other collections, and so forth. But in this thread I'm reading about discrete rooms and exits and thinking more "MUD" than "Roguelike", and there doesn't seem to be much use for arrays there. ArrayLists, sure, but that's just an implementation detail.

@TrinityGamer Thank-you for the insight. I like the sound of a rougelike game and I think that the story idea behind the game would probably fit this type of game. However I'm not sure the difference fully is. The game has three option at any point when not in a fight or event. Go, Search, and rest. Go I would like to use to move the player from room to room however all it does is get the next room. If I choose to use the method you detail with out a drawn map but how would I pull up the next room with it. I do like the idea of the rouge like game but I would like to just finish what I have. At this moment rooms are like containers that hold enemies items and events. I don't know if thats bad practice or something.

I obviously am just going to have to dive into and play with these things.

@sproingie

I was trying to make a map like ######## #

just to start but each room is a object so I was calling them by getting there index and changing what index was being referenced. however I was unsure how to code the getting and finding out if there was a room to the right. Would I assign each with a XY value and then test to see if the player is next to that value? and then test each of the objects in the arraylist (im reading the tut on collection and colletion api right now) to see if they have the same value?

Sorry if any of these question are confusing I'm still pretty fresh in the all this. Again Thank-you for the help

@TrinityGamer Thank-you for the insight. I like the sound of a rougelike game and I think that the story idea behind the game would probably fit this type of game. However I'm not sure the difference fully is. The game has three option at any point when not in a fight or event. Go, Search, and rest. Go I would like to use to move the player from room to room however all it does is get the next room. If I choose to use the method you detail with out a drawn map but how would I pull up the next room with it. I do like the idea of the rouge like game but I would like to just finish what I have. At this moment rooms are like containers that hold enemies items and events. I don't know if thats bad practice or something.

I obviously am just going to have to dive into and play with these things.

@sproingie

I was trying to make a map like ######## #

just to start but each room is a object so I was calling them by getting there index and changing what index was being referenced. however I was unsure how to code the getting and finding out if there was a room to the right. Would I assign each with a XY value and then test to see if the player is next to that value? and then test each of the objects in the arraylist (im reading the tut on collection and colletion api right now) to see if they have the same value?

Sorry if any of these question are confusing I'm still pretty fresh in the all this. Again Thank-you for the help

OOOOOOOOOOOOOOOOOOOOOOH.

yes, that is essentially what you would do. there are many ways to do it, but that is the most common method. there are a lot of ways, but most of them do pretty much the same thing.

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