diff --git a/index.html b/index.html index b3a9920..9bd6d43 100644 --- a/index.html +++ b/index.html @@ -950,7 +950,8 @@ function lucky(p, kind) { /* ---------------- collisions & scoring ---------------- */ function pipeHit(box) { for (const p of S.pipes) { - const top = { x: p.x, y: 0, w: p.theme.w, h: p.gapY }; + /* the upper column reaches up past the top of the screen */ + const top = { x: p.x, y: -1e5, w: p.theme.w, h: p.gapY + 1e5 }; const bot = { x: p.x, y: p.gapY + p.gap, w: p.theme.w, h: GROUND_Y - (p.gapY + p.gap) }; if (aabb(box, top) || aabb(box, bot)) return p; } @@ -1362,9 +1363,12 @@ function drawPipe(p) { const topH = p.gapY; const botY = p.gapY + p.gap; const botH = GROUND_Y - botY; + /* the column starts above the top of the screen so the barrier always + reaches the top edge, whatever shape the device is */ + const startY = Math.floor((-VIEW.oy / VIEW.scale) / BLOCK) * BLOCK; for (let col = 0; col < cols; col++) { const bx = Math.round(p.x + col * BLOCK); - for (let y = 0; y < topH; y += BLOCK) { + for (let y = startY; y < topH; y += BLOCK) { block(ctx, bx, y, (y + BLOCK > topH - BLOCK) ? th.top : th.body, p.seed + col); } for (let y = botY; y < botY + botH; y += BLOCK) {