Greetings SFML,
I'm creating a simple tower defense game as my first-ever C++ project. It's going decently smoothly, however I've hit a logic bump in the movement of minions.
Each minion has a member variable of type std::vector<Tile> path, which is their path. path[0] represents the start, path[path.size()] represents the end.
Currently my logic does something like:
- Loop through path. If path contains the minion, we've found its tile.
- Obtain tile path[i+1] (OOB exceptions handled). Obtain midpoint (Tile.getMidPoint()).
- If midpoint.x > minion.getPosition().x, move right. else if less, move left. etc for .y values.
The problem is that since I only check for tile.contains(), it "moves on" to the next tile just when entering the new one. This is a problem for corners, where I end up with something like this:
Here the minions start going left, rather than following the path.
Any help/ideas are appreciated!