Hey guys. I want to test whether a point on a map consists of a char.Basicall I can only get the integer.Here is a sample map.
---------
.........
.........
...C.....
---------
Here I can only get the integer which C is in.Basically I want to do something like this.
if(player->height + x == 'C')//
{
.....
// you have C in the bottom space.Beware
}
Any suggestion would be welcomed.
Basically I read a map say.
----------------
......C............
.......V..........
S................
.................
.................E
-------------
I then created the classes where the piece that represent them are.For example I created a Critter class where C is, A Valture class where V is.
But now I need to know what is where in order implement the attack.Basically the player should only be able to attack if it is only one block away.
eg
-------------------
......}.C.............. // Here the player should be able to attack the critter.
..........}..C........ //Here the player should "not" be able to attack the critter.
.......................E
But in order to do that I need to know the type of piece that is there.
You have a list of Pieces, a separate list of their (initial) positions, and some multi-dimensional array also pointing to pieces?
Does that mean that when you have a Critter, you will search from obstaclesVec the element pointing to that Critter, and then with the index of that element you pick a Position from obstaclePosVec? If so, then you could create Positions with x&y +/- 1, i.e. the neighbours, search each from the obstaclePosVec, and if found use index to retrieve Piece from obstaclesVec.