New lighting!

This commit is contained in:
lustlion 2021-10-27 11:06:08 +02:00
parent 5e1148f49d
commit 538a1f77f8
11 changed files with 158 additions and 91 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

1
data/levels/33 (2).json Normal file
View File

@ -0,0 +1 @@
[[1,1,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[1,1,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[1,1,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[1,1,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[1,1,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[1,1,21,4,4,4,4,4,4,4,4,4,4,4,4,4,4,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[1,1,1,1,1,1,8,5,5,5,5,5,5,5,5,5,5,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[1,1,1,1,1,8,20,0,0,41,0,41,0,41,0,0,41,0,0,14,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,17,17,17],[1,1,1,1,8,20,0,0,0,41,0,41,0,53,0,0,41,0,0,0,0,0,0,0,10,17,17,12,4,4,4,4,4,4,4,4,22,1,1,1],[1,1,1,8,20,0,0,0,0,54,0,41,0,0,0,0,41,0,0,0,0,6,4,4,22,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],[1,1,1,3,0,0,0,0,0,0,0,41,0,0,0,0,41,0,0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,0,0,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],[1,1,1,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],[1,1,1,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],[1,1,1,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],[1,1,1,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]]
[[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,6,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,5,5,5,5,5,5,5,5,5,5,5,9,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66],[68,68,68,68,68,68,68,68,6,4,4,31,32,0,0,0,0,0,55,0,0,0,0,0,0,0,0,2,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66],[66,66,66,66,66,66,66,66,66,66,66,66,30,31,32,0,0,0,0,0,0,0,0,0,0,0,0,2,66,66,66,66,66,66,66,66,66,66,66,66,66,8,5,5,5,5,5,5,5,5,5,5,5,5,9,66,66,66,66,66],[66,66,66,66,66,66,66,66,66,66,66,66,66,66,30,4,4,4,4,4,7,0,0,0,0,0,0,2,66,66,66,66,66,66,66,66,66,66,66,66,66,3,0,0,0,0,0,0,0,0,0,0,0,0,2,66,66,66,66,66],[66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,3,14,0,0,0,0,0,2,66,66,66,66,66,66,66,66,66,66,66,66,66,3,0,0,0,0,0,0,0,0,0,0,0,0,2,66,66,66,66,66],[66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,3,0,14,0,0,0,0,19,5,5,5,5,5,5,5,5,5,5,5,5,5,20,0,0,0,0,0,0,0,0,0,0,0,0,2,66,66,66,66,66],[66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,3,0,0,14,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,66,66,66,66,66],[66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,3,0,0,0,14,0,0,0,0,55,0,0,0,0,55,0,0,0,0,55,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,66,66,66,66,66],[66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,66,66,66,66,66],[66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,3,0,0,0,0,0,6,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,22,66,66,66,66,66],[66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,8,5,5,5,5,20,0,0,0,0,6,22,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66],[66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,3,0,0,0,0,0,0,0,0,6,22,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66],[66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,3,0,0,55,0,0,0,0,6,22,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66],[66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,3,0,0,0,0,0,0,6,22,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66],[66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,21,4,4,4,4,4,4,22,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66],[66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66]]

View File

@ -5,11 +5,11 @@ Camera = {
}
function Camera:CenterAt(x,y,cx,cy)
self.pos.x = x-self.width/(2*game.scale)
self.pos.y = y-self.height/(2*game.scale)
cx = cx - self.width
cy = cy - self.height
self.pos.x = x-self.width/game.scale/2
self.pos.y = y-self.height/game.scale/2
if not (cx == nil or cy == nil) then
cx = cx - self.width
cy = cy - self.height
if self.pos.x > cx then self.pos.x = cx end
if self.pos.y > cy then self.pos.y = cy end
if self.pos.x < 0 then self.pos.x = 0 end

View File

@ -12,7 +12,8 @@ Arrow = Entity:New(x,y)
}
o.sprite_offset = {x = 13, y = 1}
o.stuck = false
o.illuminated = true
setmetatable(o, self)
self.__index = self
table.insert(LoadedEntities,o)
@ -53,5 +54,6 @@ function Arrow:DoPhysics()
self.pos.y = self.pos.y + self.vel.y / 5
self.vel.x = 0
self.vel.y = 0
self.illuminated = false
end
end

View File

@ -19,10 +19,11 @@ Kupo = Entity:New(x,y)
o.bow_frames = 6
o.bow_extraframes = 18
o.bow_aim_frames = 8
o.lightRange = o.range
o.hostile = false
o.lightRange = o.range/10
o.light = CreateLight(o.pos.x,o.pos.y,o.lightRange)
setmetatable(o, self)
self.__index = self
@ -37,9 +38,8 @@ function Kupo:Smart()
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)
self.draw_bow = false
if distance <= self.range then
self.draw_bow = true
if distance_x > 0 then
self.sprite_flip.x = 1
@ -48,55 +48,57 @@ function Kupo:Smart()
self.sprite_flip.x = -1
end
-- fix so it can rotate from 0 to 360
if math.deg(self.bow_rotation - angle) < 0 then
self.bow_rotation = self.bow_rotation + math.rad(360)
end
-- fix so it can rotate from 360 to 0
if math.deg(self.bow_rotation - angle) > 180 then
self.bow_rotation = self.bow_rotation - math.rad(360)
end
-- actual rotation
if self.bow_rotation < angle then
self.bow_rotation = self.bow_rotation + math.rad(2)
else
self.bow_rotation = self.bow_rotation - math.rad(2)
end
--set in place
if math.abs(math.deg(self.bow_rotation) - math.deg(angle)) < 2 then
self.bow_rotation = angle
end
-- holding tight dispersion -- also affets arrows
if self.bow_rotation == angle then
self.bow_rotation = self.bow_rotation + math.rad(math.random(math.abs(self.bow_frame-self.bow_aim_frames-self.bow_frames)/2))
end
-- AIMING AI
self.bow_subframe = self.bow_subframe + current_dt
if self.bow_subframe > self.bow_speed then
self.bow_subframe = self.bow_subframe - self.bow_speed
if self.bow_frame == 3 then
self.bow_aim_frame = self.bow_aim_frame + 1
if self.bow_aim_frame > self.bow_aim_frames then
self.bow_aim_frame = self.bow_aim_frame - self.bow_aim_frames
self.bow_frame = self.bow_frame + 1
Arrow:New(self.pos.x,self.pos.y,self.bow_rotation,15)
end
else
self.bow_frame = self.bow_frame + 1
if self.hostile == true then
self.draw_bow = true
-- fix so it can rotate from 0 to 360
if math.deg(self.bow_rotation - angle) < 0 then
self.bow_rotation = self.bow_rotation + math.rad(360)
end
if self.bow_frame > self.bow_frames + self.bow_extraframes then
self.bow_frame = self.bow_frame - self.bow_frames - self.bow_extraframes
-- fix so it can rotate from 360 to 0
if math.deg(self.bow_rotation - angle) > 180 then
self.bow_rotation = self.bow_rotation - math.rad(360)
end
-- actual rotation
if self.bow_rotation < angle then
self.bow_rotation = self.bow_rotation + math.rad(2)
else
self.bow_rotation = self.bow_rotation - math.rad(2)
end
--set in place
if math.abs(math.deg(self.bow_rotation) - math.deg(angle)) < 2 then
self.bow_rotation = angle
end
-- holding tight dispersion -- also affets arrows
if self.bow_rotation == angle then
self.bow_rotation = self.bow_rotation + math.rad(math.random(math.abs(self.bow_frame-self.bow_aim_frames-self.bow_frames)/2))
end
-- AIMING AI
self.bow_subframe = self.bow_subframe + current_dt
if self.bow_subframe > self.bow_speed then
self.bow_subframe = self.bow_subframe - self.bow_speed
if self.bow_frame == 3 then
self.bow_aim_frame = self.bow_aim_frame + 1
if self.bow_aim_frame > self.bow_aim_frames then
self.bow_aim_frame = self.bow_aim_frame - self.bow_aim_frames
self.bow_frame = self.bow_frame + 1
Arrow:New(self.pos.x,self.pos.y,self.bow_rotation,15)
end
else
self.bow_frame = self.bow_frame + 1
end
if self.bow_frame > self.bow_frames + self.bow_extraframes then
self.bow_frame = self.bow_frame - self.bow_frames - self.bow_extraframes
end
end
end
else
self.bow_frame = 6
self.draw_bow = true
-- rest bow animation
if distance_x > 0 then
if self.bow_rotation > math.rad(45) then

View File

@ -15,6 +15,7 @@ function Entity:New(x,y)
o.sprite_scale = {x = 1, y = 1}
o.sprite_rotation = math.rad(0)
o.sprite_flip = { x = 1, y = 1}
o.illuminated = false
setmetatable(o, self)
self.__index = self
return o
@ -113,7 +114,7 @@ function DrawAnimation(animation, x, y, rotate, sx, sy)
end
function Entity:Animate()
if game_paused ~= true then
if game_paused ~= true and self.anim.path ~= nil then
-- try to animate
self.anim.subframe = self.anim.subframe + current_dt

View File

@ -136,6 +136,14 @@ function TileGetDepth(tile_id)
end
end
function TileGetLight(tile_id)
for _, properties in ipairs(Tiles) do
if properties.id == tile_id then
return properties.light
end
end
end
function GridDisplay()
for i = 1, #LevelTiles do
for j = 1, #LevelTiles[i] do
@ -160,10 +168,19 @@ function TileCreateObjects()
if LevelTiles[i][j] ~= 0 then
local type = TileGetType(LevelTiles[i][j])
local light = TileGetLight(LevelTiles[i][j])
local base_x = tileProperties.scale * j * tileProperties.width + tileProperties.scale * (levelProperties.offset.x - tileProperties.height)
local base_y = tileProperties.scale * i * tileProperties.height + tileProperties.scale * (levelProperties.offset.y - tileProperties.height)
if light ~= 0 and light ~= nil then
CreateLight(
base_x + tileProperties.width/2 * tileProperties.scale,
base_y + tileProperties.height/2 * tileProperties.scale,
light
)
end
if type == "whole" then
local col = Collision:New(
base_x,

View File

@ -13,46 +13,67 @@ function CreateLight(x,y,range)
}
o.range = range
o.flicker = 0
o.dim = 0
table.insert(Lights,o)
return o
end
function SetDarkness()
love.graphics.setColor(0,0,0,1)
love.graphics.rectangle("fill",0,0,game.width,game.height)
end
function DoDarkness()
love.graphics.setColor(0,0,0)
love.graphics.setColor(0,0,0,0.3)
love.graphics.rectangle("fill",0,0,game.width,game.height)
end
function DoLights()
LightTimer = LightTimer + 1
if LightTimer >= 3 then
LightTimer = LightTimer - 3
for _, light in pairs(Lights) do
light.flicker = math.random(-1,1)
end
light.flicker = math.random(-2,2)
light.dim = (light.range+light.flicker)/5
end
end
love.graphics.setBlendMode("replace")
-- first, border
love.graphics.setColor(1,1,1)
for _, light in pairs(Lights) do
love.graphics.circle(
"fill",
--[[love.graphics.circle(
"fill",
light.pos.x - Camera.pos.x,
light.pos.y - Camera.pos.y,
light.range + light.flicker + 1
)
end
love.graphics.setColor(0,0,0,0)
-- then, light
for _, light in pairs(Lights) do
)]]
end
for _, enty in pairs(LoadedEntities) do
if enty.illuminated == true then
enty:Draw()
end
end
love.graphics.setColor(0,0,0,0.5)
for _, light in pairs(Lights) do
love.graphics.circle(
"fill",
"fill",
light.pos.x - Camera.pos.x,
light.pos.y - Camera.pos.y,
light.range + light.flicker
)
)
end
-- then, light
love.graphics.setColor(0,0,0,0)
for _, light in pairs(Lights) do
love.graphics.circle(
"fill",
light.pos.x - Camera.pos.x,
light.pos.y - Camera.pos.y,
light.range + light.flicker - light.dim
)
end
love.graphics.setBlendMode("alpha")
end
@ -62,4 +83,4 @@ end
function DrawDarkness()
love.graphics.draw(Canvas.Darkness, 0, 0, 0, 0.5, 0.5)
end
end

View File

@ -272,7 +272,8 @@ return {
{
id = 55,
type = "empty",
depth = "foreground"
depth = "foreground",
light = 60
},
{
id = 56,
@ -324,6 +325,21 @@ return {
type = "whole",
depth = "foreground"
},
{
id = 66,
type = "whole",
depth = "foreground"
},
{
id = 67,
type = "whole",
depth = "foreground"
},
{
id = 68,
type = "whole",
depth = "foreground"
},
{
id = 119,
type = "whole",

View File

@ -20,17 +20,20 @@ function love.load()
Canvas = {
Darkness = CreateDarkness()
}
love.graphics.setCanvas(Canvas.Darkness)
SetDarkness()
love.graphics.setCanvas()
Camera.width = game.width
Camera.height = game.height
levelList = {"level1","2","3","ewae","tileset"}
levelNum = 1
currLevel = levelList[levelNum]
LoadedEntities = {}
LevelLoadTiles()
main_Player = Player:New(0,20)
LoadedEntities = {}
table.insert(LoadedEntities,main_Player)
table.insert(LoadedEntities,Kupo:New(450,100))
table.insert(LoadedEntities,Kupo:New(250,150))
table.insert(LoadedEntities,Kupo:New(700,150))
table.insert(LoadedEntities,Kupo:New(800,150))
main_Player.sprite = love.graphics.newImage("assets/characters/nancy/idle1.png")
main_Player:LoadAnimation(animation.nancy.idle)
end
@ -47,16 +50,6 @@ function love.update(dt)
fps_count = fps_count + 1
current_dt = dt
-- saveproof to game resize
if game.width ~= love.graphics.getWidth() or game.height ~= love.graphics.getHeight() then
game.width = love.graphics.getWidth()
game.height = love.graphics.getHeight()
Camera.height = game.height
Camera.width = game.width
Canvas.Darkness:release()
Canvas.Darkness = CreateDarkness()
end
-- GAME STEP
if not do_pause then
SetCollisionFlags(main_Player)
@ -65,7 +58,7 @@ function love.update(dt)
enty:DoPhysics()
end
AnimateTiles()
Camera:CenterAt(main_Player.pos.x, main_Player.pos.y,LevelInfo.Width,LevelInfo.Height)
Camera:CenterAt(main_Player.pos.x, main_Player.pos.y)
--camera:ScreenAt(main_Player.pos.x, main_Player.pos.y,game.width,game.height)
end
end
@ -110,6 +103,20 @@ function love.keypressed(key)
end
function love.draw()
-- saveproof to game resize
if game.width ~= love.graphics.getWidth() or game.height ~= love.graphics.getHeight() then
game.width = love.graphics.getWidth()
game.height = love.graphics.getHeight()
Camera.height = game.height
Camera.width = game.width
Canvas.Darkness:release()
Canvas.Darkness = CreateDarkness()
love.graphics.setCanvas(Canvas.Darkness)
SetDarkness()
love.graphics.setCanvas()
end
-- GAME WORLD
love.graphics.scale(game.scale,game.scale)
love.graphics.setColor(1,1,1,1)
@ -123,7 +130,7 @@ function love.draw()
-- Save color
local pcr, pcg, pcb, pca = love.graphics.getColor()
love.graphics.setCanvas(Canvas.Darkness)
DoDarkness()
DoLights()
@ -133,11 +140,11 @@ function love.draw()
love.graphics.setColor(1,1,1,1)
love.graphics.setCanvas()
love.graphics.scale(1,1)
DrawDarkness()
DrawDarkness()
-- HUD
-- Scale control
textScale = 0.5
--debug
if debug then DebugUI() end
if debug_collision then DebugColisions() end