PDA

View Full Version : Map Tiles and Variables/Properties ???


jnmwilson
03-01-2008, 05:33 PM
Okay, here is what I am trying to do...

In my RPG, I have a map created with different tiles. Now, if the character encounters an enemy character it goes to the battle sequence.

What I want to do, is display the proper background image according to the type of tile the player was standing on (grass,water,swamp, etc...).

How do I assign that in the Tile1.prototype...... process??

In the main timeline, I have this for the root variable: _root.terrain = "";

The function would go something like this:

terrain = function(){
if(_root.terrain=="grass"){
batBack_mc = grass_mc;
}else if(_root.terrain=="swamp"){
batBack = swamp_mc;
}
}
terrain();

This is just a rough representation of the actual function...but, can anyone help out with how I would assign the "terrain" variable to a tile prototype so that I can read it into a root variable at a specific time???:confused:

fnx
03-04-2008, 01:03 AM
Hello,
to solve that just create a Tile class with all the properties you need to use on the tile,
then, create a tiled terrain where each tile is a Tile class Object so you can know
everything about the tile you are on :)

jnmwilson
03-05-2008, 02:38 AM
How would I call that information in relation to what tile I am over??? In other words...how do I first, determine which tile I am on and second, call the specific information for that tile?

rrh
03-05-2008, 04:41 PM
You should make sure your tiles are named according to their x and y position in the grid, or are stored within an array according to the same. Then you can calculate the closest tile based on the x and y of your character, divided by the width of a tile.

jnmwilson
03-05-2008, 08:03 PM
Okay...I got this to work....mostly...

I have an array containing the names of the various terrain tiles in their appropriate positions...ie, grass, water, rock, etc. (grass_0_3)

When the "map builder" function runs...it takes the movie clip name and adds: _[x]_[y] to the end of it (x and y being their position in the array).

What is happening though is that as soon as even a corner of the character_mc touches a tile it shows the character as being on THAT tile. In other words, even though 3/4 of his body is standing in the grass, it will display "SWAMP" because there is 1/4 of his body touching a swamp tile....

Any suggestions on this??

(Sorry to sound like an idiot...I'm not really)

rrh
03-05-2008, 08:17 PM
Hm?

So you want to pick the four closest tiles and go with majority rules? Or maybe weight them based on distance, or something?

been_1990
03-05-2008, 10:13 PM
This place may help...........
http://www.tonypa.pri.ee/tbw/start.html
:)