0
내 Enemy
을 내 Player
으로 옮기려고합니다.내 적을 내 플레이어로 이동시키기 C++
것은 내가 알고
- 플레이어의 위치
- Enemie` '위치
- 적
내가해야 할 일의 속도 :
을- 플레이어에게 방향을 알면 적을 얻습니다. o move
그래서 내가해야 할 일은 플레이어 위치에 따라 적의 위치를 "정규화"하여 어디로 가야 하는지를 알고, 둘 다 Vector2f
을 기반으로하는 위치를 갖는 것입니다.
그리고 이것은 내가 적으로 가지고있는 코드 :
void Enemy::Move()
{
//cout << "Move" << endl;
// Make movement
Vector2f playerPosition = EntityManager::Instance().player.GetPosition();
Vector2f thisPosition;
thisPosition.x = xPos;
thisPosition.y = yPos;
//Vector2f direction = normalize(playerPosition - thisPosition);
speed = 5;
//EntityManager::Instance().enemy.enemyVisual.move(speed * direction);
}
Vector2f normalize(const Vector2f& source)
{
float length = sqrt((source.x * source.x) + (source.y * source.y));
if (length != 0)
return Vector2f(source.x/length, source.y/length);
else
return source;
}
오류입니다 : 내가 잘못 뭐하는 거지
'normalize': identifier not found
?