Hey everyone,
Currently I'm having a problem trying to implement movement into my game that works with path-finding.
Right now what I have is A* code that will create a string, "0000100223331100", that shows which direction the player needs to walk. '0' is right, '1' is down, '2' is left, and '3' is up. I have also tried to change the string into a vector of sf::Vector2f's, but I've taken it out as I think it's unnecessary.
The problem I'm having is converting this string into player movement. I have tried a for-loop, but it doesn't work very well. The best I have so far is...
for(int i = 0; i < route.size(); i++)
{
switch(route[i])
{
case '0':
rect.move(32, 0);
break;
case '1':
rect.move(0, 32);
break;
case '2':
rect.move(-32, 0);
break;
case '3':
rect.move(0, -32);
break;
}
}
... while this follows the path, it instantly teleports my play straight to the end. Instead I would like the player to slowly walk along the path.
I would love it if someone could post some code or explain to me how to structurally go about writing the code.
Thanks,
Nswift