Round at draw stage

This commit is contained in:
zenoamaro committed 2019-06-30 02:04:58 +02:00
1 parent 926e41096b
commit 4ba6851165
4 files changed
+28 -17

No files matched your search

+6 -6
View File
@@ -38,7 +38,7 @@ for (let c of [sky, terrain, traces, foreground]) {
// Init players
let i=0;
for (let color of PLAYER_COLORS) {
const x = Math.round(50 + (W-100) / 5 * i);
const x = 50 + (W-100) / 5 * i;
const y = landHeight(terrain, x) + 1;
const a = x > W/2 ? 45 : 180-45;
players.push({
@@ -152,8 +152,8 @@ function update() {
PROJECTILE_MIN_SOUND_FREQUENCY
);
projectile.t += PROJECTILE_ITERATION_PROGRESS;
projectile.x = Math.ceil(x);
projectile.y = Math.floor(y);
projectile.x = x;
projectile.y = y;
projectile.osc.frequency.setValueAtTime(f, audio.currentTime);
if (projectile.y > H || isTerrain(terrain, projectile.x, projectile.y)) {
@@ -315,8 +315,8 @@ function updateParticles() {
);
particle.t++;
particle.x = Math.round(tx);
particle.y = Math.round(ty);
particle.x = tx;
particle.y = ty;
}
}
@@ -337,7 +337,7 @@ function drawPlayers() {
const {x, y, a, c, dead} = player;
if (dead) continue;
const [px, py] = vec(x, y-3, a+180, 3);
drawLine(foreground, x, y-3, Math.round(px), Math.round(py), c);
drawLine(foreground, x, y-3, px, py, c);
drawRect(foreground, x-4, y-2, 8, 2, c);
drawRect(foreground, x-3, y-0, 6, 1, c);
}