86 lines
3.5 KiB
HTML
86 lines
3.5 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<title>headless harness</title>
|
|
<script>
|
|
// error trap BEFORE anything else
|
|
window.onerror = function (msg, src, line, col, err) {
|
|
console.log('PAGEERROR: ' + msg + ' @ ' + (src || '').split('/').pop() + ':' + line + ':' + col +
|
|
(err && err.stack ? ' | ' + err.stack.split('\n').slice(0, 3).join(' <- ') : ''));
|
|
return false;
|
|
};
|
|
window.onunhandledrejection = function (e) {
|
|
console.log('PAGEREJECTION: ' + (e.reason && e.reason.stack || e.reason));
|
|
};
|
|
// headless Chrome throttles rAF; drive it with timers so the game loop runs
|
|
window.requestAnimationFrame = function (cb) { return setTimeout(function () { cb(performance.now()); }, 16); };
|
|
</script>
|
|
<link rel="stylesheet" href="../css/style.css">
|
|
</head>
|
|
<body>
|
|
<div id="wrap"><canvas id="game" width="960" height="640"></canvas></div>
|
|
<script src="../js/utils.js"></script>
|
|
<script src="../js/state.js"></script>
|
|
<script src="../js/input.js"></script>
|
|
<script src="../js/sfx.js"></script>
|
|
<script src="../js/audio.js"></script>
|
|
<script src="../js/sprites.js"></script>
|
|
<script src="../js/particles.js"></script>
|
|
<script src="../js/weapons.js"></script>
|
|
<script src="../js/bullets.js"></script>
|
|
<script src="../js/pickups.js"></script>
|
|
<script src="../js/items.js"></script>
|
|
<script src="../js/perks.js"></script>
|
|
<script src="../js/enemies.js"></script>
|
|
<script src="../js/bosses.js"></script>
|
|
<script src="../js/rooms.js"></script>
|
|
<script src="../js/player.js"></script>
|
|
<script src="../js/hud.js"></script>
|
|
<script src="../js/main.js"></script>
|
|
<script>
|
|
window.addEventListener('load', function () {
|
|
setTimeout(function () {
|
|
var FLOOR = parseInt((location.search.match(/floor=(\d)/) || [0, '1'])[1], 10);
|
|
console.log('DRIVER: starting run, floor ' + FLOOR);
|
|
startRun();
|
|
for (var i = 1; i < FLOOR; i++) nextFloor();
|
|
var bossRoom = Object.values(G.rooms).find(function (r) { return r.type === 'boss'; });
|
|
enterRoom(bossRoom.gx, bossRoom.gy);
|
|
G.player.hp = 99999;
|
|
console.log('DRIVER: boss = ' + (G.boss && G.boss.bossKind));
|
|
var lastTime = -1, stalls = 0, ticks = 0, weaponIds = Object.keys(WEAPONS);
|
|
var fight = setInterval(function () {
|
|
G.player.hp = 99999;
|
|
if (G.boss) { Input.mx = G.boss.x; Input.my = G.boss.y; }
|
|
Input.mdown = true;
|
|
if (ticks % 90 === 45) { // wiggle movement
|
|
['w', 'a', 's', 'd'].forEach(function (k) { Input.keys[k] = false; });
|
|
Input.keys[['w', 'a', 's', 'd'][Math.floor(Math.random() * 4)]] = true;
|
|
}
|
|
if (ticks % 800 === 700) { // cycle weapons
|
|
G.player.weapon = { id: weaponIds[Math.floor(Math.random() * weaponIds.length)], ammo: 999 };
|
|
console.log('DRIVER: weapon -> ' + G.player.weapon.id);
|
|
}
|
|
if (G.mode === 'levelup') choosePerk(0);
|
|
if (G.time === lastTime && G.mode === 'play') {
|
|
stalls++;
|
|
if (stalls > 30) {
|
|
console.log('DRIVER: GAME LOOP STALLED at G.time=' + G.time.toFixed(2) + ' mode=' + G.mode +
|
|
' bossState=' + (G.boss && G.boss.state) + ' ebullets=' + G.ebullets.length);
|
|
clearInterval(fight);
|
|
}
|
|
} else { stalls = 0; lastTime = G.time; }
|
|
ticks++;
|
|
if (ticks % 100 === 0) {
|
|
console.log('DRIVER: t=' + G.time.toFixed(1) + ' bossHp=' + (G.boss ? Math.round(G.boss.hp) : 'dead') +
|
|
' bossState=' + (G.boss && G.boss.state) + ' ebullets=' + G.ebullets.length + ' enemies=' + G.enemies.length);
|
|
}
|
|
if (ticks > 900) { console.log('DRIVER: DONE'); clearInterval(fight); }
|
|
}, 100);
|
|
}, 600);
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|