我的对象目前仅使用以下代码以设定的角度直线前进:
this.time = this.time + deltaTime;
// Vertical : Speed * Sine * Angle
double vy = (this.speed * Math.sin(this.angle)) + this.ax*this.time ;
// Horizontal : Speed * Cosine * Angle
double vx = (this.speed * Math.cos(this.angle)) + this.ay*this.time;
this.x = this.x + vx*this.time;
this.y = this.y + vy*this.time + this.ay*(this.time*this.time);
vx += this.ax * this.time;
vy += this.ay * this.time;
我假设我在计算方面犯了某种数学错误,因为 x 值似乎是正确的,尽管 y 值没有回落。
如果您想知道,这是我的初始值:
this.time = 0.0;
this.deltaTime = .0001;
this.x = 1.0;
this.y = 10;
this.speed = 60.0;
this.ay = -9.8;
this.angle = 45;
this.ax = 0.0;
这是我犯的一个愚蠢的错误,还是我在这里遗漏了一些关键概念?
GamePanel.java:https://gist.github.com/Fogest/7080df577d07bfe895b6 _