This commit is contained in:
RandomityGuy 2023-10-02 23:44:04 +05:30
parent 4bc6e0b8fb
commit acde6595cb
10 changed files with 29 additions and 164 deletions

View file

@ -4,7 +4,6 @@ import haxe.Json;
import src.Util; import src.Util;
import src.Settings; import src.Settings;
import src.Http; import src.Http;
import src.Console;
typedef PayloadData = { typedef PayloadData = {
type:String, type:String,
@ -44,14 +43,12 @@ class Analytics {
}); });
} }
public static function trackLevelScore(levelName:String, levelFile:String, time:Int, oobs:Int, respawns:Int, rewind:Bool) { public static function trackLevelScore(levelName:String, levelFile:String, time:Int, rewind:Bool) {
var p = payload("level-score", { var p = payload("level-score", {
level_play: Json.stringify({ level_play: Json.stringify({
name: levelName, name: levelName,
file: levelFile, file: levelFile,
time: time, time: time,
oobs: oobs,
respawns: respawns,
rewind: rewind rewind: rewind
}) })
}); });
@ -63,14 +60,12 @@ class Analytics {
}); });
} }
public static function trackLevelQuit(levelName:String, levelFile:String, time:Int, oobs:Int, respawns:Int, rewind:Bool) { public static function trackLevelQuit(levelName:String, levelFile:String, time:Int, rewind:Bool) {
var p = payload("level-quit", { var p = payload("level-quit", {
level_quit: Json.stringify({ level_quit: Json.stringify({
name: levelName, name: levelName,
file: levelFile, file: levelFile,
time: time, time: time,
oobs: oobs,
respawns: respawns,
rewind: rewind rewind: rewind
}) })
}); });
@ -103,9 +98,9 @@ class Analytics {
language: language(), language: language(),
referrer: referrer(), referrer: referrer(),
screen: screen(), screen: screen(),
title: "MBHaxe Platinum", title: "MBHaxe Gold",
url: "/", url: "/",
website: "e6da43f0-fc6a-49cb-a4a9-4b7e7745e538", website: "737bbe05-ad2e-43a5-820b-4e3014f5683e",
name: eventName name: eventName
} }
}; };
@ -120,7 +115,7 @@ class Analytics {
return js.Browser.window.location.hostname; return js.Browser.window.location.hostname;
#end #end
#if hl #if hl
return "marbleblast.randomityguy.me"; return "marbleblastgold.randomityguy.me";
#end #end
} }

View file

