fix super speed and easter egg

This commit is contained in:
RandomityGuy 2024-06-12 18:50:11 +05:30
parent a43a13dbd9
commit 1aad5ef361
2 changed files with 10 additions and 11 deletions

View file

@ -16,6 +16,7 @@ class EasterEgg extends PowerUp {
this.pickUpName = "Easter Egg";
this.autoUse = true;
this.sharedNodeTransforms = true;
this.cooldownDuration = 1e8;
}
public function pickUp(marble:Marble):Bool {

View file

@ -72,21 +72,19 @@ class SuperSpeed extends PowerUp {
public function use(marble:Marble, timeState:TimeState) {
var movementVector = marble.getMarbleAxis()[0];
// Okay, so super speed directionality is a bit strange. In general, the direction is based on the normal vector of the last surface you had contact with.
var boostVec = movementVector.clone();
// var quat = level.newOrientationQuat;
// movementVector.applyQuaternion(quat);
var contactDot = movementVector.dot(marble.lastContactNormal);
boostVec.load(boostVec.sub(marble.lastContactNormal.multiply(contactDot)));
if (boostVec.lengthSq() > 0.01) {
boostVec.normalize();
} else {
boostVec.load(movementVector);
}
var quat2 = new Quat();
// Determine the necessary rotation to rotate the up vector to the contact normal.
quat2.initMoveTo(marble.currentUp, marble.lastContactNormal);
movementVector.transform(quat2.toMatrix());
var masslessFactor = marble.getMass() * 0.7 + 1 - 0.7;
marble.velocity = marble.velocity.add(movementVector.multiply(-25 * masslessFactor / marble.getMass()));
marble.velocity = marble.velocity.add(boostVec.multiply(-25 * masslessFactor / marble.getMass()));
// marble.body.addLinearVelocity(Util.vecThreeToOimo(movementVector).scale(24.7)); // Whirligig's determined value
// marble.body.addLinearVelocity(this.level.currentUp.scale(20)); // Simply add to vertical velocity
// if (!this.level.rewinding)
if (level.marble == marble && @:privateAccess !marble.isNetUpdate)
AudioManager.playSound(ResourceLoader.getResource("data/sound/use_speed.wav", ResourceLoader.getAudio, this.soundResources));
if (@:privateAccess !marble.isNetUpdate)