Skip to content

Commit ca470b0

Browse files
committed
fix: Make Gnome Web browser not constantly flip the canvas
1 parent e521b94 commit ca470b0

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

src/game.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import { Drop } from './drop';
2929
import { CreatureType, Realm, UnitData } from './data/types';
3030
import { setAudioMode } from './sound/soundsys';
3131
import BotController from './bot';
32+
3233
/* eslint-disable prefer-rest-params */
3334

3435
/* NOTES/TODOS
@@ -52,6 +53,12 @@ import BotController from './bot';
5253

5354
type AnimationID = number;
5455

56+
const webKitGtkUserAgent = /(X11|Linux).*AppleWebKit\/.*Version\/.*Safari\//i;
57+
58+
function shouldUseCanvasRenderer() {
59+
return webKitGtkUserAgent.test(navigator.userAgent);
60+
}
61+
5562
export type MetaPowersState = {
5663
executeMonster: boolean;
5764
resetCooldowns: boolean;
@@ -216,7 +223,8 @@ export default class Game {
216223
};
217224

218225
// Phaser
219-
this.Phaser = new Phaser.Game(1920, 1080, Phaser.AUTO, 'combatwrapper', {
226+
const renderer = shouldUseCanvasRenderer() ? Phaser.CANVAS : Phaser.AUTO;
227+
this.Phaser = new Phaser.Game(1920, 1080, renderer, 'combatwrapper', {
220228
update: this.phaserUpdate.bind(this),
221229
render: this.phaserRender.bind(this),
222230
});

0 commit comments

Comments
 (0)