@ -167,8 +167,6 @@ class DifBuilder {
colliderSurface.normals = []; colliderSurface.normals = [];
colliderSurface.indices = []; colliderSurface.indices = [];
colliderSurface.transformKeys = []; colliderSurface.transformKeys = [];
colliderSurface.edgeData = [];
colliderSurface.edgeConcavities = [];
colliderSurface.originalIndices = []; colliderSurface.originalIndices = [];
colliderSurface.originalSurfaceIndex = surfaceindex; colliderSurface.originalSurfaceIndex = surfaceindex;
@ -243,12 +241,12 @@ class DifBuilder {
colliderSurface.friction = minfo.friction; colliderSurface.friction = minfo.friction;
colliderSurface.restitution = minfo.restitution; colliderSurface.restitution = minfo.restitution;
} }
colliderSurface.points.push(new Vector(-p1.x, p1.y, p1.z)); colliderSurface.addPoint(-p1.x, p1.y, p1.z);
colliderSurface.points.push(new Vector(-p2.x, p2.y, p2.z)); colliderSurface.addPoint(-p2.x, p2.y, p2.z);
colliderSurface.points.push(new Vector(-p3.x, p3.y, p3.z)); colliderSurface.addPoint(-p3.x, p3.y, p3.z);
colliderSurface.normals.push(new Vector(-normal.x, normal.y, normal.z)); colliderSurface.addNormal(-normal.x, normal.y, normal.z);
colliderSurface.normals.push(new Vector(-normal.x, normal.y, normal.z)); colliderSurface.addNormal(-normal.x, normal.y, normal.z);
colliderSurface.normals.push(new Vector(-normal.x, normal.y, normal.z)); colliderSurface.addNormal(-normal.x, normal.y, normal.z);
colliderSurface.indices.push(colliderSurface.indices.length); colliderSurface.indices.push(colliderSurface.indices.length);
colliderSurface.indices.push(colliderSurface.indices.length); colliderSurface.indices.push(colliderSurface.indices.length);
colliderSurface.indices.push(colliderSurface.indices.length); colliderSurface.indices.push(colliderSurface.indices.length);
@ -405,52 +403,6 @@ class DifBuilder {
return vec; return vec;
} }
for (colliderSurface in colliderSurfaces) {
var i = 0;
while (i < colliderSurface.indices.length) {
var e1e2 = hashEdge(colliderSurface.originalIndices[i], colliderSurface.originalIndices[i + 1]);
var e2e3 = hashEdge(colliderSurface.originalIndices[i + 1], colliderSurface.originalIndices[i + 2]);
var e1e3 = hashEdge(colliderSurface.originalIndices[i], colliderSurface.originalIndices[i + 2]);
var edgeData = 0;
if (difEdges.exists(e1e2)) {
// if (getEdgeDot(difEdges[e1e2]) < Math.cos(Math.PI / 12)) {
edgeData |= 1;
// }
colliderSurface.edgeConcavities.push(getEdgeConcavity(difEdges[e1e2]));
// colliderSurface.edgeNormals.push(getEdgeNormal(difEdges[e1e2]));
} else {
colliderSurface.edgeConcavities.push(false);
// colliderSurface.edgeNormals.push(new Vector(0, 0, 0));
}
if (difEdges.exists(e2e3)) {
// if (getEdgeDot(difEdges[e2e3]) < Math.cos(Math.PI / 12)) {
edgeData |= 2;
// }
colliderSurface.edgeConcavities.push(getEdgeConcavity(difEdges[e2e3]));
// colliderSurface.edgeNormals.push(getEdgeNormal(difEdges[e2e3]));
// colliderSurface.edgeDots.push(dot);
} else {
colliderSurface.edgeConcavities.push(false);
// colliderSurface.edgeNormals.push(new Vector(0, 0, 0));
}
if (difEdges.exists(e1e3)) {
// if (getEdgeDot(difEdges[e1e3]) < Math.cos(Math.PI / 12)) {
edgeData |= 4;
// }
colliderSurface.edgeConcavities.push(getEdgeConcavity(difEdges[e1e3]));
// colliderSurface.edgeNormals.push(getEdgeNormal(difEdges[e1e3]));
// colliderSurface.edgeDots.push(dot);
} else {
colliderSurface.edgeConcavities.push(false);
// colliderSurface.edgeNormals.push(new Vector(0, 0, 0));
}
colliderSurface.edgeData.push(edgeData);
i += 3;
}
}
for (vtex => buckets in vertexBuckets) { for (vtex => buckets in vertexBuckets) {
for (i in 0...buckets.length) { for (i in 0...buckets.length) {
var bucket = buckets[i]; var bucket = buckets[i];
@ -483,7 +435,6 @@ class DifBuilder {
} }
} }
collider.difEdgeMap = difEdges;
collider.finalize(); collider.finalize();
itr.collider = collider; itr.collider = collider;

View file

@ -560,11 +560,11 @@ class DtsObject extends GameObject {
for (index in [i1, i2, i3]) { for (index in [i1, i2, i3]) {
var vertex = vertices[index]; var vertex = vertices[index];
hs.points.push(new Vector(vertex.x, vertex.y, vertex.z)); hs.addPoint(vertex.x, vertex.y, vertex.z);
hs.transformKeys.push(0); hs.transformKeys.push(0);
var normal = vertexNormals[index]; var normal = vertexNormals[index];
hs.normals.push(new Vector(normal.x, normal.y, normal.z)); hs.addNormal(normal.x, normal.y, normal.z);
} }
hs.indices.push(hs.indices.length); hs.indices.push(hs.indices.length);

View file

@ -1,6 +1,5 @@
package src; package src;
import src.Console;
import src.Util; import src.Util;
typedef HttpRequest = { typedef HttpRequest = {

View file

@ -1,5 +1,6 @@
package; package;
import src.Http;
import hxd.Key; import hxd.Key;
import src.Util; import src.Util;
import src.ResourceLoader; import src.ResourceLoader;
@ -18,6 +19,7 @@ import h2d.Text;
import h3d.Vector; import h3d.Vector;
import src.ProfilerUI; import src.ProfilerUI;
import src.Gamepad; import src.Gamepad;
import src.Http;
class Main extends hxd.App { class Main extends hxd.App {
var marbleGame:MarbleGame; var marbleGame:MarbleGame;
@ -60,6 +62,7 @@ class Main extends hxd.App {
trace("ResourceLoader::init"); trace("ResourceLoader::init");
ResourceLoader.init(s2d, () -> { ResourceLoader.init(s2d, () -> {
trace("Settings::init"); trace("Settings::init");
Http.init();
Settings.init(); Settings.init();
trace("Gamepad::init"); trace("Gamepad::init");
Gamepad.init(); Gamepad.init();

View file

@ -1131,8 +1131,7 @@ class Marble extends GameObject {
continue; continue;
} }
var tsi = Collision.TriangleSphereIntersection(testTri.v[0], testTri.v[1], testTri.v[2], testTri.n, position, radius, testTri.edge, var tsi = Collision.TriangleSphereIntersection(testTri.v[0], testTri.v[1], testTri.v[2], testTri.n, position, radius);
testTri.concavity);
if (tsi.result) { if (tsi.result) {
var separatingDistance = position.sub(tsi.point).normalized(); var separatingDistance = position.sub(tsi.point).normalized();
var distToContactPlane = tsi.point.distance(position); var distToContactPlane = tsi.point.distance(position);

View file

@ -18,6 +18,7 @@ import src.Util;
import src.ProfilerUI; import src.ProfilerUI;
import src.Gamepad; import src.Gamepad;
import src.Analytics; import src.Analytics;
import src.Settings;
@:publicFields @:publicFields
class MarbleGame { class MarbleGame {
@ -224,15 +225,7 @@ class MarbleGame {
public function quitMission() { public function quitMission() {
world.setCursorLock(false); world.setCursorLock(false);
if (!Settings.levelStatistics.exists(world.mission.path)) { Analytics.trackLevelQuit(world.mission.title, world.mission.path, Std.int(world.timeState.timeSinceLoad * 1000),
Settings.levelStatistics.set(world.mission.path, {
oobs: 0,
respawns: 0,
totalTime: 0,
});
}
var stats = Settings.levelStatistics[world.mission.path];
Analytics.trackLevelQuit(world.mission.title, world.mission.path, Std.int(world.timeState.timeSinceLoad * 1000), stats.oobs, stats.respawns,
Settings.optionsSettings.rewindEnabled); Settings.optionsSettings.rewindEnabled);
paused = false; paused = false;
var pmg = new PlayMissionGui(); var pmg = new PlayMissionGui();
@ -258,6 +251,9 @@ class MarbleGame {
public function watchMissionReplay(mission:Mission, replay:Replay) { public function watchMissionReplay(mission:Mission, replay:Replay) {
canvas.clearContent(); canvas.clearContent();
if (world != null) {
world.dispose();
}
Analytics.trackSingle("replay-watch"); Analytics.trackSingle("replay-watch");
world = new MarbleWorld(scene, scene2d, mission); world = new MarbleWorld(scene, scene2d, mission);
world.replay = replay; world.replay = replay;

View file

@ -1336,15 +1336,7 @@ class MarbleWorld extends Scheduler {
this.finishYaw = this.marble.camera.CameraYaw; this.finishYaw = this.marble.camera.CameraYaw;
this.finishPitch = this.marble.camera.CameraPitch; this.finishPitch = this.marble.camera.CameraPitch;
displayAlert("Congratulations! You've finished!"); displayAlert("Congratulations! You've finished!");
if (!Settings.levelStatistics.exists(mission.path)) { Analytics.trackLevelScore(mission.title, mission.path, Std.int(finishTime.gameplayClock * 1000), Settings.optionsSettings.rewindEnabled);
Settings.levelStatistics.set(mission.path, {
oobs: 0,
respawns: 0,
totalTime: 0,
});
}
Analytics.trackLevelScore(mission.title, mission.path, Std.int(finishTime.gameplayClock * 1000), Settings.levelStatistics[mission.path].oobs,
Settings.levelStatistics[mission.path].respawns, Settings.optionsSettings.rewindEnabled);
if (!this.isWatching) if (!this.isWatching)
this.schedule(this.timeState.currentAttemptTime + 2, () -> cast showFinishScreen()); this.schedule(this.timeState.currentAttemptTime + 2, () -> cast showFinishScreen());
// Stop the ongoing sounds // Stop the ongoing sounds
@ -1578,7 +1570,6 @@ class MarbleWorld extends Scheduler {
for (textureResource in this.textureResources) { for (textureResource in this.textureResources) {
textureResource.release(); textureResource.release();
} }
gems = null;
sky.dispose(); sky.dispose();
sky = null; sky = null;
@ -1586,11 +1577,8 @@ class MarbleWorld extends Scheduler {
collisionWorld.dispose(); collisionWorld.dispose();
collisionWorld = null; collisionWorld = null;
particleManager = null; particleManager = null;
namedObjects = null;
shapeOrTriggerInside = null; shapeOrTriggerInside = null;
shapeImmunity = null; shapeImmunity = null;
currentCheckpoint = null;
checkpointCollectedGems = null;
marble = null; marble = null;
this._disposed = true; this._disposed = true;

View file

@ -116,25 +116,9 @@ class RewindFrame {
framesize += 1; // s.lastDirection framesize += 1; // s.lastDirection
framesize += 8; // s.lastCompletion framesize += 8; // s.lastCompletion
} }
framesize += 8; // blastAmt
if (oobState.oob) if (oobState.oob)
framesize += 1; // oobState.oob framesize += 1; // oobState.oob
framesize += 32; // oobState.timeState framesize += 32; // oobState.timeState
framesize += 1; // Null<checkpointState>
if (checkpointState != null) {
framesize += 4; // checkpointState.currentCheckpoint
}
framesize += 2; // checkpointState.currentCheckpointTrigger
framesize += 2; // checkpointState.checkpointCollectedGems.length
for (gem in checkpointState.checkpointCollectedGems.keys()) {
framesize += 2; // gem
framesize += 1; // checkpointState.checkpointCollectedGems[gem]
}
framesize += 2; // checkpointState.checkpointHeldPowerup
framesize += 1; // Null<checkpointState.checkpointUp>
if (checkpointState.checkpointUp != null)
framesize += 24; // checkpointState.checkpointUp
framesize += 8; // checkpointState.checkpointBlast
bb.prepare(framesize); bb.prepare(framesize);
// Now actually write // Now actually write
bb.writeDouble(timeState.currentAttemptTime); bb.writeDouble(timeState.currentAttemptTime);
@ -197,7 +181,6 @@ class RewindFrame {
bb.writeByte(s.lastDirection); bb.writeByte(s.lastDirection);
bb.writeDouble(s.lastCompletion); bb.writeDouble(s.lastCompletion);
} }
bb.writeDouble(blastAmt);
bb.writeByte(oobState.oob ? 1 : 0); bb.writeByte(oobState.oob ? 1 : 0);
if (oobState.oob) { if (oobState.oob) {
bb.writeDouble(oobState.timeState.currentAttemptTime); bb.writeDouble(oobState.timeState.currentAttemptTime);
@ -205,29 +188,6 @@ class RewindFrame {
bb.writeDouble(oobState.timeState.gameplayClock); bb.writeDouble(oobState.timeState.gameplayClock);
bb.writeDouble(oobState.timeState.dt); bb.writeDouble(oobState.timeState.dt);
} }
bb.writeByte(checkpointState.currentCheckpoint == null ? 0 : 1);
if (checkpointState.currentCheckpoint != null) {
bb.writeInt16(rm.allocGO(checkpointState.currentCheckpoint.obj));
bb.writeInt16(rm.allocME(checkpointState.currentCheckpoint.elem));
}
bb.writeInt16(rm.allocGO(checkpointState.currentCheckpointTrigger));
var chkgemcount = 0;
for (g in checkpointState.checkpointCollectedGems) {
chkgemcount++;
}
bb.writeInt16(chkgemcount);
for (gem in checkpointState.checkpointCollectedGems.keys()) {
bb.writeInt16(rm.allocGO(gem));
bb.writeByte(checkpointState.checkpointCollectedGems[gem] ? 1 : 0);
}
bb.writeInt16(rm.allocGO(checkpointState.checkpointHeldPowerup));
bb.writeByte(checkpointState.checkpointUp == null ? 0 : 1);
if (checkpointState.checkpointUp != null) {
bb.writeDouble(checkpointState.checkpointUp.x);
bb.writeDouble(checkpointState.checkpointUp.y);
bb.writeDouble(checkpointState.checkpointUp.z);
}
bb.writeDouble(checkpointState.checkpointBlast);
return bb.getBytes(); return bb.getBytes();
} }
@ -321,7 +281,6 @@ class RewindFrame {
trapdoorStates_item.lastCompletion = br.readDouble(); trapdoorStates_item.lastCompletion = br.readDouble();
trapdoorStates.push(trapdoorStates_item); trapdoorStates.push(trapdoorStates_item);
} }
blastAmt = br.readDouble();
oobState = { oobState = {
oob: br.readByte() != 0, oob: br.readByte() != 0,
timeState: null timeState: null
@ -333,35 +292,5 @@ class RewindFrame {
oobState.timeState.gameplayClock = br.readDouble(); oobState.timeState.gameplayClock = br.readDouble();
oobState.timeState.dt = br.readDouble(); oobState.timeState.dt = br.readDouble();
} }
var hasCheckpoint = br.readByte() != 0;
checkpointState = {
currentCheckpoint: null,
currentCheckpointTrigger: null,
checkpointCollectedGems: new Map<Gem, Bool>(),
checkpointHeldPowerup: null,
checkpointUp: null,
checkpointBlast: 0.0,
};
if (hasCheckpoint) {
var co = rm.getGO(br.readInt16());
var ce = rm.getME(br.readInt16());
checkpointState.currentCheckpoint = {obj: cast co, elem: ce};
}
checkpointState.currentCheckpointTrigger = cast rm.getGO(br.readInt16());
var checkpointState_checkpointCollectedGems_len = br.readInt16();
for (i in 0...checkpointState_checkpointCollectedGems_len) {
var gem = cast rm.getGO(br.readInt16());
var c = br.readByte() != 0;
checkpointState.checkpointCollectedGems.set(cast gem, c);
}
checkpointState.checkpointHeldPowerup = cast rm.getGO(br.readInt16());
var checkpointState_checkpointUp_has = br.readByte() != 0;
if (checkpointState_checkpointUp_has) {
checkpointState.checkpointUp = new Vector();
checkpointState.checkpointUp.x = br.readDouble();
checkpointState.checkpointUp.y = br.readDouble();
checkpointState.checkpointUp.z = br.readDouble();
}
checkpointState.checkpointBlast = br.readDouble();
} }
} }

View file

@ -96,7 +96,12 @@ class RewindManager {
oob: level.outOfBounds, oob: level.outOfBounds,
timeState: level.outOfBoundsTime != null ? level.outOfBoundsTime.clone() : null timeState: level.outOfBoundsTime != null ? level.outOfBoundsTime.clone() : null
}; };
frames.push(rf); frameElapsedTimes.push(level.timeState.currentAttemptTime);
frameDataOffsets.push(frameData.length);
var frameDataSerialized = rf.serialize(this);
frameSizes.push(frameDataSerialized.length);
frameData.addBytes(frameDataSerialized, 0, frameDataSerialized.length);
// frames.push(rf);
} }
public function applyFrame(rf:RewindFrame) { public function applyFrame(rf:RewindFrame) {