From b487c2403b10013526843bc21f2c039058282c2e Mon Sep 17 00:00:00 2001 From: Florian <45694132+flo-bit@users.noreply.github.com> Date: Sat, 27 Jul 2024 07:37:52 +0200 Subject: [PATCH] less flickering --- src/app.ts | 16 ++++++++++------ src/light.ts | 16 +++++++++++----- src/player.ts | 4 ++-- 3 files changed, 23 insertions(+), 13 deletions(-) diff --git a/src/app.ts b/src/app.ts index e803e6d..42482c8 100644 --- a/src/app.ts +++ b/src/app.ts @@ -47,7 +47,7 @@ export default class Game { debug: boolean = false; - showStats: boolean = true; + showStats: boolean = false; stats?: Stats; @@ -78,10 +78,11 @@ export default class Game { this.lightManager = new LightManager(this); sound.add('music-intro', { - url: './music-intro.mp3' + url: './music-intro.mp3', + volume: 0.3 }); - sound.add('music', { url: './music.mp3', loop: true }); - sound.add('laser', { url: './laser.mp3', volume: 0.3 }); + sound.add('music', { url: './music.mp3', loop: true, volume: 0.3 }); + sound.add('laser', { url: './laser.mp3', volume: 0.1 }); } async setupPhysicsWorld() { @@ -192,8 +193,11 @@ export default class Game { const interpolationSpeed = 0.05; const interpolationFactor = 1 - Math.pow(1 - interpolationSpeed, deltaTime / (1000 / 60)); - this.container.x += (position.x - this.container.x) * interpolationFactor; - this.container.y += (position.y - this.container.y) * interpolationFactor; + //this.container.x += (position.x - this.container.x) * interpolationFactor; + //this.container.y += (position.y - this.container.y) * interpolationFactor; + + this.container.x = position.x; + this.container.y = position.y; } if (this.stats) this.stats.end(); diff --git a/src/light.ts b/src/light.ts index 0f30eff..2ecac45 100644 --- a/src/light.ts +++ b/src/light.ts @@ -44,6 +44,8 @@ export class Light { detail: number = 120; + shape?: PIXI.Graphics; + constructor(game: Game, options: LightOptions) { this.game = game; @@ -65,6 +67,10 @@ export class Light { if (options.detail) this.detail = options.detail; if (options.flicker !== undefined) this.flicker = options.flicker; + if (this.game.debug) { + this.shape = new PIXI.Graphics().circle(0, 0, 5).fill(this.color); + this.lightContainer.addChild(this.shape); + } this.createLight(); this.game.container.addChild(this.lightContainer); @@ -146,7 +152,7 @@ export class Light { const rays = this.detail; const angleStep = (Math.PI * 2) / rays; - const rayLength = 100000; + const rayLength = 10000000; let firstPoint; @@ -178,7 +184,7 @@ export class Light { this.shadow.lineTo(firstPoint.x, firstPoint.y); } } - this.shadow.fill(0); + this.shadow.fill(0, 0); } update(deltaTime: number) { @@ -190,9 +196,9 @@ export class Light { this.light.alpha = this._alpha + (Math.random() - 0.5) * 0.03; this.light.scale.set(this._scale + Math.random() * 0.1); - if (Math.random() < 1 / deltaTime) { - this.light.alpha = this._alpha * 0.5; - } + // if (Math.random() < 1 / deltaTime) { + // this.light.alpha = this._alpha * 0.5; + // } } } diff --git a/src/player.ts b/src/player.ts index 0407a80..5566549 100644 --- a/src/player.ts +++ b/src/player.ts @@ -92,8 +92,8 @@ export default class Player { this.leftEye = new Eye(this.playerContainer, -this.size / 4, 0); this.rightEye = new Eye(this.playerContainer, this.size / 4, 0); - this.x = 280; - this.y = 340; + this.x = 0; + this.y = 0; } createHealthBar() {