fix: changed deltaTime to dt

This commit is contained in:
Laureηt 2021-04-09 12:01:00 +02:00
parent 9bc8b487ae
commit 80e2ffa8e3
6 changed files with 21 additions and 23 deletions

View file

@ -88,14 +88,14 @@ public class Arrow extends Actor {
* Updates the physical attributes of the Arrow, * Updates the physical attributes of the Arrow,
* must be called in the main update loop. * must be called in the main update loop.
* *
* @param deltaTime time elapsed between 2 frames. * @param dt time elapsed between 2 frames.
*/ */
public void update(float deltaTime) { public void update(float dt) {
if (this.active) { if (this.active) {
verifyActivity(); verifyActivity();
integrationVerlet(deltaTime); integrationVerlet(dt);
this.TTL -= deltaTime; this.TTL -= dt;
this.angle = this.velocity.angleDeg(); this.angle = this.velocity.angleDeg();
} else { } else {
this.position = crash.position.cpy().add(offset); this.position = crash.position.cpy().add(offset);
@ -107,20 +107,20 @@ public class Arrow extends Actor {
* according to its physical attributes * according to its physical attributes
* using the Verlet integration scheme. * using the Verlet integration scheme.
* *
* @param deltaTime time difference used in the integration. * @param dt time difference used in the integration.
* @see <a href="https://gamedev.stackexchange.com/a/41917">https://gamedev.stackexchange.com/a/41917</a>. * @see <a href="https://gamedev.stackexchange.com/a/41917">https://gamedev.stackexchange.com/a/41917</a>.
*/ */
private void integrationVerlet(float deltaTime) { private void integrationVerlet(float dt) {
this.acceleration = this.force.cpy(); this.acceleration = this.force.cpy();
this.position.x += deltaTime * ( this.velocity.x + deltaTime * this.acceleration.x / 2 ); this.position.x += dt * ( this.velocity.x + dt * this.acceleration.x / 2 );
this.position.y += deltaTime * ( this.velocity.y + deltaTime * this.acceleration.y / 2 ); this.position.y += dt * ( this.velocity.y + dt * this.acceleration.y / 2 );
this.force = computeForce(); this.force = computeForce();
this.velocity.x += deltaTime * ( this.acceleration.x + this.force.x ) / 2; this.velocity.x += dt * ( this.acceleration.x + this.force.x ) / 2;
this.velocity.y += deltaTime * ( this.acceleration.y + this.force.y ) / 2; this.velocity.y += dt * ( this.acceleration.y + this.force.y ) / 2;
} }
// ---------- GRAPHICAL METHODs ---------- // ---------- GRAPHICAL METHODs ----------

View file

@ -34,7 +34,7 @@ class Bow extends Actor {
// ---------- METHODs ---------- // ---------- METHODs ----------
@Override @Override
public void act(float deltaTime) { public void act(float dt) {
if (Gdx.input.isButtonJustPressed(Buttons.LEFT) && !pressed) { if (Gdx.input.isButtonJustPressed(Buttons.LEFT) && !pressed) {
this.anchor = Sagittarius.worldCursor.cpy(); this.anchor = Sagittarius.worldCursor.cpy();

View file

@ -20,7 +20,7 @@ public class Moon extends Planet {
// ---------- METHODs ---------- // ---------- METHODs ----------
@Override @Override
public void act(float deltaTime) { public void act(float dt) {
this.rotateBy(10.0f / this.altitude); this.rotateBy(10.0f / this.altitude);

View file

@ -41,13 +41,13 @@ public class Player extends Actor {
} }
@Override @Override
public void act(float deltaTime) { public void act(float dt) {
super.act(deltaTime); super.act(dt);
this.setX(home.getX() + this.home.getRadius()*MathUtils.cosDeg(this.getRotation())); this.setX(home.getX() + this.home.getRadius()*MathUtils.cosDeg(this.getRotation()));
this.setY(home.getY() + this.home.getRadius()*MathUtils.cosDeg(this.getRotation())); this.setY(home.getY() + this.home.getRadius()*MathUtils.cosDeg(this.getRotation()));
//this.bow.act(deltaTime); //this.bow.act(dt);
} }
/** /**

View file

@ -22,7 +22,7 @@ public abstract class BaseScreen implements Screen {
@Override @Override
public void render(float dt) { public void render(float dt) {
// update actors // update Stages
uiStage.act(dt); uiStage.act(dt);
mainStage.act(dt); mainStage.act(dt);
@ -43,8 +43,10 @@ public abstract class BaseScreen implements Screen {
mainStage.dispose(); mainStage.dispose();
} }
// methods required by Screen interface @Override public void resize(int width, int height) {
@Override public void resize(int width, int height) {} mainStage.getViewport().update(width, height, true);
}
@Override public void pause() {} @Override public void pause() {}
@Override public void resume(){} @Override public void resume(){}
@Override public void show() {} @Override public void show() {}

View file

@ -50,14 +50,10 @@ public class StartScreen extends BaseScreen {
} }
@Override @Override
public void update(float deltaTime) { public void update(float dt) {
// //
} }
public void resize(int width, int height) {
mainStage.getViewport().update(width, height, true);
}
@Override @Override
public void dispose() { public void dispose() {
VisUI.dispose(); VisUI.dispose();