Если вам интересно узнать, как ваш код, с небольшими изменениями, завершается без цикла убийцы в C #:
float ax = 0; //acceleration in the horizontal direction
float ay = -9.8f; //acceleration in the downward direction
float x = 0; //top of building at position 0
float y = 50; //building is height 50 m
float vx = 10f * (float)Math.Cos(30); //velocity in the horizontal direction = 10 m/s * cos(30);
float vy = 10 * (float)Math.Sin(30); //velocity in the vertical direction = 10 m/s * sin(30);
float time = 0; //time starts at 0 seconds
float deltaTime = 0.001f; //increment time by .001 each iteration
//while ball is greater than 0, or above the ground which is at position 0
while (y > 0)
{
time = time + deltaTime;
vx = vx + ax * deltaTime;
vy = vy + ay * deltaTime;
x = x + vx * deltaTime + (1 / 2 * ax * deltaTime * deltaTime);
y = y + vy * deltaTime + (1 / 2 * ay * deltaTime * deltaTime);
Console.WriteLine("x = {0}, y = {1}, vx = {2}, vy = {3}, time = {4}, ", x, y, vx, vy, time);
}
Console.ReadKey();
Единственная модификация, которую я сделал, это наложение на Cos и Sin и изменение времени для плавания.
И добавил 'f' после некоторых начальных значений (например, приведения).
Возможно, это не реальный ответ для C, но это может быть подсказка?