mirror of
https://github.com/RandomityGuy/MBHaxe.git
synced 2026-04-27 05:01:38 +00:00
fix reported bugs
This commit is contained in:
parent
4435ae4084
commit
afb8a2dc97
10 changed files with 84 additions and 9 deletions
BIN
marblegame.hl
BIN
marblegame.hl
Binary file not shown.
|
|
@ -75,7 +75,7 @@ class CameraController extends Object {
|
||||||
this.level = level;
|
this.level = level;
|
||||||
// level.scene.addEventListener(onEvent);
|
// level.scene.addEventListener(onEvent);
|
||||||
// Sdl.setRelativeMouseMode(true);
|
// Sdl.setRelativeMouseMode(true);
|
||||||
level.scene.camera.fovY = 60;
|
level.scene.camera.fovY = Settings.optionsSettings.fov;
|
||||||
lockCursor();
|
lockCursor();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,6 @@ class InstanceManager {
|
||||||
// minfo.transparencymeshbatch.material.mainPass.setPassName(minfo.mesh.material.mainPass.name);
|
// minfo.transparencymeshbatch.material.mainPass.setPassName(minfo.mesh.material.mainPass.name);
|
||||||
minfo.transparencymeshbatch.shadersChanged = true;
|
minfo.transparencymeshbatch.shadersChanged = true;
|
||||||
minfo.transparencymeshbatch.material.mainPass.enableLights = minfo.mesh.material.mainPass.enableLights;
|
minfo.transparencymeshbatch.material.mainPass.enableLights = minfo.mesh.material.mainPass.enableLights;
|
||||||
minfo.transparencymeshbatch.material.receiveShadows = false;
|
|
||||||
// minfo.transparencymeshbatch.material.mainPass.depthWrite = false;
|
// minfo.transparencymeshbatch.material.mainPass.depthWrite = false;
|
||||||
// if (dtsShader != null) {
|
// if (dtsShader != null) {
|
||||||
// dtsShader.currentOpacity = instance.gameObject.currentOpacity;
|
// dtsShader.currentOpacity = instance.gameObject.currentOpacity;
|
||||||
|
|
|
||||||
|
|
@ -63,6 +63,11 @@ class Main extends hxd.App {
|
||||||
|
|
||||||
static function main() {
|
static function main() {
|
||||||
// h3d.mat.PbrMaterialSetup.set();
|
// h3d.mat.PbrMaterialSetup.set();
|
||||||
|
#if hl
|
||||||
|
sdl.Sdl.setGLOptions(3, 2, 24, 8, 1, 2);
|
||||||
|
sdl.Sdl.setHint("SDL_HINT_RENDER_SCALE_QUALITY", "1");
|
||||||
|
#end
|
||||||
|
h3d.Engine.ANTIALIASING = 4;
|
||||||
new Main();
|
new Main();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,8 @@ import gui.Canvas;
|
||||||
class MarbleGame {
|
class MarbleGame {
|
||||||
static var canvas:Canvas;
|
static var canvas:Canvas;
|
||||||
|
|
||||||
|
static var instance:MarbleGame;
|
||||||
|
|
||||||
var world:MarbleWorld;
|
var world:MarbleWorld;
|
||||||
|
|
||||||
var scene2d:h2d.Scene;
|
var scene2d:h2d.Scene;
|
||||||
|
|
@ -29,6 +31,7 @@ class MarbleGame {
|
||||||
canvas = new Canvas(scene2d, cast this);
|
canvas = new Canvas(scene2d, cast this);
|
||||||
this.scene = scene;
|
this.scene = scene;
|
||||||
this.scene2d = scene2d;
|
this.scene2d = scene2d;
|
||||||
|
MarbleGame.instance = this;
|
||||||
|
|
||||||
#if js
|
#if js
|
||||||
// Pause shit
|
// Pause shit
|
||||||
|
|
@ -91,10 +94,7 @@ class MarbleGame {
|
||||||
world.setCursorLock(false);
|
world.setCursorLock(false);
|
||||||
exitGameDlg = new ExitGameDlg((sender) -> {
|
exitGameDlg = new ExitGameDlg((sender) -> {
|
||||||
canvas.popDialog(exitGameDlg);
|
canvas.popDialog(exitGameDlg);
|
||||||
paused = !paused;
|
quitMission();
|
||||||
world.dispose();
|
|
||||||
world = null;
|
|
||||||
canvas.setContent(new PlayMissionGui());
|
|
||||||
}, (sender) -> {
|
}, (sender) -> {
|
||||||
canvas.popDialog(exitGameDlg);
|
canvas.popDialog(exitGameDlg);
|
||||||
paused = !paused;
|
paused = !paused;
|
||||||
|
|
@ -113,6 +113,14 @@ class MarbleGame {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function quitMission() {
|
||||||
|
world.setCursorLock(false);
|
||||||
|
paused = false;
|
||||||
|
world.dispose();
|
||||||
|
world = null;
|
||||||
|
canvas.setContent(new PlayMissionGui());
|
||||||
|
}
|
||||||
|
|
||||||
public function playMission(mission:Mission) {
|
public function playMission(mission:Mission) {
|
||||||
var musicFileName = [
|
var musicFileName = [
|
||||||
'data/sound/groovepolice.ogg',
|
'data/sound/groovepolice.ogg',
|
||||||
|
|
|
||||||
|
|
@ -265,6 +265,7 @@ class MarbleWorld extends Scheduler {
|
||||||
this.marble.reset();
|
this.marble.reset();
|
||||||
|
|
||||||
var euler = startquat.quat.toEuler();
|
var euler = startquat.quat.toEuler();
|
||||||
|
this.marble.camera.init(cast this);
|
||||||
this.marble.camera.CameraYaw = euler.z + Math.PI / 2;
|
this.marble.camera.CameraYaw = euler.z + Math.PI / 2;
|
||||||
this.marble.camera.CameraPitch = 0.45;
|
this.marble.camera.CameraPitch = 0.45;
|
||||||
this.marble.camera.oob = false;
|
this.marble.camera.oob = false;
|
||||||
|
|
@ -688,7 +689,6 @@ class MarbleWorld extends Scheduler {
|
||||||
this.marbles.push(marble);
|
this.marbles.push(marble);
|
||||||
marble.level = cast this;
|
marble.level = cast this;
|
||||||
if (marble.controllable) {
|
if (marble.controllable) {
|
||||||
marble.camera.init(cast this);
|
|
||||||
marble.init(cast this);
|
marble.init(cast this);
|
||||||
this.scene.addChild(marble.camera);
|
this.scene.addChild(marble.camera);
|
||||||
this.marble = marble;
|
this.marble = marble;
|
||||||
|
|
@ -739,7 +739,6 @@ class MarbleWorld extends Scheduler {
|
||||||
var func = this.resourceLoadFuncs.pop();
|
var func = this.resourceLoadFuncs.pop();
|
||||||
func();
|
func();
|
||||||
this.loadingGui.setProgress((1 - resourceLoadFuncs.length / _loadingLength));
|
this.loadingGui.setProgress((1 - resourceLoadFuncs.length / _loadingLength));
|
||||||
MarbleGame.canvas.render(scene2d);
|
|
||||||
} else {
|
} else {
|
||||||
if (!_ready)
|
if (!_ready)
|
||||||
postInit();
|
postInit();
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@ typedef OptionsSettings = {
|
||||||
var musicVolume:Float;
|
var musicVolume:Float;
|
||||||
var soundVolume:Float;
|
var soundVolume:Float;
|
||||||
var vsync:Bool;
|
var vsync:Bool;
|
||||||
|
var fov:Int;
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef ControlsSettings = {
|
typedef ControlsSettings = {
|
||||||
|
|
@ -57,6 +58,7 @@ class Settings {
|
||||||
shadows: false,
|
shadows: false,
|
||||||
musicVolume: 1,
|
musicVolume: 1,
|
||||||
soundVolume: 0.7,
|
soundVolume: 0.7,
|
||||||
|
fov: 60,
|
||||||
vsync: #if js true #end
|
vsync: #if js true #end
|
||||||
#if hl
|
#if hl
|
||||||
false
|
false
|
||||||
|
|
@ -171,6 +173,8 @@ class Settings {
|
||||||
highScores.set(key, value);
|
highScores.set(key, value);
|
||||||
}
|
}
|
||||||
optionsSettings = json.options;
|
optionsSettings = json.options;
|
||||||
|
if (optionsSettings.fov == 0 #if js || optionsSettings.fov == null #end)
|
||||||
|
optionsSettings.fov = 60;
|
||||||
controlsSettings = json.controls;
|
controlsSettings = json.controls;
|
||||||
progression = json.progression;
|
progression = json.progression;
|
||||||
highscoreName = json.highscoreName;
|
highscoreName = json.highscoreName;
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,10 @@ import h2d.Scene;
|
||||||
import src.MarbleGame;
|
import src.MarbleGame;
|
||||||
|
|
||||||
class GuiProgress extends GuiControl {
|
class GuiProgress extends GuiControl {
|
||||||
public var progress:Float = 0;
|
public var progress(get, set):Float;
|
||||||
|
|
||||||
|
var _progress:Float = 0;
|
||||||
|
|
||||||
public var progressColor:Int = 0x2C98A264;
|
public var progressColor:Int = 0x2C98A264;
|
||||||
|
|
||||||
var progressRect:h2d.Graphics;
|
var progressRect:h2d.Graphics;
|
||||||
|
|
@ -45,4 +48,22 @@ class GuiProgress extends GuiControl {
|
||||||
MarbleGame.canvas.scene2d.removeChild(progressRect); // Refresh "layer"
|
MarbleGame.canvas.scene2d.removeChild(progressRect); // Refresh "layer"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function get_progress() {
|
||||||
|
return this._progress;
|
||||||
|
}
|
||||||
|
|
||||||
|
function set_progress(value:Float) {
|
||||||
|
this._progress = value;
|
||||||
|
if (progressRect != null) {
|
||||||
|
var renderRect = getRenderRectangle();
|
||||||
|
var rgb = progressColor >> 2;
|
||||||
|
var a = progressColor & 0xFF;
|
||||||
|
this.progressRect.clear();
|
||||||
|
this.progressRect.beginFill(rgb, a / 0xFF);
|
||||||
|
this.progressRect.drawRect(0, 0, renderRect.extent.x * progress, renderRect.extent.y);
|
||||||
|
this.progressRect.endFill();
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ package gui;
|
||||||
import hxd.res.BitmapFont;
|
import hxd.res.BitmapFont;
|
||||||
import h3d.Vector;
|
import h3d.Vector;
|
||||||
import src.ResourceLoader;
|
import src.ResourceLoader;
|
||||||
|
import src.MarbleGame;
|
||||||
|
|
||||||
class LoadingGui extends GuiImage {
|
class LoadingGui extends GuiImage {
|
||||||
public var setProgress:Float->Void;
|
public var setProgress:Float->Void;
|
||||||
|
|
@ -51,6 +52,9 @@ class LoadingGui extends GuiImage {
|
||||||
var cancelButton = new GuiButton(loadButtonImages("data/ui/loading/cancel"));
|
var cancelButton = new GuiButton(loadButtonImages("data/ui/loading/cancel"));
|
||||||
cancelButton.position = new Vector(320, 233);
|
cancelButton.position = new Vector(320, 233);
|
||||||
cancelButton.extent = new Vector(88, 50);
|
cancelButton.extent = new Vector(88, 50);
|
||||||
|
cancelButton.pressedAction = (sender) -> {
|
||||||
|
MarbleGame.instance.quitMission();
|
||||||
|
}
|
||||||
|
|
||||||
var overlay = new GuiImage(ResourceLoader.getImage("data/ui/loading/overlay.png").toTile());
|
var overlay = new GuiImage(ResourceLoader.getImage("data/ui/loading/overlay.png").toTile());
|
||||||
overlay.position = new Vector(151, 131);
|
overlay.position = new Vector(151, 131);
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,10 @@ class PlayMissionGui extends GuiImage {
|
||||||
var currentList:Array<Mission>;
|
var currentList:Array<Mission>;
|
||||||
|
|
||||||
var setSelectedFunc:Int->Void;
|
var setSelectedFunc:Int->Void;
|
||||||
|
var buttonHoldFunc:(dt:Float, mouseState:MouseState) -> Void;
|
||||||
|
|
||||||
|
var buttonCooldown:Float = 0.5;
|
||||||
|
var maxButtonCooldown:Float = 0.5;
|
||||||
|
|
||||||
public function new() {
|
public function new() {
|
||||||
super(ResourceLoader.getImage("data/ui/background.jpg").toTile());
|
super(ResourceLoader.getImage("data/ui/background.jpg").toTile());
|
||||||
|
|
@ -181,6 +185,35 @@ class PlayMissionGui extends GuiImage {
|
||||||
}
|
}
|
||||||
pmBox.addChild(pmNext);
|
pmBox.addChild(pmNext);
|
||||||
|
|
||||||
|
buttonHoldFunc = (dt:Float, mouseState:MouseState) -> {
|
||||||
|
var prevBox = pmPrev.getRenderRectangle();
|
||||||
|
var nextBox = pmNext.getRenderRectangle();
|
||||||
|
|
||||||
|
if (prevBox.inRect(mouseState.position) && mouseState.button == Key.MOUSE_LEFT) {
|
||||||
|
if (buttonCooldown <= 0) {
|
||||||
|
pmPrev.pressedAction(pmPrev);
|
||||||
|
buttonCooldown = maxButtonCooldown;
|
||||||
|
maxButtonCooldown *= 0.75;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nextBox.inRect(mouseState.position) && mouseState.button == Key.MOUSE_LEFT) {
|
||||||
|
if (buttonCooldown <= 0) {
|
||||||
|
pmNext.pressedAction(pmNext);
|
||||||
|
buttonCooldown = maxButtonCooldown;
|
||||||
|
maxButtonCooldown *= 0.75;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (buttonCooldown > 0 && mouseState.button == Key.MOUSE_LEFT)
|
||||||
|
buttonCooldown -= dt;
|
||||||
|
|
||||||
|
if (mouseState.button != Key.MOUSE_LEFT) {
|
||||||
|
maxButtonCooldown = 0.5;
|
||||||
|
buttonCooldown = maxButtonCooldown;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var pmBack = new GuiButton(loadButtonImages("data/ui/play/back"));
|
var pmBack = new GuiButton(loadButtonImages("data/ui/play/back"));
|
||||||
pmBack.position = new Vector(102, 260);
|
pmBack.position = new Vector(102, 260);
|
||||||
pmBack.extent = new Vector(79, 61);
|
pmBack.extent = new Vector(79, 61);
|
||||||
|
|
@ -428,6 +461,8 @@ class PlayMissionGui extends GuiImage {
|
||||||
public override function update(dt:Float, mouseState:MouseState) {
|
public override function update(dt:Float, mouseState:MouseState) {
|
||||||
super.update(dt, mouseState);
|
super.update(dt, mouseState);
|
||||||
|
|
||||||
|
buttonHoldFunc(dt, mouseState);
|
||||||
|
|
||||||
if (Key.isPressed(Key.LEFT))
|
if (Key.isPressed(Key.LEFT))
|
||||||
setSelectedFunc(currentSelection - 1);
|
setSelectedFunc(currentSelection - 1);
|
||||||
if (Key.isPressed(Key.RIGHT))
|
if (Key.isPressed(Key.RIGHT))
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue