From 026fc45c1709761fc990aa08a08ac40ae67b44ed Mon Sep 17 00:00:00 2001 From: RandomityGuy <31925790+RandomityGuy@users.noreply.github.com> Date: Mon, 19 Jun 2023 01:09:35 +0530 Subject: [PATCH] some more tweaks --- src/CameraController.hx | 6 ++--- src/Marble.hx | 47 ++++++++++++++++++++++++++++++++-------- src/MarbleWorld.hx | 2 +- src/shapes/SuperJump.hx | 4 +++- src/shapes/SuperSpeed.hx | 3 ++- src/shapes/Trapdoor.hx | 2 +- 6 files changed, 48 insertions(+), 16 deletions(-) diff --git a/src/CameraController.hx b/src/CameraController.hx index 5803a653..5ddcc7ff 100644 --- a/src/CameraController.hx +++ b/src/CameraController.hx @@ -232,7 +232,7 @@ class CameraController extends Object { var up = new Vector(0, 0, 1); up.transform(orientationQuat.toMatrix()); var directionVector = new Vector(1, 0, 0); - var cameraVerticalTranslation = new Vector(0, 0, 0.325); + var cameraVerticalTranslation = new Vector(0, 0, 0.55); var q1 = new Quat(); q1.initRotateAxis(0, 1, 0, CameraPitch); @@ -248,7 +248,7 @@ class CameraController extends Object { camera.target = marblePosition.add(cameraVerticalTranslation); var closeness = 0.1; - var rayCastOrigin = marblePosition.add(level.currentUp.multiply(marble._radius)); + var rayCastOrigin = marblePosition.add(level.currentUp.multiply(marble._radius)).add(cameraVerticalTranslation); var processedShapes = []; for (i in 0...3) { @@ -289,7 +289,7 @@ class CameraController extends Object { var rightVec = camera.up.cross(forwardVec).normalized(); var upVec = forwardVec.cross(rightVec); - camera.target = marblePosition.add(upVec.multiply(0.3)); + camera.target = marblePosition.add(upVec.multiply(0.55)); camera.up = upVec; continue; } diff --git a/src/Marble.hx b/src/Marble.hx index bdbd0a82..ad2d4c0b 100644 --- a/src/Marble.hx +++ b/src/Marble.hx @@ -194,6 +194,9 @@ class Marble extends GameObject { public var _radius = 0.2; var _prevRadius:Float; + var _renderScale:Float = 1; + var _marbleScale:Float = 1; + var _defaultScale:Float = 1; var _maxRollVelocity:Float = 15; var _angularAcceleration:Float = 75; @@ -404,6 +407,9 @@ class Marble extends GameObject { var avgRadius = (b.xSize + b.ySize + b.zSize) / 6; if (isUltra) { this._radius = 0.3; + this._renderScale = 0.3 / avgRadius; + this._marbleScale = this._renderScale; + this._defaultScale = this._marbleScale; marbleDts.scale(0.3 / avgRadius); } else this._radius = avgRadius; @@ -1821,18 +1827,32 @@ class Marble extends GameObject { updatePowerupStates(timeState.currentAttemptTime, timeState.dt); - if (this._radius != 0.6666 && timeState.currentAttemptTime - this.megaMarbleEnableTime < 10) { + var s = this._renderScale * this._renderScale; + if (s <= this._marbleScale * this._marbleScale) + s = 0.1; + else + s = 0.4; + + s = timeState.dt / s * 2.302585124969482; + s = 1.0 / (s * (s * 0.2349999994039536 * s) + s + 1.0 + 0.4799999892711639 * s * s); + this._renderScale *= s; + s = 1 - s; + this._renderScale += s * this._marbleScale; + var marbledts = cast(this.getChildAt(0), DtsObject); + marbledts.setScale(this._renderScale); + + if (this._radius != 0.675 && timeState.currentAttemptTime - this.megaMarbleEnableTime < 10) { this._prevRadius = this._radius; - this._radius = 0.6666; - this.collider.radius = 0.6666; - var marbledts = cast(this.getChildAt(0), DtsObject); - marbledts.scale(this._radius / this._prevRadius); + this._radius = 0.675; + this.collider.radius = 0.675; + this._marbleScale *= 2.25; + var boost = this.level.currentUp.multiply(5); + this.velocity = this.velocity.add(boost); } else if (timeState.currentAttemptTime - this.megaMarbleEnableTime > 10) { if (this._radius != this._prevRadius) { this._radius = this._prevRadius; this.collider.radius = this._radius; - var marbledts = cast(this.getChildAt(0), DtsObject); - marbledts.scale(this._prevRadius / 0.6666); + this._marbleScale = this._defaultScale; } } @@ -1884,10 +1904,18 @@ class Marble extends GameObject { } } + public function getMass() { + if (this.level.timeState.currentAttemptTime - this.megaMarbleEnableTime < 10) { + return 5; + } else { + return 1; + } + } + public function useBlast() { if (this.level.blastAmount < 0.25 || this.level.game != "ultra") return; - var impulse = this.level.currentUp.multiply(Math.max(Math.sqrt(this.level.blastAmount), this.level.blastAmount) * 10); + var impulse = this.level.currentUp.multiply(this.level.blastAmount * 8); this.applyImpulse(impulse); AudioManager.playSound(ResourceLoader.getResource('data/sound/use_blast.wav', ResourceLoader.getAudio, this.soundResources)); this.blastWave.doSequenceOnceBeginTime = this.level.timeState.timeSinceLoad; @@ -1971,9 +1999,10 @@ class Marble extends GameObject { this.teleportEnableTime = null; if (this._radius != this._prevRadius) { this._radius = this._prevRadius; + this._marbleScale = this._renderScale = this._defaultScale; this.collider.radius = this._radius; var marbledts = cast(this.getChildAt(0), DtsObject); - marbledts.scale(this._prevRadius / 0.6666); + marbledts.scale(this._prevRadius / 0.675); } } } diff --git a/src/MarbleWorld.hx b/src/MarbleWorld.hx index f69e3151..298efb59 100644 --- a/src/MarbleWorld.hx +++ b/src/MarbleWorld.hx @@ -323,7 +323,7 @@ class MarbleWorld extends Scheduler { // ls.perPixelLighting = false; var shadow = scene.renderer.getPass(h3d.pass.DefaultShadowMap); - shadow.power = 0.5; + shadow.power = 1; shadow.mode = Dynamic; shadow.minDist = 0.1; shadow.maxDist = 200; diff --git a/src/shapes/SuperJump.hx b/src/shapes/SuperJump.hx index d1a5bb10..402b1a12 100644 --- a/src/shapes/SuperJump.hx +++ b/src/shapes/SuperJump.hx @@ -68,7 +68,9 @@ class SuperJump extends PowerUp { public function use(timeState:TimeState) { var marble = this.level.marble; - marble.velocity = marble.velocity.add(this.level.currentUp.multiply(20)); + var masslessFactor = marble.getMass() * 0.7 + 1 - 0.7; + var boost = this.level.currentUp.multiply(20 * masslessFactor / marble.getMass()); + marble.velocity = marble.velocity.add(boost); this.level.particleManager.createEmitter(superJumpParticleOptions, this.sjEmitterParticleData, null, () -> marble.getAbsPos().getPosition()); // marble.body.addLinearVelocity(this.level.currentUp.scale(20)); // Simply add to vertical velocity // if (!this.level.rewinding) diff --git a/src/shapes/SuperSpeed.hx b/src/shapes/SuperSpeed.hx index 97c36133..e6979a56 100644 --- a/src/shapes/SuperSpeed.hx +++ b/src/shapes/SuperSpeed.hx @@ -80,7 +80,8 @@ class SuperSpeed extends PowerUp { // Determine the necessary rotation to rotate the up vector to the contact normal. quat2.initMoveTo(this.level.currentUp, marble.lastContactNormal); movementVector.transform(quat2.toMatrix()); - marble.velocity = marble.velocity.add(movementVector.multiply(-25)); + var masslessFactor = marble.getMass() * 0.7 + 1 - 0.7; + marble.velocity = marble.velocity.add(movementVector.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 diff --git a/src/shapes/Trapdoor.hx b/src/shapes/Trapdoor.hx index 67789b53..19cd6f47 100644 --- a/src/shapes/Trapdoor.hx +++ b/src/shapes/Trapdoor.hx @@ -13,7 +13,7 @@ import src.MarbleWorld; class Trapdoor extends DtsObject { var lastContactTime = -1e8; - var timeout:Float = 0.2; + var timeout:Float = 0; var lastDirection:Int; var lastCompletion:Float = 0;