Skip to content

Commit 91473de

Browse files
committed
Make bouncy projectiles bounce off enemies when fired by the bouncer
class copied from RobotLucca's BYTEPATH Unofficial Patch where it had this comment: BONUS FEATURE: Bouncer class allows Bounce Attack to bounce off enemies This makes Bounce Attack more viable, as more bounces = more damage Bounce Projectiles will pierce first, then begin bouncing *FEATURE CURRENTLY DISABLED until I can bother to make this effect more "natural"
1 parent 3aae7d0 commit 91473de

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

GameObject.lua

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,19 @@ function GameObject:enemyProjectileCollisions()
6363
no_projectiles = proj.object.proj_spawned
6464
})
6565
end
66+
elseif current_room.player.bouncer and proj.object.bounce and proj.object.bounce > 0 then
67+
proj.object.bounce = proj.object.bounce - 1
68+
local x1, y1 = proj.object.shape:center()
69+
local x2, y2 = self.shape:center()
70+
local n = math.atan2(y2 - y1, x2 -x1)
71+
local nx, ny = math.cos(n), math.sin(n)
72+
local wall = n - math.pi/2
73+
local wx, wy = math.cos(wall), math.sin(wall)
74+
local vx, vy = math.cos(proj.object.r), math.sin(proj.object.r)
75+
local ux, uy = (vx * nx + vy * ny) * nx, (vx * nx + vy * ny) * ny
76+
local wx, wy = vx - ux, vy - uy
77+
local Vx, Vy = wx - ux, wy - uy
78+
proj.object.r = math.acos(Vx), math.asin(Vy)
6679
else
6780
proj.object:die()
6881
end

0 commit comments

Comments
 (0)