Add spinny powerups

This commit is contained in:
RandomityGuy 2021-06-06 23:55:54 +05:30
parent cb12352f4f
commit c2811867ff
5 changed files with 31 additions and 5 deletions

View file

@ -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<Int>;
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)

View file

@ -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";

15
src/shapes/PowerUp.hx Normal file
View file

@ -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;
}
}

View file

@ -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";

View file

@ -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";