mirror of
https://github.com/RandomityGuy/MBHaxe.git
synced 2026-02-25 07:30:59 +00:00
fix music playing before starting, finally fix camera once and for all, also fix options gui
This commit is contained in:
parent
2ac7425895
commit
0b77ef4f79
7 changed files with 39 additions and 59 deletions
BIN
marblegame.hl
BIN
marblegame.hl
Binary file not shown.
|
|
@ -211,56 +211,43 @@ class CameraController extends Object {
|
|||
|
||||
var closeness = 0.1;
|
||||
var rayCastOrigin = marblePosition.add(level.currentUp.multiply(marble._radius));
|
||||
var rayCastDirection = camera.pos.sub(rayCastOrigin).normalized();
|
||||
var results = level.collisionWorld.rayCast(rayCastOrigin, rayCastDirection);
|
||||
var rayCastEnd = rayCastOrigin.add(rayCastDirection.multiply(CameraDistance));
|
||||
|
||||
var successHits = [];
|
||||
for (i in 0...3) {
|
||||
var rayCastDirection = camera.pos.sub(rayCastOrigin);
|
||||
rayCastDirection = rayCastDirection.add(rayCastDirection.normalized().multiply(2));
|
||||
|
||||
var results = level.collisionWorld.rayCast(rayCastOrigin, rayCastDirection);
|
||||
|
||||
var firstHit = results[0];
|
||||
|
||||
if (firstHit != null) {
|
||||
if (firstHit.distance < CameraDistance) {
|
||||
// camera.pos = marblePosition.sub(directionVector.multiply(firstHit.distance * 0.7));
|
||||
var plane = new Plane(firstHit.normal.x, firstHit.normal.y, firstHit.normal.z, firstHit.point.dot(firstHit.normal));
|
||||
var normal = firstHit.normal.multiply(-1);
|
||||
// var position = firstHit.point;
|
||||
|
||||
var projected = plane.project(camera.pos.toPoint());
|
||||
var dist = plane.distance(camera.pos.toPoint());
|
||||
|
||||
if (dist >= closeness)
|
||||
break;
|
||||
|
||||
camera.pos = projected.toVector().add(normal.multiply(-closeness));
|
||||
|
||||
var forwardVec = marblePosition.sub(camera.pos).normalized();
|
||||
var rightVec = camera.up.cross(forwardVec);
|
||||
var upVec = forwardVec.cross(rightVec);
|
||||
|
||||
camera.target = marblePosition.add(upVec.multiply(0.3));
|
||||
camera.up = upVec;
|
||||
|
||||
for (result in results) {
|
||||
if (result.distance < CameraDistance) {
|
||||
var t1 = (result.point.x - rayCastOrigin.x) / (rayCastEnd.x - rayCastOrigin.x);
|
||||
if (t1 < 0 || t1 > 1)
|
||||
continue;
|
||||
var t2 = (result.point.y - rayCastOrigin.y) / (rayCastEnd.y - rayCastOrigin.y);
|
||||
if (t2 < 0 || t2 > 1)
|
||||
continue;
|
||||
var t3 = (result.point.z - rayCastOrigin.z) / (rayCastEnd.z - rayCastOrigin.z);
|
||||
if (t3 < 0 || t3 > 1)
|
||||
continue;
|
||||
successHits.push(result);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
successHits.sort((a, b) -> a.distance == b.distance ? 0 : a.distance > b.distance ? 1 : -1);
|
||||
|
||||
for (firstHit in successHits.slice(0, 1)) {
|
||||
if (firstHit.distance < CameraDistance) {
|
||||
// camera.pos = marblePosition.sub(directionVector.multiply(firstHit.distance * 0.7));
|
||||
var plane = new Plane(firstHit.normal.x, firstHit.normal.y, firstHit.normal.z, firstHit.point.dot(firstHit.normal));
|
||||
var normal = firstHit.normal.multiply(-1);
|
||||
// var position = firstHit.point;
|
||||
|
||||
var projected = plane.project(camera.pos.toPoint());
|
||||
var dist = plane.distance(camera.pos.toPoint());
|
||||
|
||||
if (dist >= closeness)
|
||||
break;
|
||||
|
||||
camera.pos = projected.toVector().add(normal.multiply(-closeness));
|
||||
|
||||
var forwardVec = marblePosition.sub(camera.pos).normalized();
|
||||
var rightVec = camera.up.cross(forwardVec);
|
||||
var upVec = forwardVec.cross(rightVec);
|
||||
|
||||
camera.target = marblePosition.add(upVec.multiply(0.3));
|
||||
camera.up = upVec;
|
||||
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (oob) {
|
||||
camera.pos = lastCamPos;
|
||||
camera.target = marblePosition.add(cameraVerticalTranslation);
|
||||
|
|
|
|||
|
|
@ -556,8 +556,6 @@ class Marble extends GameObject {
|
|||
}
|
||||
}
|
||||
if (bestSurface != -1) {
|
||||
// TODO: FIX
|
||||
// bestContact.velocity - bestContact.normal * Vector3.Dot(bestContact.normal, bestContact.velocity);
|
||||
var vAtC = this.velocity.add(this.omega.cross(bestContact.normal.multiply(-this._radius))).sub(bestContact.velocity);
|
||||
var vAtCMag = vAtC.length();
|
||||
var slipping = false;
|
||||
|
|
|
|||
|
|
@ -128,12 +128,6 @@ class MarbleGame {
|
|||
}
|
||||
|
||||
public function playMission(mission:Mission) {
|
||||
var musicFileName = [
|
||||
'data/sound/groovepolice.ogg',
|
||||
'data/sound/classic vibe.ogg',
|
||||
'data/sound/beach party.ogg'
|
||||
][(mission.index + 1) % 3];
|
||||
AudioManager.playMusic(ResourceLoader.getAudio(musicFileName));
|
||||
canvas.clearContent();
|
||||
world = new MarbleWorld(scene, scene2d, mission);
|
||||
world.init();
|
||||
|
|
|
|||
|
|
@ -170,6 +170,12 @@ class MarbleWorld extends Scheduler {
|
|||
|
||||
this.resourceLoadFuncs.push(() -> {
|
||||
this.playGui.init(this.scene2d);
|
||||
var musicFileName = [
|
||||
'data/sound/groovepolice.ogg',
|
||||
'data/sound/classic vibe.ogg',
|
||||
'data/sound/beach party.ogg'
|
||||
][(mission.index + 1) % 3];
|
||||
AudioManager.playMusic(ResourceLoader.getAudio(musicFileName));
|
||||
});
|
||||
this.resourceLoadFuncs.push(() -> {
|
||||
this.addSimGroup(this.mission.root);
|
||||
|
|
@ -831,8 +837,6 @@ class MarbleWorld extends Scheduler {
|
|||
}
|
||||
this.playGui.setHelpText(text);
|
||||
this.helpTextTimeState = this.timeState.currentAttemptTime;
|
||||
|
||||
// TODO FIX
|
||||
}
|
||||
|
||||
public function pickUpGem(gem:Gem) {
|
||||
|
|
|
|||
|
|
@ -670,11 +670,10 @@ Extensions: EAX 2.0, EAX 3.0, EAX Unified, and EAX-AC3";
|
|||
mainPane.addChild(audioPane);
|
||||
}
|
||||
if (tab == "Controls") {
|
||||
// TODO
|
||||
tabs.addChild(audioTab);
|
||||
tabs.addChild(controlsTab);
|
||||
tabs.addChild(boxFrame);
|
||||
tabs.addChild(graphicsTab);
|
||||
tabs.addChild(boxFrame);
|
||||
tabs.addChild(controlsTab);
|
||||
mainPane.addChild(controlsPane);
|
||||
}
|
||||
this.render(MarbleGame.canvas.scene2d);
|
||||
|
|
|
|||
|
|
@ -138,7 +138,6 @@ class PlayMissionGui extends GuiImage {
|
|||
var arialBold14fontdata = ResourceLoader.getFileEntry("data/font/ArialBold14px.fnt");
|
||||
var arialBold14 = new BitmapFont(arialBold14fontdata.entry);
|
||||
@:privateAccess arialBold14.loader = ResourceLoader.loader;
|
||||
// TODO texts
|
||||
|
||||
var levelBkgnd = new GuiText(domcasual24);
|
||||
levelBkgnd.position = new Vector(5, 156);
|
||||
|
|
@ -264,7 +263,6 @@ class PlayMissionGui extends GuiImage {
|
|||
}
|
||||
}
|
||||
|
||||
// TODO Pm description
|
||||
var pmDescription = new GuiMLText(arial14, mlFontLoader);
|
||||
pmDescription.position = new Vector(61, 52);
|
||||
pmDescription.extent = new Vector(215, 174);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue