mirror of
https://github.com/RandomityGuy/MBHaxe.git
synced 2026-04-27 21:21:41 +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
|
-lib stb_ogg_sound
|
||||||
--js marblegame.js
|
--js marblegame.js
|
||||||
-D windowSize=1280x720
|
-D windowSize=1280x720
|
||||||
|
-D js-es=6
|
||||||
-D keep-inline-positions
|
-D keep-inline-positions
|
||||||
--main Main
|
--main Main
|
||||||
-debug
|
-debug
|
||||||
BIN
marblegame.hl
BIN
marblegame.hl
Binary file not shown.
|
|
@ -149,6 +149,7 @@ class Marble extends GameObject {
|
||||||
public var contactEntities:Array<CollisionEntity> = [];
|
public var contactEntities:Array<CollisionEntity> = [];
|
||||||
|
|
||||||
var queuedContacts:Array<CollisionInfo> = [];
|
var queuedContacts:Array<CollisionInfo> = [];
|
||||||
|
var appliedImpulses:Array<Vector> = [];
|
||||||
|
|
||||||
public var heldPowerup:PowerUp;
|
public var heldPowerup:PowerUp;
|
||||||
public var lastContactNormal:Vector;
|
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.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.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 = AudioManager.playSound(ResourceLoader.getAudio("data/sound/superbounceactive.wav"), null, true);
|
||||||
this.shockabsorberSound.pause = true;
|
this.shockabsorberSound.pause = true;
|
||||||
this.superbounceSound = AudioManager.playSound(ResourceLoader.getAudio("data/sound/forcefield.wav"), null, true);
|
this.superbounceSound = AudioManager.playSound(ResourceLoader.getAudio("data/sound/forcefield.wav"), null, true);
|
||||||
|
|
@ -620,17 +623,18 @@ class Marble extends GameObject {
|
||||||
}
|
}
|
||||||
|
|
||||||
function trailEmitter() {
|
function trailEmitter() {
|
||||||
var speed = this.velocity.length();
|
// Trails are bugged
|
||||||
if (this._minTrailVel > speed) {
|
// var speed = this.velocity.length();
|
||||||
if (this.trailEmitterNode != null) {
|
// if (this._minTrailVel > speed) {
|
||||||
this.level.particleManager.removeEmitter(this.trailEmitterNode);
|
// if (this.trailEmitterNode != null) {
|
||||||
this.trailEmitterNode = null;
|
// this.level.particleManager.removeEmitter(this.trailEmitterNode);
|
||||||
}
|
// this.trailEmitterNode = null;
|
||||||
return;
|
// }
|
||||||
}
|
// return;
|
||||||
if (this.trailEmitterNode == null)
|
// }
|
||||||
this.trailEmitterNode = this.level.particleManager.createEmitter(trailParticleOptions, trailEmitterData, null,
|
// if (this.trailEmitterNode == null)
|
||||||
() -> this.getAbsPos().getPosition());
|
// this.trailEmitterNode = this.level.particleManager.createEmitter(trailParticleOptions, trailEmitterData, null,
|
||||||
|
// () -> this.getAbsPos().getPosition());
|
||||||
}
|
}
|
||||||
|
|
||||||
function ReportBounce(pos:Vector, normal:Vector, speed:Float) {
|
function ReportBounce(pos:Vector, normal:Vector, speed:Float) {
|
||||||
|
|
@ -703,12 +707,13 @@ class Marble extends GameObject {
|
||||||
rollSound.addEffect(new Pitch());
|
rollSound.addEffect(new Pitch());
|
||||||
}
|
}
|
||||||
|
|
||||||
var pitch = scale;
|
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 js
|
||||||
if (pitch < 0.2)
|
// // Apparently audio crashes the whole thing if pitch is less than 0.2
|
||||||
pitch = 0.2;
|
// if (pitch < 0.2)
|
||||||
#end
|
// pitch = 0.2;
|
||||||
|
// #end
|
||||||
var rPitch = rollSound.getEffect(Pitch);
|
var rPitch = rollSound.getEffect(Pitch);
|
||||||
rPitch.value = pitch;
|
rPitch.value = pitch;
|
||||||
}
|
}
|
||||||
|
|
@ -869,6 +874,11 @@ class Marble extends GameObject {
|
||||||
this._contactTime += timeStep;
|
this._contactTime += timeStep;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (impulse in appliedImpulses) {
|
||||||
|
this.velocity = this.velocity.add(impulse);
|
||||||
|
}
|
||||||
|
appliedImpulses = [];
|
||||||
|
|
||||||
piTime += timeStep;
|
piTime += timeStep;
|
||||||
if (this.controllable) {
|
if (this.controllable) {
|
||||||
for (interior in pathedInteriors) {
|
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) {
|
public function enableSuperBounce(time:Float) {
|
||||||
this.superBounceEnableTime = time;
|
this.superBounceEnableTime = time;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
18
src/Util.hx
18
src/Util.hx
|
|
@ -136,12 +136,28 @@ class Util {
|
||||||
}
|
}
|
||||||
if (c == strLiteralToken)
|
if (c == strLiteralToken)
|
||||||
inString = true;
|
inString = true;
|
||||||
else if (StringTools.startsWith(str.substr(i), searchString))
|
#if hl
|
||||||
|
else if (Util.startsWithFromIndex(str, searchString, i))
|
||||||
return i;
|
return i;
|
||||||
|
#end
|
||||||
|
#if js
|
||||||
|
else if ((cast str).startsWith(searchString, i))
|
||||||
|
return i;
|
||||||
|
#end
|
||||||
}
|
}
|
||||||
return -1;
|
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 = '"') {
|
public static function indexIsInStringLiteral(str:String, index:Int, strLiteralToken = '"') {
|
||||||
var inString = false;
|
var inString = false;
|
||||||
for (i in 0...str.length) {
|
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(landMineParticle, landMineParticleData, this.getAbsPos().getPosition());
|
||||||
this.level.particleManager.createEmitter(landMineSmokeParticle, landMineSmokeParticleData, this.getAbsPos().getPosition());
|
this.level.particleManager.createEmitter(landMineSmokeParticle, landMineSmokeParticleData, this.getAbsPos().getPosition());
|
||||||
this.level.particleManager.createEmitter(landMineSparksParticle, landMineSparkParticleData, 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.
|
// 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);
|
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);
|
var opacity = Util.clamp((timeState.timeSinceLoad - (this.disappearTime + 5)), 0, 1);
|
||||||
this.setOpacity(opacity);
|
this.setOpacity(opacity);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue