local Vector3 = require "types.vector3" local util = require "util" local TEXTURE = "images/tongue.png" local Feed = { position = {}, direction = {}, velocity = {}, landed = false, speed = 0.15, } Feed.__index = Feed function Feed.new(p_position, p_direction) local f = util.shallow_copy(Feed) f.position = p_position:copy() f.direction = p_direction:copy() 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