-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
374 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
{ | ||
"j_scout01": { | ||
"collisionModel": "orig/j_scout01.n/collide.obj", | ||
"normal": { | ||
"minSpeed": 40, | ||
"maxSpeed": 70, | ||
"acceleration": 3.5, | ||
"decceleration": 5 | ||
}, | ||
"displayModels": [ | ||
{ | ||
"displayModel": "orig/j_scout01.n/wings.obj", | ||
"displayTexture": "orig/j_scout01.n/texture_wingnone.ktx", | ||
"children": [ | ||
{ | ||
"displayModel": "orig/j_scout01.n/aileronl.obj", | ||
"displayTexture": "orig/j_scout01.n/texture_wingnone.ktx", | ||
"animationChannel": "wingVert", | ||
"relativeTransform": { | ||
"translation": [ | ||
-6.154, | ||
2.943, | ||
0.887 | ||
], | ||
"rotation": [ | ||
0.0, | ||
0.0, | ||
0.030538492, | ||
-0.9995336 | ||
], | ||
"scale": [ | ||
1, | ||
1, | ||
1 | ||
] | ||
} | ||
}, | ||
{ | ||
"displayModel": "orig/j_scout01.n/aileronr.obj", | ||
"displayTexture": "orig/j_scout01.n/texture_wingnone.ktx", | ||
"animationChannel": "wingVert", | ||
"relativeTransform": { | ||
"translation": [ | ||
6.0, | ||
2.943, | ||
0.887 | ||
], | ||
"rotation": [ | ||
0.0, | ||
0.0, | ||
0.030538514, | ||
0.9995336 | ||
], | ||
"scale": [ | ||
1, | ||
1, | ||
1 | ||
] | ||
} | ||
} | ||
] | ||
} | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
107 changes: 107 additions & 0 deletions
107
core/src/me/vinceh121/wanderer/entity/plane/AbstractPlane.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
package me.vinceh121.wanderer.entity.plane; | ||
|
||
import com.badlogic.gdx.math.MathUtils; | ||
import com.badlogic.gdx.math.Vector3; | ||
import com.badlogic.gdx.utils.Array; | ||
|
||
import me.vinceh121.wanderer.Wanderer; | ||
import me.vinceh121.wanderer.building.ExplosionPart; | ||
import me.vinceh121.wanderer.entity.AbstractClanLivingEntity; | ||
import me.vinceh121.wanderer.entity.DisplayModel; | ||
import me.vinceh121.wanderer.entity.IControllableEntity; | ||
import me.vinceh121.wanderer.input.Input; | ||
import me.vinceh121.wanderer.input.InputListener; | ||
import me.vinceh121.wanderer.input.InputListenerAdapter; | ||
|
||
public abstract class AbstractPlane extends AbstractClanLivingEntity implements IControllableEntity { | ||
private final Array<DisplayModel> explosionParts = new Array<>(); | ||
private final PlaneSpeedProfile normal, turbo; | ||
private boolean controlled; | ||
private float speedUpTime; | ||
|
||
public AbstractPlane(Wanderer game, AbstractPlaneMeta meta) { | ||
super(game); | ||
|
||
this.setCollideModel(meta.getCollisionModel()); | ||
|
||
for (final DisplayModel m : meta.getDisplayModels()) { | ||
this.getModels().add(new DisplayModel(m)); | ||
} | ||
|
||
for (final DisplayModel m : meta.getExplosionParts()) { | ||
this.explosionParts.add(new DisplayModel(m)); | ||
} | ||
|
||
this.normal = new PlaneSpeedProfile(meta.getNormal()); | ||
this.turbo = new PlaneSpeedProfile(meta.getTurbo()); | ||
} | ||
|
||
@Override | ||
public void tick(final float delta) { | ||
super.tick(delta); | ||
|
||
if (this.controlled) { | ||
if (this.game.getInputManager().isPressed(Input.FLY_BOOST)) { | ||
this.speedUpTime += delta; // FIXME upper clamp | ||
} else { | ||
this.speedUpTime = Math.max(0, this.speedUpTime - delta); | ||
} | ||
} | ||
|
||
final float speedUpProgress = this.speedUpTime / this.normal.getAcceleration(); | ||
final float speed = MathUtils.lerp(this.normal.getMinSpeed(), this.normal.getMaxSpeed(), speedUpProgress); | ||
|
||
this.translate(0, 0, -speed * delta); | ||
|
||
if (this.controlled) { | ||
this.moveCamera(); | ||
|
||
if (this.game.getInputManager().isPressed(Input.FIRE)) { | ||
this.fire(); | ||
} | ||
} | ||
} | ||
|
||
protected void moveCamera() { | ||
final Vector3 arm = new Vector3(0, 6, 17); | ||
arm.mul(this.getRotation()); | ||
arm.add(this.getTranslation()); | ||
|
||
final Vector3 watch = new Vector3(0, 0, -50); | ||
watch.mul(this.getRotation()); | ||
watch.add(this.getTranslation()); | ||
|
||
this.game.getCamera().position.set(arm); | ||
this.game.getCamera().lookAt(watch); | ||
} | ||
|
||
public abstract void fire(); | ||
|
||
@Override | ||
public void onDeath() { | ||
this.game.removeEntity(this); | ||
this.dispose(); | ||
|
||
for (final DisplayModel m : this.explosionParts) { | ||
final ExplosionPart part = new ExplosionPart(this.game, m); | ||
part.translate(this.getTranslation()); | ||
part.addEventListener("collideModelLoaded", e -> part.thrust(10)); | ||
this.game.addEntity(part); | ||
} | ||
} | ||
|
||
@Override | ||
public void onTakeControl() { | ||
this.controlled = true; | ||
} | ||
|
||
@Override | ||
public void onRemoveControl() { | ||
this.controlled = false; | ||
} | ||
|
||
@Override | ||
public InputListener getInputProcessor() { | ||
return new InputListenerAdapter(50); | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
core/src/me/vinceh121/wanderer/entity/plane/AbstractPlaneMeta.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package me.vinceh121.wanderer.entity.plane; | ||
|
||
import com.badlogic.gdx.utils.Array; | ||
|
||
import me.vinceh121.wanderer.IMeta; | ||
import me.vinceh121.wanderer.entity.DisplayModel; | ||
|
||
public abstract class AbstractPlaneMeta implements IMeta { | ||
private Array<DisplayModel> displayModels = new Array<>(); | ||
private Array<DisplayModel> explosionParts = new Array<>(); | ||
private String collisionModel; | ||
private final PlaneSpeedProfile normal = new PlaneSpeedProfile(), turbo = new PlaneSpeedProfile(); | ||
private float turboTime; | ||
|
||
public Array<DisplayModel> getDisplayModels() { | ||
return displayModels; | ||
} | ||
|
||
public void setDisplayModels(Array<DisplayModel> displayModels) { | ||
this.displayModels = displayModels; | ||
} | ||
|
||
public Array<DisplayModel> getExplosionParts() { | ||
return explosionParts; | ||
} | ||
|
||
public void setExplosionParts(Array<DisplayModel> explosionParts) { | ||
this.explosionParts = explosionParts; | ||
} | ||
|
||
public String getCollisionModel() { | ||
return collisionModel; | ||
} | ||
|
||
public void setCollisionModel(String collisionModel) { | ||
this.collisionModel = collisionModel; | ||
} | ||
|
||
public PlaneSpeedProfile getNormal() { | ||
return this.normal; | ||
} | ||
|
||
public PlaneSpeedProfile getTurbo() { | ||
return this.turbo; | ||
} | ||
|
||
public float getTurboTime() { | ||
return turboTime; | ||
} | ||
|
||
public void setTurboTime(float turboTime) { | ||
this.turboTime = turboTime; | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
core/src/me/vinceh121/wanderer/entity/plane/MachineGunPlane.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package me.vinceh121.wanderer.entity.plane; | ||
|
||
import me.vinceh121.wanderer.Wanderer; | ||
|
||
public class MachineGunPlane extends AbstractPlane { | ||
|
||
public MachineGunPlane(Wanderer game, MachineGunPlaneMeta meta) { | ||
super(game, meta); | ||
} | ||
|
||
@Override | ||
public void fire() { | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
core/src/me/vinceh121/wanderer/entity/plane/MachineGunPlaneMeta.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package me.vinceh121.wanderer.entity.plane; | ||
|
||
import me.vinceh121.wanderer.Wanderer; | ||
import me.vinceh121.wanderer.entity.AbstractEntity; | ||
|
||
public class MachineGunPlaneMeta extends AbstractPlaneMeta { | ||
|
||
@Override | ||
public AbstractEntity create(Wanderer game) { | ||
return new MachineGunPlane(game, this); | ||
} | ||
} |
Oops, something went wrong.