mirror of
https://github.com/Dejvino/roadtrip
synced 2024-12-22 19:58:49 +00:00
Added car sounds.
This commit is contained in:
parent
52bc6b6b01
commit
852c018f0c
@ -12,12 +12,11 @@ A game about a journey involving vehicles and obstacles.
|
|||||||
* Collidable objects - static and dynamic
|
* Collidable objects - static and dynamic
|
||||||
* People
|
* People
|
||||||
* Walking around (Player & NPCs)
|
* Walking around (Player & NPCs)
|
||||||
|
* Sounds - car engine, wheels & slips
|
||||||
|
|
||||||
### TODO
|
### TODO
|
||||||
* Enter / Exit a car
|
* Enter / Exit a car
|
||||||
* Sounds - car engine
|
|
||||||
* Sounds - crashes
|
* Sounds - crashes
|
||||||
* Sounds - wheels
|
|
||||||
* Target location (winning condition)
|
* Target location (winning condition)
|
||||||
* Main menu
|
* Main menu
|
||||||
* Health indicator
|
* Health indicator
|
||||||
|
BIN
assets/Sounds/wheel-slip.ogg
Normal file
BIN
assets/Sounds/wheel-slip.ogg
Normal file
Binary file not shown.
BIN
assets/Sounds/wheels.ogg
Normal file
BIN
assets/Sounds/wheels.ogg
Normal file
Binary file not shown.
@ -38,7 +38,7 @@ public class RoadTrip extends SimpleApplication implements ActionListener {
|
|||||||
final int SPORT = 3;
|
final int SPORT = 3;
|
||||||
final int FOOT = 4;
|
final int FOOT = 4;
|
||||||
|
|
||||||
final int carType = WEAK;
|
final int carType = SPORT;
|
||||||
|
|
||||||
private BulletAppState bulletAppState;
|
private BulletAppState bulletAppState;
|
||||||
private VehicleControl vehicle;
|
private VehicleControl vehicle;
|
||||||
@ -62,6 +62,8 @@ public class RoadTrip extends SimpleApplication implements ActionListener {
|
|||||||
private BetterCharacterControl playerPersonControl;
|
private BetterCharacterControl playerPersonControl;
|
||||||
|
|
||||||
AudioNode engineAudio;
|
AudioNode engineAudio;
|
||||||
|
AudioNode wheelsAudio;
|
||||||
|
AudioNode wheelSlipAudio;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void simpleInitApp() {
|
public void simpleInitApp() {
|
||||||
@ -71,8 +73,8 @@ public class RoadTrip extends SimpleApplication implements ActionListener {
|
|||||||
PhysicsTestHelper.createPhysicsTestWorld(rootNode, assetManager, bulletAppState.getPhysicsSpace());
|
PhysicsTestHelper.createPhysicsTestWorld(rootNode, assetManager, bulletAppState.getPhysicsSpace());
|
||||||
setupKeys();
|
setupKeys();
|
||||||
|
|
||||||
audioRenderer.setEnvironment(Environment.Dungeon);
|
//audioRenderer.setEnvironment(Environment.Dungeon);
|
||||||
AL10.alDistanceModel(AL11.AL_EXPONENT_DISTANCE);
|
//AL10.alDistanceModel(AL11.AL_EXPONENT_DISTANCE);
|
||||||
|
|
||||||
addMap();
|
addMap();
|
||||||
|
|
||||||
@ -248,10 +250,27 @@ public class RoadTrip extends SimpleApplication implements ActionListener {
|
|||||||
engineAudio.setReverbEnabled(true);
|
engineAudio.setReverbEnabled(true);
|
||||||
engineAudio.setRefDistance(100000000);
|
engineAudio.setRefDistance(100000000);
|
||||||
engineAudio.setMaxDistance(100000000);
|
engineAudio.setMaxDistance(100000000);
|
||||||
engineAudio.setLooping(true);
|
|
||||||
engineAudio.play();
|
engineAudio.play();
|
||||||
vehicleNode.attachChild(engineAudio);
|
vehicleNode.attachChild(engineAudio);
|
||||||
|
|
||||||
|
wheelsAudio = new AudioNode(assetManager, "Sounds/wheels.ogg", false);
|
||||||
|
wheelsAudio.setPositional(true);
|
||||||
|
wheelsAudio.setLooping(true);
|
||||||
|
//wheelsAudio.setReverbEnabled(true);
|
||||||
|
wheelsAudio.setRefDistance(100000000);
|
||||||
|
wheelsAudio.setMaxDistance(100000000);
|
||||||
|
wheelsAudio.play();
|
||||||
|
vehicleNode.attachChild(wheelsAudio);
|
||||||
|
|
||||||
|
wheelSlipAudio = new AudioNode(assetManager, "Sounds/wheel-slip.ogg", false);
|
||||||
|
wheelSlipAudio.setPositional(true);
|
||||||
|
wheelSlipAudio.setLooping(true);
|
||||||
|
//wheelsAudio.setReverbEnabled(true);
|
||||||
|
wheelSlipAudio.setRefDistance(100000000);
|
||||||
|
wheelSlipAudio.setMaxDistance(100000000);
|
||||||
|
wheelSlipAudio.play();
|
||||||
|
vehicleNode.attachChild(wheelSlipAudio);
|
||||||
|
|
||||||
playerNode = vehicleNode;
|
playerNode = vehicleNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -267,6 +286,24 @@ public class RoadTrip extends SimpleApplication implements ActionListener {
|
|||||||
//engineAudio.setLocalTranslation(x, 0, z);
|
//engineAudio.setLocalTranslation(x, 0, z);
|
||||||
engineAudio.updateGeometricState();
|
engineAudio.updateGeometricState();
|
||||||
engineAudio.setPitch(Math.max(0.5f, Math.min(accelerationSmooth / accelerationForce * 2f, 2.0f)));
|
engineAudio.setPitch(Math.max(0.5f, Math.min(accelerationSmooth / accelerationForce * 2f, 2.0f)));
|
||||||
|
|
||||||
|
wheelsAudio.updateGeometricState();
|
||||||
|
float wheelRot = Math.abs(vehicle.getWheel(0).getDeltaRotation() + vehicle.getWheel(1).getDeltaRotation()) / tpf / 40f;
|
||||||
|
// TODO: pitch
|
||||||
|
//System.out.println("wheel rot: " + wheelRot);
|
||||||
|
//wheelsAudio.setPitch(Math.max(0.5f, Math.min(wheelRot * 4f, 2.0f)));
|
||||||
|
wheelsAudio.setVolume(Math.max(0.0001f, Math.min(wheelRot, 1.0f)) - 0.0001f);
|
||||||
|
|
||||||
|
wheelSlipAudio.updateGeometricState();
|
||||||
|
float slipAll = 0f;
|
||||||
|
for (int i = 0; i < vehicle.getNumWheels(); i++) {
|
||||||
|
slipAll += vehicle.getWheel(i).getSkidInfo();
|
||||||
|
}
|
||||||
|
float slip = 1f - (slipAll) / vehicle.getNumWheels();
|
||||||
|
float wheelSlip = (slip * slip * slip * slip * slip * slip * slip) / tpf / 40f;
|
||||||
|
// TODO: pitch
|
||||||
|
//wheelsAudio.setPitch(Math.max(0.5f, Math.min(wheelRot * 4f, 2.0f)));
|
||||||
|
wheelSlipAudio.setVolume(Math.max(0.0001f, Math.min(wheelSlip, 1.0f)) - 0.0001f);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onAction(String binding, boolean value, float tpf) {
|
public void onAction(String binding, boolean value, float tpf) {
|
||||||
|
Loading…
Reference in New Issue
Block a user