Ok here is what I'm trying to do now:
Code:
void Entity::move(int milis, std::vector<Entity*> entities)
{
int x = m_x, y = m_y;
m_x += (milis*m_dx)/10;
for (int i = 0; i < entities.size(); i++)
{
if (entities[i] != this)
{
if (collides(entities[i]))
{
m_x = x;
}
}
}
m_y += (milis*m_dy)/10;
for (int i = 0; i < entities.size(); i++)
{
if (entities[i] != this)
{
if (collides(entities[i]))
{
m_y = y;
}
}
}
}
Now what I'm trying to do here is, if you move in x and collide with something (other than yourself) move back to where you were in x, back to where you still hadn't collided. Then do the same thing with y.
But the character moves into stuff and gets trapped inside... why oh why would that happen if I'm moving it to where it still hadn't collided?