From 2cd7c64dd95c6eab22b5fb9fe3c4409aa4651488 Mon Sep 17 00:00:00 2001 From: Kistaro Windrider Date: Sat, 28 Jun 2025 22:35:36 -0700 Subject: [PATCH] micro-optimize bullet details Shots that miss are most likely to not be there yet, so check Y-top first. If I assume shots will never be larger than 16 pixels per side, there is no reason to check the ship's genuine width and height. --- vacuum_gambit.p8 | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/vacuum_gambit.p8 b/vacuum_gambit.p8 index 2454f10..769bf46 100644 --- a/vacuum_gambit.p8 +++ b/vacuum_gambit.p8 @@ -775,7 +775,7 @@ end function bullet_base:move() local x,y = self.x + self.dx, self.y+self.dy self.x,self.y=x,y - return (y<=128) and (y >= -(self.height<<3)) and (x <= 128) and (x >= -(self.width<<3)) + return (y<=128) and (y >= -16) and (x <= 128) and (x >= -16) end function bullet_base:draw() @@ -1351,11 +1351,11 @@ end -- box: x1, y1, x2, y2 function collides(b1, b2) - return - b1.x1<=b2.x2 - and b1.y1<=b2.y2 - and b1.x2>=b2.x1 + return + b1.y1<=b2.y2 and b1.y2>=b2.y1 + and b1.x1<=b2.x2 + and b1.x2>=b2.x1 end collider = mknew{