|
Hi!. It was a loooong wait, but this lesson is finally
here!. Now we'll see that tiles aren't the only part of a map, a map is
a mixture of a lot of things... now, let's start!!!
(NOTE: All this document talks about maps where PC's and NPC walks
with a minimun step of ONE tile. If you want to know more about
pixel_by_pixel steps e-mail us)
Before Start...
Tiles in a Map
Movement flags
Encounters with enemies andinfo of the limits
Events
Other things
Source code
Final Words
What are the basic things of a map?
How can I represent the tiles in a map?
With a two-dimensional arrayl:
TGraphicsInMap = Array [1..MAX_X,1..MAX_Y] Of
TTile(2)
Remember this graphic (previous lesson)?. OK. Well,
the graphic IS a map (with
MAX_X=4 and MAX_Y=4), and every
cell ([X,Y]) of the two-dimensional array has information about a tile.
And where are the tile graphics stored?. Every layer
have its own file of graphics, and when executing the program, these files
are stored into memory (for faster access).
And how more i have to know about tiles?
There's still a couple of details: the type of the layers (Byte/Word/DWord), and an optimization.
[(1,1)] Layer1,Layer2,Layer3,Layer4 | [(2,1)] Layer1,Layer2,Layer3,Layer4 | [(3,1)] Layer1,Layer2,Layer3,Layer4 | .... | [(Max_X,Max_Y)] Layer1,Layer2,Layer3,Layer4
S----------------------> Row 1
-----------------------> Row 2
.....
----------------------E>Row
Max_Y
(when recording, the Array would travel from S to E going from left to right and from up to down)
However, if instead of making a two-dimensional array of tiles we make FOUR two-dimensional arrays of layers, we would have a bigger compression. (a layer is usually similar to the one that is to its right):
(1,1) Layer1, (1,2) Layer1, (1,3)
Layer1, .... , (Max_X,Max_Y) Layer1 | (1,1) Layer2, ....
,(Max_X,Max_Y) Layer2 | And this way with Layer3 and Layer4..........
255 | 255 | 255 | 255 | |||||
+ | 255 | 255 | ||||||
|
|
And what are them?
Look at the above map (that of the red crosses).
It would be strange that you could walk in the mountains, uh?.
In every CRPG, there're certain tiles that we cannot
step, neither cross (mountains, rivers, walls,...). How can we implement
that?
First way to make it: adding a new data to every
tile: walk/don't walk over me. Example:
Movement Flags
Look at the situation that we have to our left. They are two tiles that
represent a section of a wall that is in a house with wooden floor, and
whose exterior has floor of grass.
A character can walk inside of the house (leaving
the wall behind), but he can also walk outside of the house (the wall would
cover him). And he/she should not walk inside-out and out-inside.
That is impossible to contemplate with the previous
method (the one that uses a boolean methid: can/can't walk over a tile),
but there is a better way: To use movement flags.
The Movement Flags are in fact 4 bits that indicate
to what addresses I can move (in the tile that I am) and to which not:
|
|
|
|
0 indicate "I CAN go to that address"
1 indicate "I CANNOT go to that address" |
ENCOUNTERS WITH THE ENEMIES AND INFO ABOUT MAP LIMITS
Encounters with enemies
When we'are going to fight ?
When we meet with bad guys ^_^. But there are several
ways of finding them:
A) You are walking in the field area, there's a flash
and...combat!!!.
B) When speaking with a VERY powerful enemy (Sephiroth,
Dark Force, Gades, i.e. ^_^)
We'll see the A case.The % of encountering with enemies,
the type of enemies you encounter, the quantity,... all is kept in the
map.
Well, in fact not all the things are stored in the
map ^_-. But the most of things, yes.
The main problem: Where are in the map the data
about encounters with enemies?.
A.1) In each tile: Absolutely wasteful and useless.It
would occupy a lot of space and it would be a lot of work.
A.2) In the map: It depends on the size. If it is
a small map (40x20 tiles, p. e.g.), it is worthwhile. If it is bigger (160x90,
i. e.),...
A.3) In sections (areas) of the map. The map is
divided into sections (for example, the map 160x90 is divided in sections
of 32x18 tiles each one), and in each section is saved the data of encounters.
Well. And those data,... what things contains? ("with whom","where","how much"):
Information of limits.
What happens if I'm in the limit of the map and i
walk outside it?. I teleport into other map.
Well, the we must keep that info (the map we teleport)
saved in some place(5) (or if we don't go
to anywhere).
This is made with an Array of 4 positions (
Array[0
..3] Of Word) for each map. In each position is saved where to go if
we go up (0), right (1), below (2) or left (3).
And how can we indicate: "No teleport"?. Using the
maximun value of the Array's type (
In the previous example, if a limit
is 65535, we cannot walk toward that address [Limit pos. 0 is 65535, we
can't go up])
For example, the array of limits _arraylim is
equal to (34,2,3,65535) in a map of size [1 ..20,1 ..20]. If we are in
the position X=1 and Y=1 and we go up, we load the map nº 34 (_arraylim[0]).
But if we go to the left, we don't load any map: we cannot move (_arraylim[3]=65535).
Games like Knigths of Xentar (Dragon Knight 3) do
this stuff. But there's games with other techniques (Phantasy Star saga,
with a map they have enoguh to represent a planet, and the map is circular,
without stopping the scroll).
This is left for later
Each map has a series of "mini-programs" that,
when run, make the complicated stuff of CRPG's (to speak with somebody,
to fight with a bad guy, to go to stores, to open a wall that was closed,
special effects, move the PC's or NPC's...). These mini-programs are activated
when looking or going into certain tiles. When this happens, an event is
shot, and executes the corresponding mini-program.
...And explaining all of this needs an special lesson.
So sorry, you must wait mooooooore time :_ (.
NOTE: People that knows RPG Maker 95 from ASCII
will known of what i'm speaking ;-).
Diagonal movements
Now, we can only go towards the 4 cardinal points.
But there're games (Emerald Dragon for SNES, Y's V, Shinning Force II)
where people can walk in diagonal.
We supossed that this was implemented with events,
but we have discovered other solution. We'll post it when required ^_-.
I_Can_Shot-Flag
It will be commented in the lessons of COMBATS, but
this is saved in the map, so it is necessary to point out it here.
If the combats are strategic, we can use the movement
flags to indicate if a Pj can shoot or not into a tile (with an enemy inside...or
not). But... there're certain tiles for which we cannot move (a river,
i.e.) but we can see what there is in the other bank.
For that this Flag exists. It indicates that a tile
can be seen, although one cannot walk into it. This way, a river would
have active this flag, and although we could not walk on it, we
could shoot above it.
Other flags
Roof Tiles, Mobile tiles,... these flags (we saw them in the previous lesson) also stays in the map.
Pnj's moving
We have made them (and programmed them ^_^). But is complicated: needs a special lesson.
In TIPOS.PAS/PP is the type TPantallaHDD, the map. For an explanation of the flags, look at the beginning of the MAPMAKE2.PAS/PP. Also execute the MAPMAKE2.EXE to see the movement flags (inferior zone, option 6º. I advise to load the map nº 0 to see the flags of the town)
(1): NPC: Non-Player Character.
(2): Look in the previous lesson the
tile definition.
(3): An example: Now the game has 3 files
for the transparent layer (TRANS000?.PCX). Each map chooses what file wants
to use, and it loads the graphics to memory when the map is loaded.
(4): This is the RLE compression. Other
compressions, as the ZIP, are based on the patterns: they look at the bits
pieces that repeat, and they substitute it for an index to a dictionary
of pieces:
The end. The next lesson should go about the types of the characters, about the items,...; or about the scroll. But there are desires of writing a lesson about the combat, so for the next one: COMBATS: TYPES OF COMBATS.
See you!!!. And remember: we love mails ^_^!!!!. Send us your opinions about this tutorial (you see, isn't dead)