mirror of
https://github.com/RandomityGuy/MBHaxe.git
synced 2025-10-30 08:11:25 +00:00
pause dialog + some fixes
This commit is contained in:
parent
9a3635f242
commit
bdd8bb4c60
11 changed files with 174 additions and 69 deletions
|
|
@ -11,6 +11,7 @@ class InteriorObject extends GameObject {
|
|||
public var collider:CollisionEntity;
|
||||
public var interiorFile:String;
|
||||
public var useInstancing = true;
|
||||
public var level:MarbleWorld;
|
||||
|
||||
public function new() {
|
||||
super();
|
||||
|
|
@ -19,11 +20,13 @@ class InteriorObject extends GameObject {
|
|||
|
||||
public function init(level:MarbleWorld) {
|
||||
this.identifier = this.interiorFile;
|
||||
this.level = level;
|
||||
DifBuilder.loadDif(this.interiorFile, cast this);
|
||||
}
|
||||
|
||||
public override function setTransform(transform:Matrix) {
|
||||
super.setTransform(transform);
|
||||
collider.setTransform(transform);
|
||||
this.level.collisionWorld.updateTransform(this.collider);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
67
src/Main.hx
67
src/Main.hx
|
|
@ -1,73 +1,21 @@
|
|||
package;
|
||||
|
||||
import gui.GuiControl.MouseState;
|
||||
import hxd.Window;
|
||||
import gui.Canvas;
|
||||
import src.MarbleGame;
|
||||
import gui.MainMenuGui;
|
||||
import hxd.res.DefaultFont;
|
||||
import h2d.Text;
|
||||
import src.Mission;
|
||||
import mis.MisParser;
|
||||
import sys.io.File;
|
||||
import shapes.EndPad;
|
||||
import shapes.LandMine;
|
||||
import shapes.StartPad;
|
||||
import shapes.TriangleBumper;
|
||||
import shapes.RoundBumper;
|
||||
import shapes.Oilslick;
|
||||
import gui.PlayGui;
|
||||
import shapes.Helicopter;
|
||||
import shapes.ShockAbsorber;
|
||||
import shapes.SuperBounce;
|
||||
import shapes.SuperSpeed;
|
||||
import shapes.SignFinish;
|
||||
import shapes.Trapdoor;
|
||||
import shapes.AntiGravity;
|
||||
import shapes.SuperJump;
|
||||
import h3d.prim.Polygon;
|
||||
import src.ResourceLoader;
|
||||
import src.GameObject;
|
||||
import shapes.Tornado;
|
||||
import shapes.DuctFan;
|
||||
import dts.DtsFile;
|
||||
import src.InteriorObject;
|
||||
import h3d.Quat;
|
||||
import src.PathedInteriorMarker;
|
||||
import src.PathedInterior;
|
||||
import src.MarbleWorld;
|
||||
import collision.CollisionWorld;
|
||||
import src.Marble;
|
||||
import src.DifBuilder;
|
||||
import h3d.Vector;
|
||||
import h3d.scene.fwd.DirLight;
|
||||
import h3d.mat.Material;
|
||||
import h3d.prim.Cube;
|
||||
import h3d.scene.*;
|
||||
import src.DtsObject;
|
||||
|
||||
class Main extends hxd.App {
|
||||
var scene:Scene;
|
||||
|
||||
var world:MarbleWorld;
|
||||
var dtsObj:DtsObject;
|
||||
|
||||
var canvas:Canvas;
|
||||
var marbleGame:MarbleGame;
|
||||
|
||||
var fpsCounter:Text;
|
||||
|
||||
override function init() {
|
||||
super.init();
|
||||
|
||||
var ltr = File.getContent("data/missions/advanced/airwalk.mis");
|
||||
var mfp = new MisParser(ltr);
|
||||
var mis = mfp.parse();
|
||||
|
||||
var mission = new Mission();
|
||||
mission.root = mis.root;
|
||||
|
||||
canvas = new Canvas(s2d);
|
||||
|
||||
canvas.setContent(new MainMenuGui());
|
||||
marbleGame = new MarbleGame(s2d, s3d);
|
||||
marbleGame.canvas.setContent(new MainMenuGui());
|
||||
// world = new MarbleWorld(s3d, s2d, mission);
|
||||
|
||||
// world.init();
|
||||
|
|
@ -80,17 +28,14 @@ class Main extends hxd.App {
|
|||
|
||||
override function update(dt:Float) {
|
||||
super.update(dt);
|
||||
var wnd = Window.getInstance();
|
||||
var mouseState:MouseState = {
|
||||
position: new Vector(wnd.mouseX, wnd.mouseY)
|
||||
}
|
||||
canvas.update(dt, mouseState);
|
||||
marbleGame.update(dt);
|
||||
// world.update(dt);
|
||||
fpsCounter.text = 'FPS: ${this.engine.fps}';
|
||||
}
|
||||
|
||||
override function render(e:h3d.Engine) {
|
||||
// this.world.render(e);
|
||||
marbleGame.render(e);
|
||||
super.render(e);
|
||||
}
|
||||
|
||||
|
|
|
|||
66
src/MarbleGame.hx
Normal file
66
src/MarbleGame.hx
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
package src;
|
||||
|
||||
import gui.ExitGameDlg;
|
||||
import hxd.Key;
|
||||
import src.Mission;
|
||||
import h3d.Vector;
|
||||
import gui.GuiControl.MouseState;
|
||||
import hxd.Window;
|
||||
import src.MarbleWorld;
|
||||
import gui.Canvas;
|
||||
|
||||
@:publicFields
|
||||
class MarbleGame {
|
||||
var canvas:Canvas;
|
||||
var world:MarbleWorld;
|
||||
|
||||
var scene2d:h2d.Scene;
|
||||
var scene:h3d.scene.Scene;
|
||||
|
||||
var paused:Bool;
|
||||
|
||||
var exitGameDlg:ExitGameDlg;
|
||||
|
||||
public function new(scene2d:h2d.Scene, scene:h3d.scene.Scene) {
|
||||
this.canvas = new Canvas(scene2d, cast this);
|
||||
this.scene = scene;
|
||||
this.scene2d = scene2d;
|
||||
}
|
||||
|
||||
public function update(dt:Float) {
|
||||
if (world != null) {
|
||||
if (!paused) {
|
||||
world.update(dt);
|
||||
}
|
||||
if (Key.isPressed(Key.ESCAPE)) {
|
||||
paused = !paused;
|
||||
if (paused) {
|
||||
exitGameDlg = new ExitGameDlg();
|
||||
canvas.pushDialog(exitGameDlg);
|
||||
} else {
|
||||
canvas.popDialog(exitGameDlg);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (canvas != null) {
|
||||
var wnd = Window.getInstance();
|
||||
var mouseState:MouseState = {
|
||||
position: new Vector(wnd.mouseX, wnd.mouseY)
|
||||
}
|
||||
canvas.update(dt, mouseState);
|
||||
}
|
||||
}
|
||||
|
||||
public function playMission(mission:Mission) {
|
||||
this.canvas.clearContent();
|
||||
mission.load();
|
||||
world = new MarbleWorld(scene, scene2d, mission);
|
||||
world.init();
|
||||
world.start();
|
||||
}
|
||||
|
||||
public function render(e:h3d.Engine) {
|
||||
if (world != null)
|
||||
world.render(e);
|
||||
}
|
||||
}
|
||||
|
|
@ -525,7 +525,6 @@ class MarbleWorld extends Scheduler {
|
|||
if (element.datablock == "OutOfBoundsTrigger") {
|
||||
trigger = new OutOfBoundsTrigger(element, cast this);
|
||||
} else if (element.datablock == "InBoundsTrigger") {
|
||||
return;
|
||||
trigger = new InBoundsTrigger(element, cast this);
|
||||
} else if (element.datablock == "HelpTrigger") {
|
||||
trigger = new HelpTrigger(element, cast this);
|
||||
|
|
|
|||
|
|
@ -20,6 +20,12 @@ class Mission {
|
|||
|
||||
public function new() {}
|
||||
|
||||
public function load() {
|
||||
var misParser = new MisParser(ResourceLoader.fileSystem.get(this.path).getText());
|
||||
var contents = misParser.parse();
|
||||
root = contents.root;
|
||||
}
|
||||
|
||||
public static function fromMissionInfo(path:String, mInfo:MissionElementScriptObject) {
|
||||
var mission = new Mission();
|
||||
mission.path = path;
|
||||
|
|
|
|||
|
|
@ -51,8 +51,6 @@ class PathedInterior extends InteriorObject {
|
|||
var stopped:Bool = false;
|
||||
var stopTime:Float;
|
||||
|
||||
public var level:MarbleWorld;
|
||||
|
||||
var previousState:PIState;
|
||||
|
||||
public static function createFromSimGroup(simGroup:MissionElementSimGroup, level:MarbleWorld) {
|
||||
|
|
|
|||
|
|
@ -1,15 +1,19 @@
|
|||
package gui;
|
||||
|
||||
import src.MarbleGame;
|
||||
import h3d.Vector;
|
||||
import h2d.Scene;
|
||||
import gui.GuiControl.MouseState;
|
||||
|
||||
@:publicFields
|
||||
class Canvas extends GuiControl {
|
||||
var scene2d:Scene;
|
||||
var marbleGame:MarbleGame;
|
||||
|
||||
public function new(scene) {
|
||||
public function new(scene, marbleGame:MarbleGame) {
|
||||
super();
|
||||
this.scene2d = scene;
|
||||
this.marbleGame = marbleGame;
|
||||
|
||||
this.position = new Vector();
|
||||
this.extent = new Vector(640, 480);
|
||||
|
|
@ -23,6 +27,22 @@ class Canvas extends GuiControl {
|
|||
this.render(scene2d);
|
||||
}
|
||||
|
||||
public function pushDialog(content:GuiControl) {
|
||||
this.addChild(content);
|
||||
this.render(scene2d);
|
||||
}
|
||||
|
||||
public function popDialog(content:GuiControl) {
|
||||
content.dispose();
|
||||
this.removeChild(content);
|
||||
this.render(scene2d);
|
||||
}
|
||||
|
||||
public function clearContent() {
|
||||
this.dispose();
|
||||
this.render(scene2d);
|
||||
}
|
||||
|
||||
public override function update(dt:Float, mouseState:MouseState) {
|
||||
super.update(dt, mouseState);
|
||||
}
|
||||
|
|
|
|||
52
src/gui/ExitGameDlg.hx
Normal file
52
src/gui/ExitGameDlg.hx
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
package gui;
|
||||
|
||||
import h3d.Vector;
|
||||
import src.ResourceLoader;
|
||||
|
||||
class ExitGameDlg extends GuiControl {
|
||||
public function new() {
|
||||
super();
|
||||
|
||||
this.horizSizing = Width;
|
||||
this.vertSizing = Height;
|
||||
this.position = new Vector();
|
||||
this.extent = new Vector(640, 480);
|
||||
|
||||
function loadButtonImages(path:String) {
|
||||
var normal = ResourceLoader.getImage('${path}_n.png').toTile();
|
||||
var hover = ResourceLoader.getImage('${path}_h.png').toTile();
|
||||
var pressed = ResourceLoader.getImage('${path}_d.png').toTile();
|
||||
return [normal, hover, pressed];
|
||||
}
|
||||
|
||||
var dialogImg = new GuiImage(ResourceLoader.getImage("data/ui/common/dialog.png").toTile());
|
||||
dialogImg.horizSizing = Center;
|
||||
dialogImg.vertSizing = Center;
|
||||
dialogImg.position = new Vector(134, 148);
|
||||
dialogImg.extent = new Vector(388, 186);
|
||||
|
||||
var yesButton = new GuiButton(loadButtonImages("data/ui/common/yes"));
|
||||
yesButton.position = new Vector(47, 107);
|
||||
yesButton.extent = new Vector(88, 52);
|
||||
yesButton.vertSizing = Top;
|
||||
yesButton.horizSizing = Right;
|
||||
|
||||
var noButton = new GuiButton(loadButtonImages("data/ui/common/no"));
|
||||
noButton.position = new Vector(151, 107);
|
||||
noButton.extent = new Vector(83, 55);
|
||||
noButton.vertSizing = Top;
|
||||
noButton.horizSizing = Right;
|
||||
|
||||
var restartButton = new GuiButton(loadButtonImages("data/ui/common/restart"));
|
||||
restartButton.position = new Vector(249, 107);
|
||||
restartButton.extent = new Vector(103, 56);
|
||||
restartButton.vertSizing = Top;
|
||||
restartButton.horizSizing = Right;
|
||||
|
||||
dialogImg.addChild(yesButton);
|
||||
dialogImg.addChild(noButton);
|
||||
dialogImg.addChild(restartButton);
|
||||
|
||||
this.addChild(dialogImg);
|
||||
}
|
||||
}
|
||||
|
|
@ -122,12 +122,12 @@ class GuiControl {
|
|||
}
|
||||
if (this.horizSizing == HorizSizing.Left) {
|
||||
if (this.parent != null) {
|
||||
rect.position.x = parentRect.extent.x - (parent.extent.x - this.position.x);
|
||||
rect.position.x = parentRect.position.x + parentRect.extent.x - (parent.extent.x - this.position.x);
|
||||
}
|
||||
}
|
||||
if (this.vertSizing == VertSizing.Top) {
|
||||
if (this.parent != null) {
|
||||
rect.position.y = parentRect.extent.y - (parent.extent.y - this.position.y);
|
||||
rect.position.y = parentRect.position.y + parentRect.extent.y - (parent.extent.y - this.position.y);
|
||||
}
|
||||
}
|
||||
return rect;
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ class PlayGui {
|
|||
var powerupBox:GuiImage;
|
||||
var powerupImageScene:h3d.scene.Scene;
|
||||
var powerupImageSceneTarget:Texture;
|
||||
var powerupImageSceneTargetBitmap:Bitmap;
|
||||
var powerupImageObject:DtsObject;
|
||||
|
||||
var RSGOCenterText:Anim;
|
||||
|
|
@ -50,6 +51,17 @@ class PlayGui {
|
|||
|
||||
var playGuiCtrl:GuiControl;
|
||||
|
||||
public function dispose() {
|
||||
playGuiCtrl.dispose();
|
||||
gemImageScene.dispose();
|
||||
gemImageSceneTarget.dispose();
|
||||
gemImageSceneTargetBitmap.remove();
|
||||
powerupImageScene.dispose();
|
||||
powerupImageSceneTarget.dispose();
|
||||
powerupImageSceneTargetBitmap.remove();
|
||||
RSGOCenterText.remove();
|
||||
}
|
||||
|
||||
public function init(scene2d:h2d.Scene) {
|
||||
this.scene2d = scene2d;
|
||||
|
||||
|
|
@ -231,7 +243,7 @@ class PlayGui {
|
|||
powerupImageSceneTarget = new Texture(68, 67, [Target]);
|
||||
powerupImageSceneTarget.depthBuffer = new DepthBuffer(68, 67);
|
||||
|
||||
var powerupImageSceneTargetBitmap = new Bitmap(Tile.fromTexture(powerupImageSceneTarget), scene2d);
|
||||
powerupImageSceneTargetBitmap = new Bitmap(Tile.fromTexture(powerupImageSceneTarget), scene2d);
|
||||
powerupImageSceneTargetBitmap.x = scene2d.width - 88;
|
||||
powerupImageSceneTargetBitmap.y = 18;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -138,6 +138,10 @@ class PlayMissionGui extends GuiImage {
|
|||
var pmPlay = new GuiButton(loadButtonImages("data/ui/play/play"));
|
||||
pmPlay.position = new Vector(391, 257);
|
||||
pmPlay.extent = new Vector(121, 62);
|
||||
pmPlay.pressedAction = (sender) -> {
|
||||
// Wacky hacks
|
||||
cast(this.parent, Canvas).marbleGame.playMission(currentList[currentSelection]);
|
||||
}
|
||||
pmBox.addChild(pmPlay);
|
||||
|
||||
var pmPrev = new GuiButton(loadButtonImages("data/ui/play/prev"));
|
||||
|
|
@ -199,7 +203,7 @@ class PlayMissionGui extends GuiImage {
|
|||
var descText2 = '<br/><br/>' + '<font opacity="0">ÂTest Align</font>';
|
||||
descText2 += '<br/><br/><br/>';
|
||||
for (i in 0...3) {
|
||||
descText2 += '<br/>ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ<font face="ArialBold14">00:00.000</font>';
|
||||
descText2 += '<br/>ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ<font face="ArialBold14">99:59.999</font>';
|
||||
}
|
||||
pmDescriptionOther.text.text = descText2;
|
||||
pmBox.addChild(pmDescriptionOther);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue