Sign in to follow this  

Place and drop paths. Need help.

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[i] * 0.6f and y[i] * 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 to see the project in making. ~Axesor

Share this post

Link to post
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 this post

Link to post
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:

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.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this