# Place and drop paths. Need help.

This topic is 4374 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I'm trying to program a path in which my program reads this data and places squares into the path where the charqcter moves in. Here's the path:
/*Tryout area.*/
MapData1.type = 2;
//bottom layer
MapData1.X[0] = -4;  	MapData1.X[1] = -4;
MapData1.Y[0] = -2;     MapData1.Y[1] = -1;
//middle layer
MapData1.X[2] = -4;  	MapData1.X[3] = -3;
MapData1.Y[2] = 0;      MapData1.Y[3] = 0;
MapData1.X[4] = -2;  	MapData1.X[5] = -1;
MapData1.Y[4] =  0;     MapData1.Y[5] = 0;
//top layer
MapData1.X[6] = -1;  	MapData1.X[7] = -1;
MapData1.Y[6] = 1;      MapData1.Y[7] = 2;

Then in the program it places 1x1 squares down in posistion (x * 0.6f and y * 0.5f gives the squares exact position I needed). When my character moves, I need it to chack those- currently- 7 areas and see if my charatcer moves on them. They are not the walls to avoid, they are the path to walk on and only them. The character moves by walky and walkx (-0.01f and +0.01f) and is also 1x1 scaled down to about 0.5 x 0.6? Thank you for answering this hard problem and if you help, I will put you into the game credits. For more information (As I did not give much) go to www.atfreeforum.com/pcn to see the project in making. ~Axesor

##### Share on other sites
The simplest thing is just to test each move whether the new position of the character is valid (i.e. on the tiles), and reject the move if not.

Testing whether they are on the path is probably most simply done by checking whether they are on each tile in turn. If the tiles are rectangular and aligned with the axes it is one of the quickest tests (on_this_tile = ((player.X >= tile.X0) && (player.X <= tile.X1) && (player.Y >= tile.Y0) && (player.Y <= tile.Y1)) is all).

##### Share on other sites
It also needs to see if a tile is next to that tile so the tile you are currently standing on will allow you to move ahead. Like:

[0][1][2]
------[3]
Tile0 is -4x and 0y and tile1 is -3x and 0y. So the test needs to see if that tile is next to somehting else so that the 0.5x0.5 player can move across the 1x1 tile without being stopeed until it reaches an end.

1. 1
Rutin
23
2. 2
3. 3
JoeJ
20
4. 4
5. 5

• 30
• 41
• 23
• 13
• 13
• ### Forum Statistics

• Total Topics
631741
• Total Posts
3001980
×