From 61029569c7927aaee624e81ec02cb10871c4fece Mon Sep 17 00:00:00 2001 From: James Turk Date: Sat, 6 May 2023 17:52:05 -0500 Subject: [PATCH] crush line --- games/against.p8 | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/games/against.p8 b/games/against.p8 index 91dadbf..9004e34 100644 --- a/games/against.p8 +++ b/games/against.p8 @@ -57,10 +57,10 @@ end function start_level() walls = {} - walls[30]={{0,10}, {25,30}, {38,44}} - walls[50]={{5,10}, {20,30}, {45,55}} - walls[70]={{0,10}, {20,30}, {44,55}} - walls[90]={{0,10}, {25,30}, {38,44}} + walls[30]={{0,20}} + walls[50]={{20,60}} + walls[70]={{90, 120}} + walls[90]={{10, 40}, {80, 100}} the_line = 64 spr_frame = 1 opp_frame = 1 @@ -86,10 +86,11 @@ end function collide_platforms() local left = the_line - 6 local right = the_line + 6 + local py = 128-floor for y, platforms in pairs(walls) do for plat in all(platforms) do -- check if there's a platform at this level - if floor > y and floor - y < 8 then + if py > y and py - y < 8 then -- check if either edge of player+opp is between edges if (left > plat[1] and left < plat[2]) or (right > plat[1] and right < plat[2]) then printh("xcol "..(the_line-6).." "..plat[1].."-"..plat[2]) @@ -101,10 +102,19 @@ function collide_platforms() end function draw_player() - spr(spr_frame, the_line-8, 120-floor, 1, 1, false) - pal({[LIGHT]=DARK}) - spr(opp_frame, the_line, 120-floor, 1, 1, true) - pal() + if crush_line then + local squash_h = 8-(crush_line - (120-floor)) + printh(crush_line.." "..(120-floor)) + sspr(40, 0, 8, 8, the_line-8, crush_line, 8, squash_h, false) + pal({[LIGHT]=DARK}) + sspr(40, 0, 8, 8, the_line, crush_line, 8, squash_h, true) + pal() + else + spr(spr_frame, the_line-8, 120-floor, 1, 1, false) + pal({[LIGHT]=DARK}) + spr(opp_frame, the_line, 120-floor, 1, 1, true) + pal() + end end function draw_level() @@ -152,7 +162,9 @@ function update_level() the_line += dx -- collision - collide_platforms() + if not crush_line then + collide_platforms() + end -- player frames: -- still: 1