Hey everyone
I am currently doing a game, everything is going well so far, but I’ve found myself in a problem, i am trying to make a rectangular hitbox for a boat, and it works fine when it is at 90 degrees, but when it turns i am having problems with the hitbox, i kinda solved this issue with "vec2(bullet.x,bullet.y):dist(Enemy.pos) < 45"but this creates a circular hitbox and not a rectangular one :(, here i put a failed approach i tried, maybe i am doing something wrong, if anyone could help me i would thank you a lot
--[[
local px= Enemy.pos.x
local py= Enemy.pos.y
pushMatrix()
translate(Enemy.pos.x,Enemy.pos.y)
rotate(Enemy.Angle)
pushStyle()
fill(255, 0, 0, 255)
ellipse(bullet.x-px,bullet.y-py,10) --this is to see the bullets hitbox
fill(28, 0, 255, 255)
rectMode(CORNER)
rect(-22,-54,44,108) --this is to see the boat hitbox
popStyle()
if (bullet.x-px) > -22 and (bullet.x-px) < 22 and (bullet.y-py) > -54 and (bullet.y-py) < 54 then
sound("A Hero's Quest:Drop")
table.remove(self.shots,i)
if InfiniteLife == false then
self.life=self.life-1
end
end
popMatrix()]]