uh yeah i keep forgetting ab pushing these. sorry.

This commit is contained in:
lustlion
2022-01-18 00:14:54 +01:00
parent dd2debc0bd
commit 5a266d6b3a
73 changed files with 405 additions and 274 deletions

View File

@@ -25,7 +25,7 @@ Kupo = Entity:New(x,y)
o.bow_aim_frames = 8
o.hostile = true
o.lightRange = o.range/10
o.lightRange = o.range/2
o.light = CreateLight(o.pos.x,o.pos.y,o.lightRange)
setmetatable(o, self)
@@ -35,23 +35,17 @@ Kupo = Entity:New(x,y)
end
function Kupo:Smart()
self.light.pos.x = self.pos.x-self.target_offset.x
self.light.pos.y = self.pos.y-self.target_offset.y
self.target.x = main_Player.pos.x - main_Player.target_offset.x
self.target.y = main_Player.pos.y - main_Player.target_offset.y
local distance_x = self.target.x - self.pos.x
local distance_y = self.target.y - self.pos.y
local distance = math.sqrt(distance_x ^ 2 + distance_y ^ 2)
local angle = math.atan(distance_y/distance_x)
local angle = GetAngleFromVector(distance_x,distance_y)
self.draw_bow = false
if distance <= self.range then
if distance_x > 0 then
self.sprite_flip.x = 1
else
angle = angle + math.rad(180)
self.sprite_flip.x = -1
end
if self.hostile == true then
self.draw_bow = true
-- fix so it can rotate from 0 to 360
@@ -133,26 +127,29 @@ function Kupo:Smart()
end
function Kupo:HandleAnimation()
-- flip sprite to look in the direction is moving
if self.vel.x ~= 0 then self.sprite_flip.x = math.sign(self.vel.x) end
local distance_x = self.target.x - self.pos.x
local distance_y = self.target.y - self.pos.y
self.body:Animate()
self.body:Draw(
self.pos.x - Camera.pos.x - ( (self.sprite_offset.x) * math.cos(self.sprite_rotation) - (self.sprite_offset.y) * math.sin(self.sprite_rotation)) * self.sprite_scale.x * self.sprite_flip.x,
self.pos.y - Camera.pos.y - ( (self.sprite_offset.x) * math.sin(self.sprite_rotation) + (self.sprite_offset.y) * math.cos(self.sprite_rotation)) * self.sprite_scale.y * self.sprite_flip.y,
self.sprite_rotation,
self.sprite_scale.x * self.sprite_flip.x,
self.sprite_scale.y * self.sprite_flip.y
)
if distance_x > 0 then
self.sprite_flip.x = 1
else
self.sprite_flip.x = -1
end
if self.draw_bow == true then
self.bow:DrawFrame(
math.min(self.bow_frame,self.bow_frames),
self.pos.x + ( 8 * math.sin(self.bow_rotation)),
self.pos.y + (2 - 6 * math.cos(self.bow_rotation)),
self.bow_rotation
)
end
-- flip sprite to look in the direction is moving
if self.vel.x ~= 0 then self.sprite_flip.x = math.sign(self.vel.x) end
self.body:Animate()
self:Draw(self.body)
if self.draw_bow == true then
self.bow:DrawFrame(
math.min(self.bow_frame,self.bow_frames),
self.pos.x + ( 8 * math.sin(self.bow_rotation)),
self.pos.y + (2 - 6 * math.cos(self.bow_rotation)),
self.bow_rotation
)
end
end
function Kupo:DoPhysics()