From 1aad5ef361cffe7d2f7607c350a3754d0dbae5fc Mon Sep 17 00:00:00 2001 From: RandomityGuy <31925790+RandomityGuy@users.noreply.github.com> Date: Wed, 12 Jun 2024 18:50:11 +0530 Subject: [PATCH] fix super speed and easter egg --- src/shapes/EasterEgg.hx | 1 + src/shapes/SuperSpeed.hx | 20 +++++++++----------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/shapes/EasterEgg.hx b/src/shapes/EasterEgg.hx index f838a6f0..77e7d622 100644 --- a/src/shapes/EasterEgg.hx +++ b/src/shapes/EasterEgg.hx @@ -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 { diff --git a/src/shapes/SuperSpeed.hx b/src/shapes/SuperSpeed.hx index edd00cb2..cd196e38 100644 --- a/src/shapes/SuperSpeed.hx +++ b/src/shapes/SuperSpeed.hx @@ -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)