-
Notifications
You must be signed in to change notification settings - Fork 1
/
game.lua
75 lines (60 loc) · 1.6 KB
/
game.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
local Scene = require "world.scene"
local Dialog = require "dialog"
local GameState = require "gamestate"
local Intro = require "world.intro"
local game = {shading = false, is_paused = false}
local vision_opts = require "torch"
_G.Say = function(dialog, props)
Moan.speak({dialog[1], YELLOW}, {dialog[2]}, props)
end
_G.RSay = function(dialog, props)
Moan.speak({dialog[1], L_RED}, {dialog[2]}, props)
end
_G.Speak = Moan.speak
function game.load()
local house = require "world.house"
house.load()
Scene.load()
game.shading = false
game.current_scene = Intro
GameState.game = game
end
function game.start()
game.shading = true
game.current_scene = Scene()
end
function game.draw()
game.current_scene:draw()
end
function game.ui_layer()
game.current_scene:ui_layer()
end
function game.update(dt)
Dialog:update()
game.current_scene:update(dt)
vision_opts.radius = vision_opts.radius + vision_opts.dr
if vision_opts.radius > vision_opts.max or vision_opts.radius < vision_opts.min then
vision_opts.dr = vision_opts.dr * -1
end
end
function game.shade(shader)
local player_pos = game.current_scene:player_screen_coords()
shader:send("los_center", {player_pos.x, player_pos.y})
shader:send("los_radius", vision_opts.radius)
shader:send("los_on", vision_opts.on)
end
function love.keypressed(key)
game.current_scene:keypressed(key)
if key == "q" and GameState.events.torch_found then
vision_opts:toggle()
end
end
function love.keyreleased(key)
if game.current_scene.keyreleased then
game.current_scene:keyreleased(key)
end
end
function game.set_scene(s)
game.current_scene = s
end
return game