Only auto aim and healthbars
This commit is contained in:
1 parent
54c6327ac7
commit
a914bd74fe
14 files changed
+95
-89
No files matched your search
+25
-28
@@ -46,7 +46,6 @@ window.addEventListener('orientationchange', resizeToWindow);
|
||||
resizeToWindow();
|
||||
|
||||
const input = new Input(canvas, viewport);
|
||||
const isMobile = input.isMobile;
|
||||
|
||||
const fullscreenButton = document.getElementById('fullscreen');
|
||||
const updateFullscreenLabel = () => {
|
||||
@@ -87,9 +86,7 @@ const updateCamera = (cx, cy) => {
|
||||
camera.y = Math.min(Math.max(0, targetY), Math.max(0, WORLD_H - viewport.height));
|
||||
};
|
||||
|
||||
let autoAim = isMobile;
|
||||
let muted = false;
|
||||
let autoAimNotice = 0;
|
||||
let muteNotice = 0;
|
||||
let gameStarted = false;
|
||||
let lastEventSeq = -1;
|
||||
@@ -555,7 +552,6 @@ const Lobby = (() => {
|
||||
};
|
||||
|
||||
el.name.value = me.name;
|
||||
el.room.value = localStorage.getItem('zombies.room') || '';
|
||||
|
||||
const setStatus = (text, error = false) => {
|
||||
el.status.textContent = text;
|
||||
@@ -579,7 +575,20 @@ const Lobby = (() => {
|
||||
return;
|
||||
}
|
||||
const my = players.find((p) => p.id === me.id) || null;
|
||||
el.players.textContent = `In room: ${players.map((p) => `${p.name}${p.host ? ' (host)' : ''}${p.id === me.id ? ' (you)' : ''}`).join(', ')}`;
|
||||
el.players.textContent = '';
|
||||
const title = document.createElement('div');
|
||||
title.className = 'lobby-players-title';
|
||||
title.textContent = 'Players';
|
||||
el.players.appendChild(title);
|
||||
for (const p of players) {
|
||||
const row = document.createElement('div');
|
||||
row.className = 'lobby-player';
|
||||
row.textContent = `${p.name}${p.id === me.id ? ' (you)' : ''}${p.host ? ' (host)' : ''}`;
|
||||
if (p.id === me.id) {
|
||||
row.classList.add('you');
|
||||
}
|
||||
el.players.appendChild(row);
|
||||
}
|
||||
el.roomCode.textContent = me.room;
|
||||
showInRoom();
|
||||
if (players.length === 1) {
|
||||
@@ -917,11 +926,11 @@ const drawHud = (state, my, now, t) => {
|
||||
textRenderer.draw(renderer, `Score: ${my.score}`, 12, 12, { size: 20, fillStyle: '#fff' });
|
||||
textRenderer.draw(renderer, `HP: ${my.hp}`, 12, 40, { size: 20, fillStyle: '#fff' });
|
||||
|
||||
if (autoAim) {
|
||||
const aaEntry = textRenderer.measure('AUTO-AIM', { size: 14, fillStyle: '#4fe3ff' });
|
||||
textRenderer.draw(renderer, 'AUTO-AIM', viewport.width - aaEntry.width - 12, 12, {
|
||||
size: 14,
|
||||
fillStyle: '#4fe3ff',
|
||||
if (my.dead && state.state === 'playing' && state.players.some((p) => p.id !== my.id && !p.dead)) {
|
||||
const specEntry = textRenderer.measure('SPECTATING', { size: 20, fillStyle: '#8a8a8a' });
|
||||
textRenderer.draw(renderer, 'SPECTATING', viewport.width / 2 - specEntry.width / 2, 60, {
|
||||
size: 20,
|
||||
fillStyle: '#8a8a8a',
|
||||
});
|
||||
}
|
||||
|
||||
@@ -947,15 +956,6 @@ const drawHud = (state, my, now, t) => {
|
||||
fillStyle: '#fff',
|
||||
});
|
||||
}
|
||||
if (autoAimNotice > 0) {
|
||||
autoAimNotice -= t;
|
||||
const notice = autoAim ? 'Auto-aim ON' : 'Auto-aim OFF';
|
||||
const entry = textRenderer.measure(notice, { size: 22, fillStyle: '#fff' });
|
||||
textRenderer.draw(renderer, notice, viewport.width / 2 - entry.width / 2, viewport.height / 2 - 20, {
|
||||
size: 22,
|
||||
fillStyle: '#4fe3ff',
|
||||
});
|
||||
}
|
||||
|
||||
void now;
|
||||
};
|
||||
@@ -978,20 +978,18 @@ const gameLoop = (now) => {
|
||||
muted = sounds.toggleMuted();
|
||||
muteNotice = 1.2;
|
||||
}
|
||||
if (!isMobile && input.pressed.has('q')) {
|
||||
input.clearPressed();
|
||||
autoAim = !autoAim;
|
||||
autoAimNotice = 1.2;
|
||||
}
|
||||
|
||||
renderer.clear(0, 0, 0, 1);
|
||||
|
||||
const snapshot = networking.curr;
|
||||
const frame = snapshot ? interpolate(now) : null;
|
||||
const own = frame ? frame.players.find((p) => p.id === me.id) || null : null;
|
||||
if (own) {
|
||||
entities.setTarget(own.x, own.y);
|
||||
updateCamera(own.x, own.y);
|
||||
const anchor = own
|
||||
? (own.dead ? frame.players.find((p) => p.id !== me.id && !p.dead) || own : own)
|
||||
: null;
|
||||
if (anchor) {
|
||||
entities.setTarget(anchor.x, anchor.y);
|
||||
updateCamera(anchor.x, anchor.y);
|
||||
} else {
|
||||
updateCamera(WORLD_W / 2, WORLD_H / 2);
|
||||
}
|
||||
@@ -1084,7 +1082,6 @@ const gameLoop = (now) => {
|
||||
keys: [...input.keys],
|
||||
aim: { x: mouse.x - own.x, y: mouse.y - own.y },
|
||||
fire: input.mouseDown,
|
||||
autoAim,
|
||||
});
|
||||
} else {
|
||||
networking.stopSendingInput();
|
||||
|
||||
Reference in new issue
Block a user