내 XNA 프로젝트에 대한 간단한 AI를 만들었습니다.XNA, Do-While 기본 문제
내 페니 다이오드가 오른쪽에서 왼쪽으로 이동해야합니다.
불행히도 내 코드는 내 첫 번째 및 두 번째 Do-While을 건너 뛰므로 내 적의 이동이 없습니다. < 5 초. 그래서 그는 지금 또 다른 문제, 그래서 ... + -1.X 위치 업데이트
while (i <= 1)
{
EnemyVelocity.X += 1f;
timer += (float)gameTime.ElapsedGameTime.TotalSeconds;
usedTimeRight = timer;
i++;
}
if (usedTimeRight != 0)
{
do
{ EnemyVelocity.X -= 1f;
timer += (float)gameTime.ElapsedGameTime.TotalSeconds;
} while ((timer - usedTimeRight) >= 5);
usedTimeLeft = timer;
usedTimeRight = 0;
}
if (usedTimeLeft != 0)
{
do
{ EnemyVelocity.X += 1f;
timer += (float)gameTime.ElapsedGameTime.TotalSeconds;
}
while (timer - usedTimeLeft >= 5);
usedTimeRight = timer;
usedTimeLeft= 0;
}
에서 ~~~~~~~~~~~
점프 - 내 적의 모든 왼쪽 이동 시간
timer += (float)gameTime.ElapsedGameTime.TotalSeconds;
while (i <= 1)
{
EnemyVelocity.X -= 1f;
timer += (float)gameTime.ElapsedGameTime.TotalSeconds;
usedTimeRight = timer;
i++;
}
if (usedTimeRight != 0 && (timer - usedTimeRight <= 2))
{
int x;
for (x = 0; x <= 3; x++)
{
EnemyVelocity.X = 1;
}
usedTimeLeft = timer;
usedTimeRight = 0;
}
if (usedTimeLeft != 0 && (timer - usedTimeLeft <= 2))
{
int x;
for (x = 0; x <= 3; x++)
{
EnemyVelocity.X = - 1;
}
usedTimeRight = timer;
usedTimeLeft = 0;
}
(그동안에 타이머를 넣어 피하기 위해 노력을)하지만 내 캐릭터가 지금 왼쪽으로 이동 ... (추가하는 방법 새로운 코드? ^^) '' – Suikoden
나는 각 점에서 모든 값을 살펴봄으로써 코드를 생각할 필요가 있다고 생각한다. – Needham