double fisted gun action

This commit is contained in:
Philip Rosedale 2014-05-09 00:16:11 -07:00
parent 4a1672957e
commit a7f44bf207

View file

@ -28,7 +28,7 @@ var BULLET_VELOCITY = 5.0;
var MIN_THROWER_DELAY = 1000; var MIN_THROWER_DELAY = 1000;
var MAX_THROWER_DELAY = 1000; var MAX_THROWER_DELAY = 1000;
var LEFT_BUTTON_3 = 3; var LEFT_BUTTON_3 = 3;
var RELOAD_INTERVAL = 9; var RELOAD_INTERVAL = 5;
var showScore = false; var showScore = false;
@ -92,12 +92,12 @@ function printVector(string, vector) {
} }
function shootBullet(position, velocity) { function shootBullet(position, velocity) {
var BULLET_SIZE = 0.02; var BULLET_SIZE = 0.01;
var BULLET_GRAVITY = -0.02; var BULLET_GRAVITY = -0.02;
Particles.addParticle( Particles.addParticle(
{ position: position, { position: position,
radius: BULLET_SIZE, radius: BULLET_SIZE,
color: { red: 200, green: 0, blue: 0 }, color: { red: 10, green: 10, blue: 10 },
velocity: velocity, velocity: velocity,
gravity: { x: 0, y: BULLET_GRAVITY, z: 0 }, gravity: { x: 0, y: BULLET_GRAVITY, z: 0 },
damping: 0 }); damping: 0 });
@ -187,12 +187,23 @@ function keyPressEvent(event) {
if (event.text == "t") { if (event.text == "t") {
var time = MIN_THROWER_DELAY + Math.random() * MAX_THROWER_DELAY; var time = MIN_THROWER_DELAY + Math.random() * MAX_THROWER_DELAY;
Script.setTimeout(shootTarget, time); Script.setTimeout(shootTarget, time);
} if (event.text == ".") { } else if (event.text == ".") {
shootFromMouse(); shootFromMouse();
} else if (event.text == "r") {
playLoadSound();
} }
} }
function playLoadSound() {
audioOptions.position = Vec3.sum(Camera.getPosition(), Quat.getFront(Camera.getOrientation()));
Audio.playSound(loadSound, audioOptions);
}
MyAvatar.attach(gunModel, "RightHand", {x: -0.02, y: -.14, z: 0.07}, Quat.fromPitchYawRollDegrees(-70, -151, 72), 0.20); MyAvatar.attach(gunModel, "RightHand", {x: -0.02, y: -.14, z: 0.07}, Quat.fromPitchYawRollDegrees(-70, -151, 72), 0.20);
MyAvatar.attach(gunModel, "LeftHand", {x: -0.02, y: -.14, z: 0.07}, Quat.fromPitchYawRollDegrees(-70, -151, 72), 0.20);
// Give a bit of time to load before playing sound
Script.setTimeout(playLoadSound, 2000);
function update(deltaTime) { function update(deltaTime) {
// Check for mouseLook movement, update rotation // Check for mouseLook movement, update rotation
@ -309,6 +320,7 @@ function scriptEnding() {
Overlays.deleteOverlay(reticle); Overlays.deleteOverlay(reticle);
Overlays.deleteOverlay(text); Overlays.deleteOverlay(text);
MyAvatar.detachOne(gunModel); MyAvatar.detachOne(gunModel);
MyAvatar.detachOne(gunModel);
} }
Particles.particleCollisionWithVoxel.connect(particleCollisionWithVoxel); Particles.particleCollisionWithVoxel.connect(particleCollisionWithVoxel);