mercredi 13 juillet 2016

how can i detect when tile is traversable

I am trying to detect if "start" and "end" and in a traversable location using a vector of bools called "map" but when I run the program both start and end sometimes appear in a location that is non-traversable. I have included a small section of my code which deals with initializing the locations of start, end uses the same code.

start = tydle::Vector(rand() % 512, rand() % 512);
end = tydle::Vector(rand() % 512, rand() % 512);
nodes.resize(0);
int tempx = start.x;
int tempy = start.y;
int Coord = (tempx % 512) * tempy;
while (!map[Coord]){
    start.x = rand() % 512;
    start.y = rand() % 512;
    tempx = start.x;
    tempy = start.y;
    Coord = (tempx % 512) * tempy;
}




Aucun commentaire:

Enregistrer un commentaire