mirror of
https://github.com/RandomityGuy/MBHaxe.git
synced 2026-01-09 16:52:14 +00:00
fix landmine explosion stuff, remove marble trail, make mis parsing faster??
This commit is contained in:
parent
b045be9f12
commit
3cbd1066ad
5 changed files with 63 additions and 31 deletions
|
|
@ -3,6 +3,7 @@
|
|||
-lib stb_ogg_sound
|
||||
--js marblegame.js
|
||||
-D windowSize=1280x720
|
||||
-D js-es=6
|
||||
-D keep-inline-positions
|
||||
--main Main
|
||||
-debug
|
||||
BIN
marblegame.hl
BIN
marblegame.hl
Binary file not shown.
|
|
@ -149,6 +149,7 @@ class Marble extends GameObject {
|
|||
public var contactEntities:Array<CollisionEntity> = [];
|
||||
|
||||
var queuedContacts:Array<CollisionInfo> = [];
|
||||
var appliedImpulses:Array<Vector> = [];
|
||||
|
||||
public var heldPowerup:PowerUp;
|
||||
public var lastContactNormal:Vector;
|
||||
|
|
@ -204,6 +205,8 @@ class Marble extends GameObject {
|
|||
|
||||
this.rollSound = AudioManager.playSound(ResourceLoader.getAudio("data/sound/rolling_hard.wav"), this.getAbsPos().getPosition(), true);
|
||||
this.slipSound = AudioManager.playSound(ResourceLoader.getAudio("data/sound/sliding.wav"), this.getAbsPos().getPosition(), true);
|
||||
this.rollSound.volume = 0;
|
||||
this.slipSound.volume = 0;
|
||||
this.shockabsorberSound = AudioManager.playSound(ResourceLoader.getAudio("data/sound/superbounceactive.wav"), null, true);
|
||||
this.shockabsorberSound.pause = true;
|
||||
this.superbounceSound = AudioManager.playSound(ResourceLoader.getAudio("data/sound/forcefield.wav"), null, true);
|
||||
|
|
@ -620,17 +623,18 @@ class Marble extends GameObject {
|
|||
}
|
||||
|
||||
function trailEmitter() {
|
||||
var speed = this.velocity.length();
|
||||
if (this._minTrailVel > speed) {
|
||||
if (this.trailEmitterNode != null) {
|
||||
this.level.particleManager.removeEmitter(this.trailEmitterNode);
|
||||
this.trailEmitterNode = null;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (this.trailEmitterNode == null)
|
||||
this.trailEmitterNode = this.level.particleManager.createEmitter(trailParticleOptions, trailEmitterData, null,
|
||||
() -> this.getAbsPos().getPosition());
|
||||
// Trails are bugged
|
||||
// var speed = this.velocity.length();
|
||||
// if (this._minTrailVel > speed) {
|
||||
// if (this.trailEmitterNode != null) {
|
||||
// this.level.particleManager.removeEmitter(this.trailEmitterNode);
|
||||
// this.trailEmitterNode = null;
|
||||
// }
|
||||
// return;
|
||||
// }
|
||||
// if (this.trailEmitterNode == null)
|
||||
// this.trailEmitterNode = this.level.particleManager.createEmitter(trailParticleOptions, trailEmitterData, null,
|
||||
// () -> this.getAbsPos().getPosition());
|
||||
}
|
||||
|
||||
function ReportBounce(pos:Vector, normal:Vector, speed:Float) {
|
||||
|
|
@ -703,12 +707,13 @@ class Marble extends GameObject {
|
|||
rollSound.addEffect(new Pitch());
|
||||
}
|
||||
|
||||
var pitch = scale;
|
||||
#if js
|
||||
// Apparently audio crashes the whole thing if pitch is less than 0.2
|
||||
if (pitch < 0.2)
|
||||
pitch = 0.2;
|
||||
#end
|
||||
var pitch = Util.clamp(rollVel.length() / 15, 0, 1) * 0.75 + 0.75;
|
||||
|
||||
// #if js
|
||||
// // Apparently audio crashes the whole thing if pitch is less than 0.2
|
||||
// if (pitch < 0.2)
|
||||
// pitch = 0.2;
|
||||
// #end
|
||||
var rPitch = rollSound.getEffect(Pitch);
|
||||
rPitch.value = pitch;
|
||||
}
|
||||
|
|
@ -869,6 +874,11 @@ class Marble extends GameObject {
|
|||
this._contactTime += timeStep;
|
||||
}
|
||||
|
||||
for (impulse in appliedImpulses) {
|
||||
this.velocity = this.velocity.add(impulse);
|
||||
}
|
||||
appliedImpulses = [];
|
||||
|
||||
piTime += timeStep;
|
||||
if (this.controllable) {
|
||||
for (interior in pathedInteriors) {
|
||||
|
|
@ -1014,6 +1024,10 @@ class Marble extends GameObject {
|
|||
}
|
||||
}
|
||||
|
||||
public function applyImpulse(impulse:Vector) {
|
||||
this.appliedImpulses.push(impulse);
|
||||
}
|
||||
|
||||
public function enableSuperBounce(time:Float) {
|
||||
this.superBounceEnableTime = time;
|
||||
}
|
||||
|
|
|
|||
18
src/Util.hx
18
src/Util.hx
|
|
@ -136,12 +136,28 @@ class Util {
|
|||
}
|
||||
if (c == strLiteralToken)
|
||||
inString = true;
|
||||
else if (StringTools.startsWith(str.substr(i), searchString))
|
||||
#if hl
|
||||
else if (Util.startsWithFromIndex(str, searchString, i))
|
||||
return i;
|
||||
#end
|
||||
#if js
|
||||
else if ((cast str).startsWith(searchString, i))
|
||||
return i;
|
||||
#end
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static function startsWithFromIndex(str:String, searchString:String, index:Int) {
|
||||
if (index + searchString.length > str.length)
|
||||
return false;
|
||||
for (i in 0...searchString.length) {
|
||||
if (searchString.charAt(i) != str.charAt(index + i))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function indexIsInStringLiteral(str:String, index:Int, strLiteralToken = '"') {
|
||||
var inString = false;
|
||||
for (i in 0...str.length) {
|
||||
|
|
|
|||
|
|
@ -125,6 +125,20 @@ class LandMine extends DtsObject {
|
|||
this.level.particleManager.createEmitter(landMineParticle, landMineParticleData, this.getAbsPos().getPosition());
|
||||
this.level.particleManager.createEmitter(landMineSmokeParticle, landMineSmokeParticleData, this.getAbsPos().getPosition());
|
||||
this.level.particleManager.createEmitter(landMineSparksParticle, landMineSparkParticleData, this.getAbsPos().getPosition());
|
||||
|
||||
var marble = this.level.marble;
|
||||
var minePos = this.getAbsPos().getPosition();
|
||||
var off = marble.getAbsPos().getPosition().sub(minePos);
|
||||
|
||||
var strength = computeExplosionStrength(off.length());
|
||||
|
||||
var impulse = off.normalized().multiply(strength);
|
||||
marble.applyImpulse(impulse);
|
||||
|
||||
// for (collider in this.colliders) {
|
||||
// var hull:CollisionHull = cast collider;
|
||||
// hull.force = strength;
|
||||
// }
|
||||
}
|
||||
// Normally, we would add a light here, but that's too expensive for THREE, apparently.
|
||||
|
||||
|
|
@ -153,19 +167,6 @@ class LandMine extends DtsObject {
|
|||
this.setHide(true);
|
||||
}
|
||||
|
||||
if (this.isCollideable) {
|
||||
var marble = this.level.marble;
|
||||
var minePos = this.getAbsPos().getPosition();
|
||||
var off = marble.getAbsPos().getPosition().sub(minePos);
|
||||
|
||||
var strength = computeExplosionStrength(off.length());
|
||||
|
||||
for (collider in this.colliders) {
|
||||
var hull:CollisionHull = cast collider;
|
||||
hull.force = strength;
|
||||
}
|
||||
}
|
||||
|
||||
var opacity = Util.clamp((timeState.timeSinceLoad - (this.disappearTime + 5)), 0, 1);
|
||||
this.setOpacity(opacity);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue