initialization is very slightly faster this way, I think
This commit is contained in:
@ -568,7 +568,7 @@ end
|
||||
function hurtbox(ship)
|
||||
local h = ship.hurt
|
||||
local x1,y1 = ship.x + h.x_off, ship.y+h.y_off
|
||||
return {x1, y1, x1+h.width, y1+h.height}
|
||||
return {x1=x1, y1=y1, x2=x1+h.width, y2=y1+h.height}
|
||||
end
|
||||
|
||||
function ship_m:maybe_shoot(gun)
|
||||
@ -1354,12 +1354,11 @@ end
|
||||
|
||||
-- box: x1, y1, x2, y2
|
||||
function collides(b1, b2)
|
||||
-- x1, y1, x2, y2
|
||||
return
|
||||
b1[1]<=b2[3]
|
||||
and b1[2]<=b2[4]
|
||||
and b1[3]>=b2[1]
|
||||
and b1[4]>=b2[2]
|
||||
b1.x1<=b2.x2
|
||||
and b1.y1<=b2.y2
|
||||
and b1.x2>=b2.x1
|
||||
and b1.y2>=b2.y1
|
||||
end
|
||||
|
||||
collider = mknew{
|
||||
@ -1380,8 +1379,8 @@ collider = mknew{
|
||||
}
|
||||
|
||||
function collider_indexes(box)
|
||||
local ret, ylo, yhi = {}, box[2]\8, box[4]\8
|
||||
for x = box[1]\8, box[3]\8 do
|
||||
local ret, ylo, yhi = {}, box.y1\8, box.y2\8
|
||||
for x = box.x1\8, box.x2\8 do
|
||||
for y = ylo, yhi do
|
||||
add(ret, x+(y<<8))
|
||||
end
|
||||
|
Reference in New Issue
Block a user