N
O
0
o
β°
β
Β°
-- Bird.lua (Attach this script to your bird Blueprint/Actor)
local FLAP_STRENGTH = 600 -- How high the bird jumps
local GRAVITY = 2000 -- How fast the bird falls
local VELOCITY_Y = 0 -- Current vertical speed of the bird
-- Called every frame
function onUpdate(dt)
-- Apply gravity
VELOCITY_Y = VELOCITY_Y + GRAVITY * dt
self.actor.y = self.actor.y + VELOCITY_Y * dt
-- Clamp bird's position (prevent it from going off-screen)
if self.actor.y < 0 then
self.actor.y = 0
VELOCITY_Y = 0
elseif self.actor.y > castle.dimensions.height - self.actor.height then -- Assuming your bird has a 'height' property
self.actor.y = castle.dimensions.height - self.actor.height
VELOCITY_Y = 0
-- Game Over if it hits the bottom (implement game over logic here)
end
end
-- Called when the user clicks/taps
function onInput(input)
if input.isDown then
VELOCITY_Y = -FLAP_STRENGTH -- Make th