mirror of
https://github.com/RandomityGuy/MBHaxe.git
synced 2025-10-30 08:11:25 +00:00
PlayGui stuff
This commit is contained in:
parent
354bb52ea9
commit
f08fb95648
15 changed files with 469 additions and 67 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -3,5 +3,6 @@ data
|
|||
*.hl
|
||||
*.js
|
||||
*.js.map
|
||||
*.tmp
|
||||
.vscode
|
||||
native
|
||||
|
|
@ -87,10 +87,14 @@ class CameraController extends Object {
|
|||
// CameraYaw = Math.PI / 2;
|
||||
// CameraPitch = Math.PI / 4;
|
||||
|
||||
if (CameraPitch > Math.PI)
|
||||
CameraPitch = 3.141;
|
||||
if (CameraPitch < 0)
|
||||
CameraPitch = 0.001;
|
||||
if (CameraPitch > Math.PI / 2)
|
||||
CameraPitch = Math.PI / 2 - 0.001;
|
||||
if (CameraPitch < -Math.PI / 2)
|
||||
CameraPitch = -Math.PI / 2 + 0.001;
|
||||
// if (CameraPitch > Math.PI)
|
||||
// CameraPitch = 3.141;
|
||||
// if (CameraPitch < 0)
|
||||
// CameraPitch = 0.001;
|
||||
}
|
||||
|
||||
public function update(currentTime:Float, dt:Float) {
|
||||
|
|
@ -137,18 +141,34 @@ class CameraController extends Object {
|
|||
var upVec = new Vector(0, 0, 1);
|
||||
var quat = getRotQuat(upVec, up);
|
||||
|
||||
var q1 = new Quat();
|
||||
q1.initRotateAxis(0, 1, 0, CameraPitch);
|
||||
var q2 = new Quat();
|
||||
q2.initRotateAxis(0, 0, 1, CameraYaw);
|
||||
|
||||
var dir = new Vector(1, 0, 0);
|
||||
dir.transform(q1.toMatrix());
|
||||
dir.transform(q2.toMatrix());
|
||||
dir = dir.multiply(2.5);
|
||||
|
||||
var x = CameraDistance * Math.sin(CameraPitch) * Math.cos(CameraYaw);
|
||||
var y = CameraDistance * Math.sin(CameraPitch) * Math.sin(CameraYaw);
|
||||
var z = CameraDistance * Math.cos(CameraPitch);
|
||||
|
||||
var directionVec = new Vector(x, y, z);
|
||||
var cameraVerticalTranslation = new Vector(0, 0, 0.3);
|
||||
cameraVerticalTranslation.transform(q1.toMatrix());
|
||||
cameraVerticalTranslation.transform(q2.toMatrix());
|
||||
cameraVerticalTranslation.transform(orientationQuat.toMatrix());
|
||||
|
||||
var directionVec = dir; // new Vector(x, y, z);
|
||||
directionVec.transform(orientationQuat.toMatrix());
|
||||
// cameraVerticalTranslation.transform(orientationQuat.toMatrix());
|
||||
|
||||
var targetpos = this.marble.getAbsPos().getPosition();
|
||||
|
||||
var toPos = targetpos.add(directionVec);
|
||||
var toPos = targetpos.add(directionVec).add(cameraVerticalTranslation);
|
||||
camera.pos = toPos;
|
||||
camera.target = targetpos;
|
||||
camera.target = targetpos.add(cameraVerticalTranslation); // .add(cameraVerticalTranslation);
|
||||
|
||||
var closeness = 0.1;
|
||||
var rayCastOrigin = targetpos.add(up.multiply(marble._radius));
|
||||
|
|
@ -175,8 +195,10 @@ class CameraController extends Object {
|
|||
|
||||
var toPos = targetpos.add(directionVec);
|
||||
camera.pos = toPos;
|
||||
|
||||
// camera.target = null;
|
||||
// camera.target = targetpos.add(cameraVerticalTranslation);
|
||||
// this.x = targetpos.x + directionVec.x;
|
||||
|
||||
// this.y = targetpos.y + directionVec.y;
|
||||
// this.z = targetpos.z + directionVec.z;
|
||||
// this.level.scene.camera.follow = {pos: this, target: this.marble};
|
||||
|
|
|
|||
|
|
@ -111,9 +111,12 @@ class DtsObject extends GameObject {
|
|||
public function init(level:MarbleWorld) {
|
||||
this.dts = ResourceLoader.loadDts(this.dtsPath);
|
||||
this.directoryPath = Path.directory(this.dtsPath);
|
||||
this.level = level;
|
||||
if (level != null)
|
||||
this.level = level;
|
||||
|
||||
isInstanced = this.level.instanceManager.isInstanced(this) && useInstancing;
|
||||
var isInstanced = false;
|
||||
if (this.level != null)
|
||||
isInstanced = this.level.instanceManager.isInstanced(this) && useInstancing;
|
||||
if (!isInstanced)
|
||||
this.computeMaterials();
|
||||
|
||||
|
|
@ -301,8 +304,10 @@ class DtsObject extends GameObject {
|
|||
|
||||
rootObject.scaleX = -1;
|
||||
|
||||
this.boundingCollider = new BoxCollisionEntity(this.level.instanceManager.getObjectBounds(cast this), cast this);
|
||||
this.boundingCollider.setTransform(this.getTransform());
|
||||
if (this.level != null) {
|
||||
this.boundingCollider = new BoxCollisionEntity(this.level.instanceManager.getObjectBounds(cast this), cast this);
|
||||
this.boundingCollider.setTransform(this.getTransform());
|
||||
}
|
||||
}
|
||||
|
||||
function computeMaterials() {
|
||||
|
|
|
|||
|
|
@ -14,4 +14,8 @@ class GameObject extends Object {
|
|||
public function onMarbleEnter(time:Float) {}
|
||||
|
||||
public function onMarbleLeave(time:Float) {}
|
||||
|
||||
public function onLevelStart() {}
|
||||
|
||||
public function reset() {}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ class Main extends hxd.App {
|
|||
dtsObj = new SuperSpeed();
|
||||
dtsObj.x = -3;
|
||||
|
||||
world = new MarbleWorld(s3d);
|
||||
world = new MarbleWorld(s3d, s2d);
|
||||
|
||||
var db = new InteriorObject();
|
||||
db.interiorFile = "data/interiors/beginner/beginner_finish.dif";
|
||||
|
|
@ -117,8 +117,6 @@ class Main extends hxd.App {
|
|||
ag.y = 6;
|
||||
world.addDtsObject(ag);
|
||||
|
||||
var pg = new PlayGui();
|
||||
pg.init(s2d);
|
||||
// var le:ParticleEmitterOptions = {
|
||||
|
||||
// ejectionPeriod: 0.01,
|
||||
|
|
@ -203,6 +201,11 @@ class Main extends hxd.App {
|
|||
world.update(dt);
|
||||
}
|
||||
|
||||
override function render(e:h3d.Engine) {
|
||||
this.world.render(e);
|
||||
super.render(e);
|
||||
}
|
||||
|
||||
static function main() {
|
||||
h3d.mat.PbrMaterialSetup.set();
|
||||
new Main();
|
||||
|
|
|
|||
|
|
@ -784,6 +784,7 @@ class Marble extends GameObject {
|
|||
}
|
||||
if (currentTime - this.helicopterEnableTime < 5) {
|
||||
this.helicopter.setPosition(x, y, z);
|
||||
this.helicopter.setRotationQuat(this.level.getOrientationQuat(currentTime));
|
||||
} else {
|
||||
this.helicopter.setPosition(1e8, 1e8, 1e8);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package src;
|
||||
|
||||
import gui.PlayGui;
|
||||
import src.ParticleSystem.ParticleManager;
|
||||
import src.Util;
|
||||
import h3d.Quat;
|
||||
|
|
@ -19,11 +20,13 @@ import h3d.scene.CustomObject;
|
|||
import collision.CollisionWorld;
|
||||
import src.Marble;
|
||||
|
||||
class MarbleWorld {
|
||||
class MarbleWorld extends Scheduler {
|
||||
public var collisionWorld:CollisionWorld;
|
||||
public var instanceManager:InstanceManager;
|
||||
public var particleManager:ParticleManager;
|
||||
|
||||
var playGui:PlayGui;
|
||||
|
||||
public var interiors:Array<InteriorObject> = [];
|
||||
public var pathedInteriors:Array<PathedInterior> = [];
|
||||
public var marbles:Array<Marble> = [];
|
||||
|
|
@ -33,6 +36,8 @@ class MarbleWorld {
|
|||
var shapeOrTriggerInside:Array<DtsObject> = [];
|
||||
|
||||
public var currentTime:Float = 0;
|
||||
public var elapsedTime:Float = 0;
|
||||
public var bonusTime:Float = 0;
|
||||
public var sky:Sky;
|
||||
|
||||
public var scene:Scene;
|
||||
|
|
@ -40,6 +45,7 @@ class MarbleWorld {
|
|||
public var marble:Marble;
|
||||
public var worldOrientation:Quat;
|
||||
public var currentUp = new Vector(0, 0, 1);
|
||||
public var outOfBounds:Bool = false;
|
||||
|
||||
var orientationChangeTime = -1e8;
|
||||
var oldOrientationQuat = new Quat();
|
||||
|
|
@ -47,17 +53,69 @@ class MarbleWorld {
|
|||
/** The new target camera orientation quat */
|
||||
public var newOrientationQuat = new Quat();
|
||||
|
||||
public function new(scene:Scene) {
|
||||
public function new(scene:Scene, scene2d:h2d.Scene) {
|
||||
this.collisionWorld = new CollisionWorld();
|
||||
this.scene = scene;
|
||||
this.playGui = new PlayGui();
|
||||
this.instanceManager = new InstanceManager(scene);
|
||||
this.particleManager = new ParticleManager(cast this);
|
||||
this.sky = new Sky();
|
||||
sky.dmlPath = "data/skies/sky_day.dml";
|
||||
sky.init(cast this);
|
||||
playGui.init(scene2d);
|
||||
scene.addChild(sky);
|
||||
}
|
||||
|
||||
public function start() {
|
||||
restart();
|
||||
for (interior in this.interiors)
|
||||
interior.onLevelStart();
|
||||
for (shape in this.dtsObjects)
|
||||
shape.onLevelStart();
|
||||
}
|
||||
|
||||
public function restart() {
|
||||
this.currentTime = 0;
|
||||
this.elapsedTime = 0;
|
||||
this.bonusTime = 0;
|
||||
this.outOfBounds = false;
|
||||
this.marble.camera.CameraPitch = 0.45;
|
||||
|
||||
for (shape in dtsObjects)
|
||||
shape.reset();
|
||||
for (interior in this.interiors)
|
||||
interior.reset();
|
||||
|
||||
this.currentUp = new Vector(0, 0, 1);
|
||||
this.orientationChangeTime = -1e8;
|
||||
this.oldOrientationQuat = new Quat();
|
||||
this.newOrientationQuat = new Quat();
|
||||
this.deselectPowerUp();
|
||||
|
||||
this.clearSchedule();
|
||||
}
|
||||
|
||||
public function updateGameState() {
|
||||
if (this.currentTime < 0.5) {
|
||||
this.playGui.setCenterText('none');
|
||||
}
|
||||
if (this.currentTime >= 0.5 && this.currentTime < 2) {
|
||||
this.playGui.setCenterText('ready');
|
||||
}
|
||||
if (this.currentTime >= 2 && this.currentTime < 3.5) {
|
||||
this.playGui.setCenterText('set');
|
||||
}
|
||||
if (this.currentTime >= 3.5 && this.currentTime < 5.5) {
|
||||
this.playGui.setCenterText('go');
|
||||
}
|
||||
if (this.currentTime >= 5.5) {
|
||||
this.playGui.setCenterText('none');
|
||||
}
|
||||
if (this.outOfBounds) {
|
||||
this.playGui.setCenterText('outofbounds');
|
||||
}
|
||||
}
|
||||
|
||||
public function addInterior(obj:InteriorObject) {
|
||||
this.interiors.push(obj);
|
||||
obj.init(cast this);
|
||||
|
|
@ -108,6 +166,8 @@ class MarbleWorld {
|
|||
}
|
||||
|
||||
public function update(dt:Float) {
|
||||
this.tickSchedule(currentTime);
|
||||
this.updateGameState();
|
||||
for (obj in dtsObjects) {
|
||||
obj.update(currentTime, dt);
|
||||
}
|
||||
|
|
@ -116,12 +176,32 @@ class MarbleWorld {
|
|||
}
|
||||
this.instanceManager.update(dt);
|
||||
this.particleManager.update(1000 * currentTime, dt);
|
||||
currentTime += dt;
|
||||
this.updateTimer(dt);
|
||||
this.playGui.update(currentTime, dt);
|
||||
|
||||
if (this.marble != null) {
|
||||
callCollisionHandlers(marble);
|
||||
}
|
||||
}
|
||||
|
||||
public function render(e:h3d.Engine) {
|
||||
this.playGui.render(e);
|
||||
}
|
||||
|
||||
public function updateTimer(dt:Float) {
|
||||
currentTime += dt;
|
||||
if (this.bonusTime != 0) {
|
||||
this.bonusTime -= dt;
|
||||
if (this.bonusTime < 0) {
|
||||
this.elapsedTime -= this.bonusTime;
|
||||
this.bonusTime = 0;
|
||||
}
|
||||
} else {
|
||||
this.elapsedTime += dt;
|
||||
}
|
||||
playGui.formatTimer(this.elapsedTime);
|
||||
}
|
||||
|
||||
function callCollisionHandlers(marble:Marble) {
|
||||
var contacts = this.collisionWorld.radiusSearch(marble.getAbsPos().getPosition(), marble._radius);
|
||||
var newImmunity = [];
|
||||
|
|
@ -172,24 +252,14 @@ class MarbleWorld {
|
|||
if (this.marble.heldPowerup == powerUp)
|
||||
return false;
|
||||
this.marble.heldPowerup = powerUp;
|
||||
// for (let overlayShape
|
||||
// of
|
||||
// this.overlayShapes
|
||||
// )
|
||||
// {
|
||||
// if (overlayShape.dtsPath.includes("gem"))
|
||||
// continue;
|
||||
// // Show the corresponding icon in the HUD
|
||||
// if (overlayShape.dtsPath == = powerUp.dtsPath)
|
||||
// this.overlayScene.add(overlayShape.group);
|
||||
// else
|
||||
// this.overlayScene.remove(overlayShape.group);
|
||||
// }
|
||||
// if (!this.rewinding)
|
||||
// AudioManager.play(powerUp.sounds[0]);
|
||||
this.playGui.setPowerupImage(powerUp.identifier);
|
||||
return true;
|
||||
}
|
||||
|
||||
public function deselectPowerUp() {
|
||||
this.playGui.setPowerupImage("");
|
||||
}
|
||||
|
||||
/** Get the current interpolated orientation quaternion. */
|
||||
public function getOrientationQuat(time:Float) {
|
||||
var completion = Util.clamp((time - this.orientationChangeTime) / 0.3, 0, 1);
|
||||
|
|
@ -244,3 +314,57 @@ class MarbleWorld {
|
|||
this.orientationChangeTime = time;
|
||||
}
|
||||
}
|
||||
|
||||
typedef ScheduleInfo = {
|
||||
var id:Float;
|
||||
var stringId:String;
|
||||
var time:Float;
|
||||
var callBack:Void->Any;
|
||||
}
|
||||
|
||||
abstract class Scheduler {
|
||||
var scheduled:Array<ScheduleInfo> = [];
|
||||
|
||||
public function tickSchedule(time:Float) {
|
||||
for (item in this.scheduled) {
|
||||
if (time >= item.time) {
|
||||
this.scheduled.remove(item);
|
||||
item.callBack();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function schedule(time:Float, callback:Void->Any, stringId:String = null) {
|
||||
var id = Math.random();
|
||||
this.scheduled.push({
|
||||
id: id,
|
||||
stringId: '${id}',
|
||||
time: time,
|
||||
callBack: callback
|
||||
});
|
||||
return id;
|
||||
}
|
||||
|
||||
/** Cancels a schedule */
|
||||
public function cancel(id:Float) {
|
||||
var idx = this.scheduled.filter((val) -> {
|
||||
return val.id == id;
|
||||
});
|
||||
if (idx.length == 0)
|
||||
return;
|
||||
this.scheduled.remove(idx[0]);
|
||||
}
|
||||
|
||||
public function clearSchedule() {
|
||||
this.scheduled = [];
|
||||
}
|
||||
|
||||
public function clearScheduleId(id:String) {
|
||||
var idx = this.scheduled.filter((val) -> {
|
||||
return val.stringId == id;
|
||||
});
|
||||
if (idx.length == 0)
|
||||
return;
|
||||
this.scheduled.remove(idx[0]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -203,7 +203,7 @@ class PathedInterior extends InteriorObject {
|
|||
return tform;
|
||||
}
|
||||
|
||||
function reset() {
|
||||
override function reset() {
|
||||
this.currentTime = 0;
|
||||
this.targetTime = -1;
|
||||
this.changeTime = 0;
|
||||
|
|
|
|||
|
|
@ -80,27 +80,27 @@ class Collision {
|
|||
}
|
||||
|
||||
// Check points
|
||||
if (center.sub(v0).lengthSq() < radiusSq) {
|
||||
res.result = true;
|
||||
res.point = v0;
|
||||
res.normal = center.sub(v0).normalized();
|
||||
// center.sub(v0).normalized();
|
||||
return res;
|
||||
}
|
||||
if (center.sub(v1).lengthSq() < radiusSq) {
|
||||
res.result = true;
|
||||
res.point = v1;
|
||||
res.normal = center.sub(v1).normalized();
|
||||
// if (center.sub(v0).lengthSq() < radiusSq) {
|
||||
// res.result = true;
|
||||
// res.point = v0;
|
||||
// res.normal = center.sub(v0).normalized();
|
||||
// // center.sub(v0).normalized();
|
||||
// return res;
|
||||
// }
|
||||
// if (center.sub(v1).lengthSq() < radiusSq) {
|
||||
// res.result = true;
|
||||
// res.point = v1;
|
||||
// res.normal = center.sub(v1).normalized();
|
||||
|
||||
return res;
|
||||
}
|
||||
if (center.sub(v2).lengthSq() < radiusSq) {
|
||||
res.result = true;
|
||||
res.point = v2;
|
||||
res.normal = center.sub(v2).normalized();
|
||||
// return res;
|
||||
// }
|
||||
// if (center.sub(v2).lengthSq() < radiusSq) {
|
||||
// res.result = true;
|
||||
// res.point = v2;
|
||||
// res.normal = center.sub(v2).normalized();
|
||||
|
||||
return res;
|
||||
}
|
||||
// return res;
|
||||
// }
|
||||
|
||||
// Check edges
|
||||
var r1 = IntersectLineSphere(v0, v1, center, radius);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,18 @@
|
|||
package gui;
|
||||
|
||||
import format.gif.Data.Block;
|
||||
import hxd.res.BitmapFont;
|
||||
import h2d.Text;
|
||||
import h3d.shader.pbr.PropsValues;
|
||||
import h3d.Vector;
|
||||
import hxd.fmt.hmd.Data.AnimationEvent;
|
||||
import h2d.Tile;
|
||||
import h3d.mat.DepthBuffer;
|
||||
import h3d.mat.Texture;
|
||||
import h3d.mat.Material;
|
||||
import h3d.scene.Mesh;
|
||||
import h3d.prim.Cube;
|
||||
import src.DtsObject;
|
||||
import h2d.Anim;
|
||||
import h2d.Bitmap;
|
||||
import src.ResourceLoader;
|
||||
|
|
@ -9,10 +22,28 @@ class PlayGui {
|
|||
|
||||
public function new() {}
|
||||
|
||||
var numbers:Array<Anim> = [];
|
||||
var timerNumbers:Array<Anim> = [];
|
||||
var timerPoint:Bitmap;
|
||||
var timerColon:Bitmap;
|
||||
|
||||
var gemCountNumbers:Array<Anim> = [];
|
||||
var gemCountSlash:Bitmap;
|
||||
var gemImageScene:h3d.scene.Scene;
|
||||
var gemImageSceneTarget:Texture;
|
||||
var gemImageObject:DtsObject;
|
||||
|
||||
var powerupBox:Bitmap;
|
||||
var powerupImageScene:h3d.scene.Scene;
|
||||
var powerupImageSceneTarget:Texture;
|
||||
var powerupImageObject:DtsObject;
|
||||
|
||||
var RSGOCenterText:Anim;
|
||||
|
||||
var helpTextForeground:Text;
|
||||
var helpTextBackground:Text;
|
||||
var alertTextForeground:Text;
|
||||
var alertTextBackground:Text;
|
||||
|
||||
public function init(scene2d:h2d.Scene) {
|
||||
this.scene2d = scene2d;
|
||||
|
||||
|
|
@ -23,12 +54,30 @@ class PlayGui {
|
|||
}
|
||||
|
||||
for (i in 0...7) {
|
||||
numbers.push(new Anim(numberTiles, 0, scene2d));
|
||||
timerNumbers.push(new Anim(numberTiles, 0, scene2d));
|
||||
}
|
||||
|
||||
for (i in 0...4) {
|
||||
gemCountNumbers.push(new Anim(numberTiles, 0, scene2d));
|
||||
}
|
||||
|
||||
var rsgo = [];
|
||||
rsgo.push(ResourceLoader.getImage("data/ui/game/ready.png").toTile());
|
||||
rsgo.push(ResourceLoader.getImage("data/ui/game/set.png").toTile());
|
||||
rsgo.push(ResourceLoader.getImage("data/ui/game/go.png").toTile());
|
||||
rsgo.push(ResourceLoader.getImage("data/ui/game/outofbounds.png").toTile());
|
||||
RSGOCenterText = new Anim(rsgo, 0, scene2d);
|
||||
|
||||
timerPoint = new Bitmap(ResourceLoader.getImage('data/ui/game/numbers/point.png').toTile(), scene2d);
|
||||
timerColon = new Bitmap(ResourceLoader.getImage('data/ui/game/numbers/colon.png').toTile(), scene2d);
|
||||
gemCountSlash = new Bitmap(ResourceLoader.getImage('data/ui/game/numbers/slash.png').toTile(), scene2d);
|
||||
|
||||
powerupBox = new Bitmap(ResourceLoader.getImage('data/ui/game/powerup.png').toTile(), scene2d);
|
||||
initTimer();
|
||||
initGemCounter();
|
||||
initCenterText();
|
||||
initPowerupBox();
|
||||
initTexts();
|
||||
}
|
||||
|
||||
public function initTimer() {
|
||||
|
|
@ -42,14 +91,207 @@ class PlayGui {
|
|||
return (y / 480) * screenHeight;
|
||||
}
|
||||
|
||||
numbers[0].x = toScreenSpaceX(23);
|
||||
numbers[1].x = toScreenSpaceX(47);
|
||||
timerNumbers[0].x = toScreenSpaceX(23);
|
||||
timerNumbers[1].x = toScreenSpaceX(47);
|
||||
timerColon.x = toScreenSpaceX(67);
|
||||
numbers[2].x = toScreenSpaceX(83);
|
||||
numbers[3].x = toScreenSpaceX(107);
|
||||
timerNumbers[2].x = toScreenSpaceX(83);
|
||||
timerNumbers[3].x = toScreenSpaceX(107);
|
||||
timerPoint.x = toScreenSpaceX(127);
|
||||
numbers[4].x = toScreenSpaceX(143);
|
||||
numbers[5].x = toScreenSpaceX(167);
|
||||
numbers[6].x = toScreenSpaceX(191);
|
||||
timerNumbers[4].x = toScreenSpaceX(143);
|
||||
timerNumbers[5].x = toScreenSpaceX(167);
|
||||
timerNumbers[6].x = toScreenSpaceX(191);
|
||||
}
|
||||
|
||||
public function initCenterText() {
|
||||
RSGOCenterText.x = scene2d.width / 2 - RSGOCenterText.frames[0].width / 2;
|
||||
RSGOCenterText.y = scene2d.height * 0.3; // - RSGOCenterText.frames[0].height / 2;
|
||||
}
|
||||
|
||||
public function setCenterText(identifier:String) {
|
||||
if (identifier == 'none') {
|
||||
this.RSGOCenterText.visible = false;
|
||||
} else if (identifier == 'ready') {
|
||||
this.RSGOCenterText.visible = true;
|
||||
this.RSGOCenterText.currentFrame = 0;
|
||||
RSGOCenterText.x = scene2d.width / 2 - RSGOCenterText.frames[0].width / 2;
|
||||
} else if (identifier == 'set') {
|
||||
this.RSGOCenterText.visible = true;
|
||||
this.RSGOCenterText.currentFrame = 1;
|
||||
RSGOCenterText.x = scene2d.width / 2 - RSGOCenterText.frames[1].width / 2;
|
||||
} else if (identifier == 'go') {
|
||||
this.RSGOCenterText.visible = true;
|
||||
this.RSGOCenterText.currentFrame = 2;
|
||||
RSGOCenterText.x = scene2d.width / 2 - RSGOCenterText.frames[2].width / 2;
|
||||
} else if (identifier == 'outofbounds') {
|
||||
this.RSGOCenterText.visible = true;
|
||||
this.RSGOCenterText.currentFrame = 3;
|
||||
RSGOCenterText.x = scene2d.width / 2 - RSGOCenterText.frames[3].width / 2;
|
||||
}
|
||||
}
|
||||
|
||||
public function initGemCounter() {
|
||||
gemCountNumbers[0].x = 30;
|
||||
gemCountNumbers[1].x = 54;
|
||||
gemCountSlash.x = 75;
|
||||
gemCountNumbers[2].x = 96;
|
||||
gemCountNumbers[3].x = 120;
|
||||
|
||||
this.gemImageScene = new h3d.scene.Scene();
|
||||
var gemImageRenderer = cast(this.gemImageScene.renderer, h3d.scene.pbr.Renderer);
|
||||
gemImageRenderer.skyMode = Hide;
|
||||
|
||||
gemImageSceneTarget = new Texture(60, 60, [Target]);
|
||||
gemImageSceneTarget.depthBuffer = new DepthBuffer(60, 60);
|
||||
|
||||
var gemImageSceneTargetBitmap = new Bitmap(Tile.fromTexture(gemImageSceneTarget), scene2d);
|
||||
gemImageSceneTargetBitmap.x = -8;
|
||||
gemImageSceneTargetBitmap.y = -8;
|
||||
|
||||
gemImageObject = new DtsObject();
|
||||
gemImageObject.dtsPath = "data/shapes/items/gem.dts";
|
||||
gemImageObject.ambientRotate = true;
|
||||
gemImageObject.showSequences = false;
|
||||
gemImageObject.matNameOverride.set("base.gem", "base.gem.png");
|
||||
gemImageObject.ambientSpinFactor /= -2;
|
||||
// ["base.gem"] = color + ".gem";
|
||||
gemImageObject.init(null);
|
||||
for (mat in gemImageObject.materials) {
|
||||
mat.mainPass.addShader(new PropsValues(1, 0, 0, 1));
|
||||
}
|
||||
gemImageScene.addChild(gemImageObject);
|
||||
var gemImageCenter = gemImageObject.getBounds().getCenter();
|
||||
|
||||
gemImageScene.camera.pos = new Vector(0, 3, gemImageCenter.z);
|
||||
gemImageScene.camera.target = new Vector(gemImageCenter.x, gemImageCenter.y, gemImageCenter.z);
|
||||
}
|
||||
|
||||
function initPowerupBox() {
|
||||
powerupBox.x = scene2d.width - 102;
|
||||
powerupBox.y = 6;
|
||||
|
||||
this.powerupImageScene = new h3d.scene.Scene();
|
||||
var powerupImageRenderer = cast(this.powerupImageScene.renderer, h3d.scene.pbr.Renderer);
|
||||
powerupImageRenderer.skyMode = Hide;
|
||||
|
||||
powerupImageSceneTarget = new Texture(68, 67, [Target]);
|
||||
powerupImageSceneTarget.depthBuffer = new DepthBuffer(68, 67);
|
||||
|
||||
var powerupImageSceneTargetBitmap = new Bitmap(Tile.fromTexture(powerupImageSceneTarget), scene2d);
|
||||
powerupImageSceneTargetBitmap.x = scene2d.width - 88;
|
||||
powerupImageSceneTargetBitmap.y = 18;
|
||||
}
|
||||
|
||||
function initTexts() {
|
||||
var fontdata = ResourceLoader.loader.load("data/font/DomCasual32px.fnt");
|
||||
var bfont = new BitmapFont(fontdata.entry);
|
||||
@:privateAccess bfont.loader = ResourceLoader.loader;
|
||||
helpTextBackground = new Text(bfont.toFont(), scene2d);
|
||||
helpTextBackground.text = "Hello Bruh";
|
||||
helpTextBackground.x = scene2d.width / 2 - helpTextBackground.textWidth / 2 + 1;
|
||||
helpTextBackground.y = scene2d.height * 0.45 + 1;
|
||||
helpTextBackground.textColor = 0x000000;
|
||||
|
||||
helpTextForeground = new Text(bfont.toFont(), scene2d);
|
||||
helpTextForeground.text = "Hello Bruh";
|
||||
helpTextForeground.x = scene2d.width / 2 - helpTextForeground.textWidth / 2;
|
||||
helpTextForeground.y = scene2d.height * 0.45;
|
||||
helpTextForeground.textColor = 0xFFFFFF;
|
||||
|
||||
alertTextBackground = new Text(bfont.toFont(), scene2d);
|
||||
alertTextBackground.text = "Hello Bruh";
|
||||
alertTextBackground.x = scene2d.width / 2 - alertTextBackground.textWidth / 2 + 1;
|
||||
alertTextBackground.y = scene2d.height - 102 + 1;
|
||||
alertTextBackground.textColor = 0x000000;
|
||||
|
||||
alertTextForeground = new Text(bfont.toFont(), scene2d);
|
||||
alertTextForeground.text = "Hello Bruh";
|
||||
alertTextForeground.x = scene2d.width / 2 - alertTextForeground.textWidth / 2;
|
||||
alertTextForeground.y = scene2d.height - 102;
|
||||
alertTextForeground.textColor = 0xFFE240;
|
||||
}
|
||||
|
||||
public function setPowerupImage(powerupIdentifier:String) {
|
||||
this.powerupImageScene.removeChildren();
|
||||
if (powerupIdentifier == "SuperJump") {
|
||||
powerupImageObject = new DtsObject();
|
||||
powerupImageObject.dtsPath = "data/shapes/items/superjump.dts";
|
||||
} else if (powerupIdentifier == "SuperSpeed") {
|
||||
powerupImageObject = new DtsObject();
|
||||
powerupImageObject.dtsPath = "data/shapes/items/superspeed.dts";
|
||||
} else if (powerupIdentifier == "ShockAbsorber") {
|
||||
powerupImageObject = new DtsObject();
|
||||
powerupImageObject.dtsPath = "data/shapes/items/shockabsorber.dts";
|
||||
} else if (powerupIdentifier == "SuperBounce") {
|
||||
powerupImageObject = new DtsObject();
|
||||
powerupImageObject.dtsPath = "data/shapes/items/superbounce.dts";
|
||||
} else if (powerupIdentifier == "Helicopter") {
|
||||
powerupImageObject = new DtsObject();
|
||||
powerupImageObject.dtsPath = "data/shapes/images/helicopter.dts";
|
||||
} else {
|
||||
powerupIdentifier = "";
|
||||
this.powerupImageObject = null;
|
||||
}
|
||||
|
||||
if (powerupIdentifier != "") {
|
||||
powerupImageObject.ambientRotate = true;
|
||||
powerupImageObject.ambientSpinFactor /= 2;
|
||||
powerupImageObject.showSequences = false;
|
||||
powerupImageObject.init(null);
|
||||
for (mat in powerupImageObject.materials) {
|
||||
mat.mainPass.addShader(new PropsValues(1, 0, 0, 1));
|
||||
}
|
||||
powerupImageScene.addChild(powerupImageObject);
|
||||
var powerupImageCenter = powerupImageObject.getBounds().getCenter();
|
||||
|
||||
powerupImageScene.camera.pos = new Vector(0, 4, powerupImageCenter.z);
|
||||
powerupImageScene.camera.target = new Vector(powerupImageCenter.x, powerupImageCenter.y, powerupImageCenter.z);
|
||||
}
|
||||
}
|
||||
|
||||
public function formatTimer(time:Float) {
|
||||
var et = time * 1000;
|
||||
var thousandth = et % 10;
|
||||
var hundredth = Math.floor((et % 1000) / 10);
|
||||
var totalSeconds = Math.floor(et / 1000);
|
||||
var seconds = totalSeconds % 60;
|
||||
var minutes = (totalSeconds - seconds) / 60;
|
||||
|
||||
var secondsOne = seconds % 10;
|
||||
var secondsTen = (seconds - secondsOne) / 10;
|
||||
var minutesOne = minutes % 10;
|
||||
var minutesTen = (minutes - minutesOne) / 10;
|
||||
var hundredthOne = hundredth % 10;
|
||||
var hundredthTen = (hundredth - hundredthOne) / 10;
|
||||
|
||||
timerNumbers[0].currentFrame = minutesTen;
|
||||
timerNumbers[1].currentFrame = minutesOne;
|
||||
timerNumbers[2].currentFrame = secondsTen;
|
||||
timerNumbers[3].currentFrame = secondsOne;
|
||||
timerNumbers[4].currentFrame = hundredthTen;
|
||||
timerNumbers[5].currentFrame = hundredthOne;
|
||||
timerNumbers[6].currentFrame = thousandth;
|
||||
}
|
||||
|
||||
public function render(engine:h3d.Engine) {
|
||||
engine.pushTarget(this.gemImageSceneTarget);
|
||||
|
||||
engine.clear(0, 1);
|
||||
this.gemImageScene.render(engine);
|
||||
|
||||
engine.popTarget();
|
||||
engine.pushTarget(this.powerupImageSceneTarget);
|
||||
|
||||
engine.clear(0, 1);
|
||||
this.powerupImageScene.render(engine);
|
||||
|
||||
engine.popTarget();
|
||||
}
|
||||
|
||||
public function update(currentTime:Float, dt:Float) {
|
||||
this.gemImageObject.update(currentTime, dt);
|
||||
this.gemImageScene.setElapsedTime(dt);
|
||||
if (this.powerupImageObject != null)
|
||||
this.powerupImageObject.update(currentTime, dt);
|
||||
this.powerupImageScene.setElapsedTime(dt);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,6 +23,6 @@ class Helicopter extends PowerUp {
|
|||
// if (!this.level.rewinding)
|
||||
// AudioManager.play(this.sounds[1]);
|
||||
// this.level.particles.createEmitter(superJumpParticleOptions, null, () => Util.vecOimoToThree(marble.body.getPosition()));
|
||||
// this.level.deselectPowerUp();
|
||||
this.level.deselectPowerUp();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,6 +22,6 @@ class ShockAbsorber extends PowerUp {
|
|||
// if (!this.level.rewinding)
|
||||
// AudioManager.play(this.sounds[1]);
|
||||
// this.level.particles.createEmitter(superJumpParticleOptions, null, () => Util.vecOimoToThree(marble.body.getPosition()));
|
||||
// this.level.deselectPowerUp();
|
||||
this.level.deselectPowerUp();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,6 +22,6 @@ class SuperBounce extends PowerUp {
|
|||
// if (!this.level.rewinding)
|
||||
// AudioManager.play(this.sounds[1]);
|
||||
// this.level.particles.createEmitter(superJumpParticleOptions, null, () => Util.vecOimoToThree(marble.body.getPosition()));
|
||||
// this.level.deselectPowerUp();
|
||||
this.level.deselectPowerUp();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,6 +54,6 @@ class SuperJump extends PowerUp {
|
|||
// if (!this.level.rewinding)
|
||||
// AudioManager.play(this.sounds[1]);
|
||||
// this.level.particles.createEmitter(superJumpParticleOptions, null, () => Util.vecOimoToThree(marble.body.getPosition()));
|
||||
// this.level.deselectPowerUp();
|
||||
this.level.deselectPowerUp();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -73,6 +73,6 @@ class SuperSpeed extends PowerUp {
|
|||
// if (!this.level.rewinding)
|
||||
// AudioManager.play(this.sounds[1]);
|
||||
this.level.particleManager.createEmitter(superSpeedParticleOptions, this.ssEmitterParticleData, null, () -> marble.getAbsPos().getPosition());
|
||||
// this.level.deselectPowerUp();
|
||||
this.level.deselectPowerUp();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue