Simple rpg map question?
Simple rpg map question?
Ok...I'm starting an RPG. I have been colecting all the tutorials and source code i can find (ARC legacy ROCKS!!). In all the tutorials i can find all the map data and tilesets are hard coded into the game...I don't want that...I wanna load a map and tilesets. Question No. 2 What is a good what to do passibility...a second layer? Final question...how does the map routine on the ARC game work?...ASCII maps? Thanx for all the help!
I haven't checked out The ARC Legacy in years, so I'm not gonna answer your ARC question now... but I can give your first two questions a shot.
I'm assuming in the tutorials you find, your maps and tiles look something like this:
Then the program READs this DATA into an array to be used by your program like so:
And what you want to do is take all that DATA and put it in a separate file?
Well, this is not hard at all. First, copy that big block of DATA statements into an empty text editor... Notepad will work fine. Now, get rid of all the DATA statements at the beginning so you just have the numbers, separated by commas.
Save the file as something like "map.dat". You can pick any extension you'd like.
Feel free to delete all those ugly DATA statements you've got there now. Instead, you've got them in your map.dat file! (Sure makes it a heck of a lot cleaner, eh?)
Now, somewhere before the code that reads the map into the array that I provided above, you've got to use a few commands that you might not be familiar with: file manipulating commands like OPEN, INPUT, CLOSE, etc.
If you have never used these commands before, I suggest you check out a tutorial like this one:
http://members.aol.com/nickjc67/qbtutor5.htm
Anway, you load your map like this:
This should work just like it did when you had your map as a DATA statement. It works the same way with tiles, if you don't load them as BSAVEs, but instead as DATA.
(There might be some errors here...I haven't checked it...but I'm tired and it's 2AM...gotta get to sleep soon...)
Anyway, instead of listening to me, I suggest you check out Fling-Master's RPGs 101 tutorial series from QB Chronicles, which covers all this and more.
You can find the first issue here:
http://qbchronicles.qbrpgs.com/issue1.html
The following issues have the sequel articles.
Now for your second question:
Anyway, I hoped this helped.
But don't take my word for it -- Fling-Master's tutorials are probably your best bet.
Remember, I haven't programmed QB in about four years, so I wouldn't be surprised if I screwed something up.
This is not difficult at all.In all the tutorials i can find all the map data and tilesets are hard coded into the game...I don't want that...I wanna load a map and tilesets.
I'm assuming in the tutorials you find, your maps and tiles look something like this:
Code: Select all
DATA 00,00,00,00,00,00,00,00,00,00,12,12,00,00,00
DATA 00,00,00,00,00,00,00,00,00,00,15,15,00,00,00
DATA 00,00,00,00,00,00,00,00,00,15,15,15,15,00,00
DATA 00,00,00,00,00,00,00,00,00,15,15,00,15,00,00
DATA 00,00,00,00,00,00,00,00,15,15,15,15,15,14,00
DATA 00,00,00,00,15,15,15,15,15,15,15,15,15,14,14
DATA 15,00,15,15,15,15,00,15,15,15,15,15,00,00,00
DATA 00,15,15,15,15,00,15,15,15,15,15,00,00,00,00
DATA 15,00,15,15,00,15,15,15,15,15,15,00,00,00,00
DATA 00,15,15,15,15,00,00,15,15,15,15,00,00,00,00
DATA 15,00,15,15,15,15,15,15,15,15,00,00,00,00,00
DATA 00,00,00,00,00,00,15,15,15,00,00,00,00,00,00
DATA 00,00,00,00,00,00,00,14,00,00,00,00,00,00,00
DATA 00,00,00,00,00,00,00,14,00,00,00,00,00,00,00
DATA 00,00,00,00,00,00,14,14,14,00,00,00,00,00,00
Code: Select all
DIM SHARED Map%(0 TO 14, 0 TO 14) ' This is the 2d array which will be
' used to hold the map data.
'this reads the DATA statements and gets the map into the map% array.
FOR Y = 0 TO 14
FOR X = 0 TO 14
READ Map%(X, Y)
NEXT X
NEXT Y
Well, this is not hard at all. First, copy that big block of DATA statements into an empty text editor... Notepad will work fine. Now, get rid of all the DATA statements at the beginning so you just have the numbers, separated by commas.
Save the file as something like "map.dat". You can pick any extension you'd like.
Feel free to delete all those ugly DATA statements you've got there now. Instead, you've got them in your map.dat file! (Sure makes it a heck of a lot cleaner, eh?)
Now, somewhere before the code that reads the map into the array that I provided above, you've got to use a few commands that you might not be familiar with: file manipulating commands like OPEN, INPUT, CLOSE, etc.
If you have never used these commands before, I suggest you check out a tutorial like this one:
http://members.aol.com/nickjc67/qbtutor5.htm
Anway, you load your map like this:
Code: Select all
OPEN map.dat FOR INPUT AS #1 'Open it
'Load map data from the map.dat file
FOR x = 0 TO 14
FOR y = 0 TO 14
INPUT #1, map%(x, y)
NEXT J
NEXT i
CLOSE #1
(There might be some errors here...I haven't checked it...but I'm tired and it's 2AM...gotta get to sleep soon...)
Anyway, instead of listening to me, I suggest you check out Fling-Master's RPGs 101 tutorial series from QB Chronicles, which covers all this and more.
You can find the first issue here:
http://qbchronicles.qbrpgs.com/issue1.html
The following issues have the sequel articles.
Now for your second question:
Making a second layer WILL work, but it's not the easiest way to do it. The easiest of all is to make certain tile types walkable and other tiles not walkable. For example, you always want your hero to be able to walk on a grass tile. Say on your map, a grass tile is represented by "00". What you do then is every time you try to move, you check to see if the tile you're about to move on is a grass tile. If it is, then you're free to move... but if it's not a grass tile... say it's #14, a rock tile... then your move gets rejected and you stay on the same tile as before. This is a limited way to do this, but it's also damn simple, and doesn't require any extra variables or arrays or anything.Question No. 2 What is a good what to do passibility...a second layer?
Anyway, I hoped this helped.
But don't take my word for it -- Fling-Master's tutorials are probably your best bet.
Remember, I haven't programmed QB in about four years, so I wouldn't be surprised if I screwed something up.