Pipe barriers now reach the top of the screen
On a tall phone the game world sits in the lower part of the display, so the upper pipe column used to stop in mid-air with dead sky above it - and the bird could actually fly up past the wall into that gap. The upper column is now drawn from above the top edge of the screen down to the gap, and its collision box matches, so the ceiling is always where the player expects it on any screen shape.
This commit is contained in:
parent
43db37e63b
commit
1acd790806
1 changed files with 6 additions and 2 deletions
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue