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("Simulate") local friendly = data.friendly or false local hostile = data.hostile or false if friendly == true then o:AddList("FriendlyBullet") end if hostile == true then o:AddList("HostileBullet") o.grazeTimer = 0 o.Grazed = false 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 ) -- bends towards the player? owo 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 ) -- if out of s screen, kill. if self.pos.x < 0 or self.pos.x > windowWidth or self.pos.y < 0 or self.pos.y > windowHeight then self:RemoveList("Simulate") self:RemoveList("EnemyBullet") self:RemoveList("FriendlyBullet") end end function Projectile:Draw() self.animation:Animate() self.animation:Draw( self.pos.x, self.pos.y, self.angle+math.rad(90), self.draw_scale, self.draw_scale ) love.graphics.line(self.pos.x, self.pos.y, self.pos.x + 50*self.vel.x, self.pos.y + 50*self.vel.y) --[[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