Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - PreDominance

Pages: [1]
1
General / Re: Logic question regarding movement.
« on: May 28, 2014, 07:48:44 pm »
Yeah, my bad.

2
General / Logic question regarding movement.
« on: May 28, 2014, 07:31:47 pm »
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!

Pages: [1]