Shader for lighting, fairy line of view, tileset change, broke lights, sorry

This commit is contained in:
lustlion
2022-02-05 12:32:47 +01:00
parent 15f5ef8454
commit cbf29ced65
13 changed files with 176 additions and 31 deletions

View File

@@ -73,6 +73,31 @@ function Entity:Kill()
self = nil
end
function Entity:CheckVisionLine(entity)
local target_x = entity.pos.x + entity.target_offset.x
local target_y = entity.pos.y + entity.target_offset.y
local distance_x = target_x - self.pos.x
local distance_y = target_y - self.pos.y
local angle = GetAngleFromVector(distance_x,distance_y)
local distance = math.sqrt(distance_x ^ 2 + distance_y ^ 2)
local is_colliding = false
for i=1, distance, game.scale do
if isThereObjectAt(
self.pos.x+math.cos(angle)*i,
self.pos.y+math.sin(angle)*i,
LoadedObjects.Collisions
) then
is_colliding = true
end
end
return not is_colliding
end
function Entity:Draw(animation)
local c1, c2, c3, a = love.graphics.getColor()
love.graphics.setColor(self.sprite_tint[1],self.sprite_tint[2],self.sprite_tint[3],self.sprite_alpha)
@@ -138,6 +163,39 @@ function Entity:isCollidingAtAll(x,y)
return result
end
function Entity:CheckVisionLineDebug(entity)
local c1, c2, c3, a = love.graphics.getColor()
local target_x = entity.pos.x + entity.target_offset.x
local target_y = entity.pos.y + entity.target_offset.y
local distance_x = target_x - self.pos.x
local distance_y = target_y - self.pos.y
local angle = GetAngleFromVector(distance_x,distance_y)
local distance = math.sqrt(distance_x ^ 2 + distance_y ^ 2)
for i=1, distance, game.scale do
if isThereObjectAt(
self.pos.x+math.cos(angle)*i,
self.pos.y+math.sin(angle)*i,
LoadedObjects.Collisions
) then
love.graphics.setColor(1,0,0)
else
love.graphics.setColor(0,1,0)
end
love.graphics.line(
self.pos.x+math.cos(angle)*i-1 - Camera.pos.x,
self.pos.y+math.sin(angle)*i-1 - Camera.pos.y,
self.pos.x+math.cos(angle)*i - Camera.pos.x,
self.pos.y+math.sin(angle)*i - Camera.pos.y
)
end
love.graphics.setColor(c1,c2,c3,a)
end
function Entity:Debug()
-- draw center GREEN
love.graphics.setColor(0,1,0)