-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.lua
executable file
·109 lines (81 loc) · 3 KB
/
main.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
-- main.lua
-- Example for using luven.lua
Luven = require "luven/luven"
Inspect = require "dev/inspect"
Profi = require "dev/profi"
local zoom = 2
local image = nil
local moveSpeed = 150
local lightId = 0
local lightId2 = 0
local power = 0.25
function love.load()
love.graphics.setDefaultFilter("nearest", "nearest")
-- Profi:start()
image = love.graphics.newImage("Background.png")
Luven.init()
Luven.setAmbientLightColor({ 0.1, 0.1, 0.1 })
Luven.camera:init(love.graphics.getWidth() / 2, love.graphics.getHeight() / 2)
Luven.camera:setScale(zoom)
lightId = Luven.addFlickeringLight(600, 400, { min = { 0.8, 0.0, 0.8, 0.8 }, max = { 1.0, 0.0, 1.0, 1.0 } }, { min = 0.25, max = 0.27 }, { min = 0.12, max = 0.2 })
lightId2 = Luven.addFlickeringLight(700, 400, { min = { 0.8, 0.0, 0.8, 0.8 }, max = { 1.0, 0.0, 1.0, 1.0 } }, { min = 0.25, max = 0.7 }, { min = 0.12, max = 0.2 }, Luven.lightShapes.cone)
Luven.addNormalLight(700, 500, { 0.9, 1, 0 }, 1, Luven.lightShapes.cone, 0)
end -- function
function love.update(dt)
Luven.update(dt)
local vx, vy = 0, 0
if (love.keyboard.isDown("w")) then
vy = vy - moveSpeed * dt
end -- if
if (love.keyboard.isDown("s")) then
vy = vy + moveSpeed * dt
end -- if
if (love.keyboard.isDown("a")) then
vx = vx - moveSpeed * dt
end -- if
if (love.keyboard.isDown("d")) then
vx = vx + moveSpeed * dt
end -- if
Luven.camera:move(vx, vy)
Luven.setLightRotation(lightId2, Luven.getLightRotation(lightId2) + 1 * dt)
end -- function
function love.keypressed(key)
if (key == "space") then
Luven.camera:setShake(0.7, 5.5)
end -- if
if (key == "m") then
power = power + 0.05
Luven.setLightPower(lightId, power)
end -- if
if (key == "n") then
power = power - 0.05
Luven.setLightPower(lightId, power)
end -- if
if (key == "l") then
lightId = Luven.addNormalLight(Luven.camera.x, Luven.camera.y, { 1.0, 1.0 , 1.0 }, 0.05)
end -- if
if (key == "z") then
Luven.addFlashingLight(Luven.camera.x, Luven.camera.y, { 1.0, 0.0, 0.0 }, 1, 3)
end
if (key == "f") then
--Luven.addFlashingLight(Luven.camera.x, Luven.camera.y, { 1.0, 0.0, 0.0 }, 1, 3)
Luven.camera:setFade(3, { 1, 0, 0, 1 }, function() Luven.camera:setFade(3, { 0, 0, 0, 0 }) end)
end -- if
if (key == "g") then
--Luven.addFlashingLight(Luven.camera.x, Luven.camera.y, { 1.0, 0.0, 0.0 }, 1, 3)
Luven.camera:setFade(3, { 0, 0, 0, 0 })
end -- if
end -- function
function love.draw()
Luven.drawBegin()
love.graphics.draw(image, 0, 0, 0, 0.5, 0.5)
Luven.drawEnd()
love.graphics.print("Current FPS: " .. tostring(love.timer.getFPS()), 10, 10)
love.graphics.print("Number of lights: " .. tostring(Luven.getLightCount()), 10, 30)
Luven.camera:draw()
end -- function
function love.quit()
Luven.dispose()
-- Profi:stop()
-- Profi:writeReport("LuvenProfile.txt")
end -- function