2025-02-14 17:04:45 +00:00
|
|
|
local Vector3 = require "types.vector3"
|
|
|
|
|
|
|
|
local TEXTURE = "images/tongue.png"
|
|
|
|
|
2025-02-15 14:25:27 +00:00
|
|
|
local Feed = {}
|
2025-02-14 17:04:45 +00:00
|
|
|
|
|
|
|
Feed.__index = Feed
|
|
|
|
|
2025-02-15 14:25:27 +00:00
|
|
|
function Feed.new(position, direction)
|
|
|
|
local f = {
|
|
|
|
position = position:copy(),
|
|
|
|
direction = direction:copy(),
|
|
|
|
velocity = Vector3(),
|
|
|
|
landed = false,
|
|
|
|
occupied = false,
|
|
|
|
|
|
|
|
speed = 0.15,
|
|
|
|
}
|
2025-02-14 17:04:45 +00:00
|
|
|
f.velocity = f.direction * f.speed
|
|
|
|
f.velocity.y = 0.1
|
|
|
|
|
|
|
|
return setmetatable(f, Feed)
|
|
|
|
end
|
|
|
|
|
|
|
|
function Feed:tick(ctx)
|
|
|
|
if not self.landed then
|
|
|
|
-- gravity
|
|
|
|
self.velocity.y = math.max(self.velocity.y - 0.02, -0.2)
|
|
|
|
self.position = self.position + self.velocity
|
|
|
|
end
|
|
|
|
|
|
|
|
if self.position.y <= 0.2 and not self.landed then
|
|
|
|
self.position.y = 0.2
|
|
|
|
self.landed = true
|
|
|
|
end
|
|
|
|
draw_billboard{position = self.position, texture = TEXTURE, size = Vector3(0.2, 0.2)}
|
|
|
|
end
|
|
|
|
|
|
|
|
return Feed
|