mirror of
https://git.leinelab.org/Mal/mr-crocs-adventures.git
synced 2025-09-11 02:57:36 +02:00
Optimization for Firefox and Chrome
This commit is contained in:
16
js/module.js
16
js/module.js
@@ -112,7 +112,16 @@ function MainLoop(timestamp)
|
||||
}
|
||||
|
||||
context.clearRect(0, 0, window.innerWidth, window.innerHeight);
|
||||
architecture.draw(context, camera);
|
||||
|
||||
switch (browser) {
|
||||
case 'Chrome':
|
||||
architecture.drawForChrome(context, camera);
|
||||
break;
|
||||
|
||||
default:
|
||||
architecture.drawForFirefox(context, camera);
|
||||
}
|
||||
|
||||
mrCroc.draw(context, camera);
|
||||
gisela.draw(context, camera);
|
||||
userInterface.draw(context);
|
||||
@@ -154,7 +163,8 @@ let level = Level.createFromFile(Setting.LEVELS_LOCATION + LEVEL[levelIndex]);
|
||||
|
||||
const GAME_SPEED = 1;
|
||||
const GRAVITY = level.gravity;
|
||||
let fps = 120;
|
||||
let fps = 60;
|
||||
const browser = navigator.userAgent.indexOf('Firefox') === -1 ? 'Chrome' : 'Firefox';
|
||||
let frameDuration;
|
||||
let lastRendered = undefined;
|
||||
let lastTimestamp = undefined;
|
||||
@@ -179,8 +189,6 @@ loader.addImage(Setting.TILESET_LOCATION + GraphicSet[level.getTilesetId()].tile
|
||||
loader.addImage(Setting.GRAPHICS_LOCATION + 'gisela-right.png');
|
||||
loader.addImage(Setting.GRAPHICS_LOCATION + 'gisela-left.png');
|
||||
|
||||
// new FrameRateMeasurer();
|
||||
|
||||
window.addEventListener(
|
||||
'imagesloaded',
|
||||
() => {
|
||||
|
||||
Reference in New Issue
Block a user