Projectile = Entity:New(x,y) function Projectile:New(x,y,angle,data) local o = Entity:New(x,y,angle) o.target = {} o.hitbox = 2 o.draw_scale = 2 o.angle = angle o.hits = data.hits o.damage = data.damage -- i guess damage is useless to the player but maybe there's stuff that has hp? like obstacles o.animation = AnimationContainer:New(data.animation) o.moveSpeed = data.moveSpeed o.moveSpeedLimits = data.moveSpeedLimits or { min = 0, max = 100} o.moveSpeedIncrease = data.moveSpeedIncrease or 0 o.moveHorizontalIncrease = data.moveHorizontalIncrease or 0 o.moveVerticalIncrease = data.moveVerticalIncrease or 0 o.maximumTurnRate = data.maximumTurnRate or 0 o.moveHorizontal = 0 o.moveVertical = 0 -- lists o:AddList(List.Simulate) local friendly = data.friendly or false local hostile = data.hostile or false if friendly == true then o:AddList(List.FriendlyBullet) end if hostile == true then o:AddList(List.EnemyBullet) end setmetatable(o, self) self.__index = self return o end function Projectile:Step() self.moveSpeed = self.moveSpeed + self.moveSpeedIncrease self.moveSpeed = math.max(self.moveSpeedLimits.min,self.moveSpeed) self.moveSpeed = math.min(self.moveSpeedLimits.max,self.moveSpeed) self.moveHorizontal = self.moveHorizontal + self.moveHorizontalIncrease self.moveVertical = self.moveVertical + self.moveVerticalIncrease local move_x = (self.moveSpeed) * math.cos(self.angle) + self.moveHorizontal local move_y = (self.moveSpeed) * math.sin(self.angle) + self.moveVertical self:AngleTowards( You.pos.x, You.pos.y ) self.pos.x = self.pos.x + move_x + self.maximumTurnRate * math.cos(self.angle) self.pos.y = self.pos.y + move_y + self.maximumTurnRate * math.sin(self.angle) self:AngleTowards( self.pos.x + move_x, self.pos.y + move_y ) -- bends towards the player? owo if self.pos.x < 0 or self.pos.x > window_width or self.pos.y < 0 or self.pos.y > window_height then self:RemoveList(List.Simulate) self:RemoveList(List.CollidesEnemies) end end function Projectile:Draw() self.animation:Animate() love.graphics.line(self.pos.x, self.pos.y, self.pos.x + 10*self.vel.x, self.pos.y + 10*self.vel.y) self.animation:Draw( self.pos.x, self.pos.y, self.angle+math.rad(90), self.draw_scale, self.draw_scale ) --[[love.graphics.draw( self.sprite, self.pos.x, self.pos.y, self.angle+math.rad(90), self.draw_scale, self.draw_scale, self.sprite:getPixelWidth()/2, self.sprite:getPixelHeight()/2 )]] end