diff --git a/src/DtsObject.hx b/src/DtsObject.hx index ba3d53cb..b27bb59f 100644 --- a/src/DtsObject.hx +++ b/src/DtsObject.hx @@ -1,8 +1,6 @@ package src; -import shaders.DtsMaterial; import shaders.DtsTexture; -import shaders.DtsMaterialSetup; import h3d.shader.AlphaMult; import sys.io.File; import src.MarbleWorld; @@ -100,6 +98,9 @@ class DtsObject extends GameObject { var mountPointNodes:Array; var alphaShader:AlphaMult; + var ambientRotate = false; + var ambientSpinFactor = -1 / 3 * Math.PI * 2; + public function new() { super(); } @@ -731,6 +732,16 @@ class DtsObject extends GameObject { } } + if (this.ambientRotate) { + var spinAnimation = new Quat(); + spinAnimation.initRotateAxis(0, 0, -1, (currentTime + dt) * this.ambientSpinFactor); + + var orientation = this.getRotationQuat(); + // spinAnimation.multiply(orientation, spinAnimation); + + this.rootObject.setRotationQuat(spinAnimation); + } + for (i in 0...this.colliders.length) { var absTform = this.graphNodes[i].getAbsPos().clone(); if (this.colliders[i] != null) diff --git a/src/shapes/AntiGravity.hx b/src/shapes/AntiGravity.hx index 13f99924..ef70458a 100644 --- a/src/shapes/AntiGravity.hx +++ b/src/shapes/AntiGravity.hx @@ -2,7 +2,7 @@ package shapes; import src.DtsObject; -class AntiGravity extends DtsObject { +class AntiGravity extends PowerUp { public function new() { super(); this.dtsPath = "data/shapes/items/antigravity.dts"; diff --git a/src/shapes/PowerUp.hx b/src/shapes/PowerUp.hx new file mode 100644 index 00000000..661eb68c --- /dev/null +++ b/src/shapes/PowerUp.hx @@ -0,0 +1,15 @@ +package shapes; + +import src.DtsObject; + +class PowerUp extends DtsObject { + public var lastPickupTime:Float = -1; + public var cooldownDuration:Float = 7; + public var autoUse:Bool = false; + + public function new() { + super(); + this.isCollideable = false; + this.ambientRotate = true; + } +} diff --git a/src/shapes/SuperJump.hx b/src/shapes/SuperJump.hx index 8a872385..8d0d81b4 100644 --- a/src/shapes/SuperJump.hx +++ b/src/shapes/SuperJump.hx @@ -2,7 +2,7 @@ package shapes; import src.DtsObject; -class SuperJump extends DtsObject { +class SuperJump extends PowerUp { public function new() { super(); this.dtsPath = "data/shapes/items/superjump.dts"; diff --git a/src/shapes/SuperSpeed.hx b/src/shapes/SuperSpeed.hx index a895b76e..e2488d40 100644 --- a/src/shapes/SuperSpeed.hx +++ b/src/shapes/SuperSpeed.hx @@ -2,7 +2,7 @@ package shapes; import src.DtsObject; -class SuperSpeed extends DtsObject { +class SuperSpeed extends PowerUp { public function new() { super(); this.dtsPath = "data/shapes/items/superspeed.dts";