fix reported bugs

This commit is contained in:
RandomityGuy 2021-07-13 13:24:54 +05:30
parent 4435ae4084
commit afb8a2dc97
10 changed files with 84 additions and 9 deletions

Binary file not shown.

View file

@ -75,7 +75,7 @@ class CameraController extends Object {
this.level = level;
// level.scene.addEventListener(onEvent);
// Sdl.setRelativeMouseMode(true);
level.scene.camera.fovY = 60;
level.scene.camera.fovY = Settings.optionsSettings.fov;
lockCursor();
}

View file

@ -56,7 +56,6 @@ class InstanceManager {
// minfo.transparencymeshbatch.material.mainPass.setPassName(minfo.mesh.material.mainPass.name);
minfo.transparencymeshbatch.shadersChanged = true;
minfo.transparencymeshbatch.material.mainPass.enableLights = minfo.mesh.material.mainPass.enableLights;
minfo.transparencymeshbatch.material.receiveShadows = false;
// minfo.transparencymeshbatch.material.mainPass.depthWrite = false;
// if (dtsShader != null) {
// dtsShader.currentOpacity = instance.gameObject.currentOpacity;

View file

@ -63,6 +63,11 @@ class Main extends hxd.App {
static function main() {
// 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();
}
}

View file

@ -16,6 +16,8 @@ import gui.Canvas;
class MarbleGame {
static var canvas:Canvas;
static var instance:MarbleGame;
var world:MarbleWorld;
var scene2d:h2d.Scene;
@ -29,6 +31,7 @@ class MarbleGame {
canvas = new Canvas(scene2d, cast this);
this.scene = scene;
this.scene2d = scene2d;
MarbleGame.instance = this;
#if js
// Pause shit
@ -91,10 +94,7 @@ class MarbleGame {
world.setCursorLock(false);
exitGameDlg = new ExitGameDlg((sender) -> {
canvas.popDialog(exitGameDlg);
paused = !paused;
world.dispose();
world = null;
canvas.setContent(new PlayMissionGui());
quitMission();
}, (sender) -> {
canvas.popDialog(exitGameDlg);
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) {
var musicFileName = [
'data/sound/groovepolice.ogg',

View file

@ -265,6 +265,7 @@ class MarbleWorld extends Scheduler {
this.marble.reset();
var euler = startquat.quat.toEuler();
this.marble.camera.init(cast this);
this.marble.camera.CameraYaw = euler.z + Math.PI / 2;
this.marble.camera.CameraPitch = 0.45;
this.marble.camera.oob = false;
@ -688,7 +689,6 @@ class MarbleWorld extends Scheduler {
this.marbles.push(marble);
marble.level = cast this;
if (marble.controllable) {
marble.camera.init(cast this);
marble.init(cast this);
this.scene.addChild(marble.camera);
this.marble = marble;
@ -739,7 +739,6 @@ class MarbleWorld extends Scheduler {
var func = this.resourceLoadFuncs.pop();
func();
this.loadingGui.setProgress((1 - resourceLoadFuncs.length / _loadingLength));
MarbleGame.canvas.render(scene2d);
} else {
if (!_ready)
postInit();

View file

@ -26,6 +26,7 @@ typedef OptionsSettings = {
var musicVolume:Float;
var soundVolume:Float;
var vsync:Bool;
var fov:Int;
}
typedef ControlsSettings = {
@ -57,6 +58,7 @@ class Settings {
shadows: false,
musicVolume: 1,
soundVolume: 0.7,
fov: 60,
vsync: #if js true #end
#if hl
false
@ -171,6 +173,8 @@ class Settings {
highScores.set(key, value);
}
optionsSettings = json.options;
if (optionsSettings.fov == 0 #if js || optionsSettings.fov == null #end)
optionsSettings.fov = 60;
controlsSettings = json.controls;
progression = json.progression;
highscoreName = json.highscoreName;

View file

@ -5,7 +5,10 @@ import h2d.Scene;
import src.MarbleGame;
class GuiProgress extends GuiControl {
public var progress:Float = 0;
public var progress(get, set):Float;
var _progress:Float = 0;
public var progressColor:Int = 0x2C98A264;
var progressRect:h2d.Graphics;
@ -45,4 +48,22 @@ class GuiProgress extends GuiControl {
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;
}
}

View file

@ -3,6 +3,7 @@ package gui;
import hxd.res.BitmapFont;
import h3d.Vector;
import src.ResourceLoader;
import src.MarbleGame;
class LoadingGui extends GuiImage {
public var setProgress:Float->Void;
@ -51,6 +52,9 @@ class LoadingGui extends GuiImage {
var cancelButton = new GuiButton(loadButtonImages("data/ui/loading/cancel"));
cancelButton.position = new Vector(320, 233);
cancelButton.extent = new Vector(88, 50);
cancelButton.pressedAction = (sender) -> {
MarbleGame.instance.quitMission();
}
var overlay = new GuiImage(ResourceLoader.getImage("data/ui/loading/overlay.png").toTile());
overlay.position = new Vector(151, 131);

View file

@ -26,6 +26,10 @@ class PlayMissionGui extends GuiImage {
var currentList:Array<Mission>;
var setSelectedFunc:Int->Void;
var buttonHoldFunc:(dt:Float, mouseState:MouseState) -> Void;
var buttonCooldown:Float = 0.5;
var maxButtonCooldown:Float = 0.5;
public function new() {
super(ResourceLoader.getImage("data/ui/background.jpg").toTile());
@ -181,6 +185,35 @@ class PlayMissionGui extends GuiImage {
}
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"));
pmBack.position = new Vector(102, 260);
pmBack.extent = new Vector(79, 61);
@ -428,6 +461,8 @@ class PlayMissionGui extends GuiImage {
public override function update(dt:Float, mouseState:MouseState) {
super.update(dt, mouseState);
buttonHoldFunc(dt, mouseState);
if (Key.isPressed(Key.LEFT))
setSelectedFunc(currentSelection - 1);
if (Key.isPressed(Key.RIGHT))