fix: another PNG CRC error
[poca-love.git] / background.lua
blob4a26a2e0cb6facc51f2588185281ab902843038c
1 --[[
2 This file is part of POCA - a puzzle game
4 POCA is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
9 This software is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>.
19 backgrounds = {
20 Apartment = {
21 color = {.1, .2, .3},
22 music = 'opening'
24 Block = {
25 color = {.3, .2, 0},
26 music = 'street'
28 City = {
29 color = {.2, .1, .2},
30 music = 'city'
32 Dig = {
33 color = {0, .3, 0},
34 music = 'graveyard'
36 Elevation = {
37 color = {.1, .3, .3},
38 music = 'windmills'
40 Faydom = {
41 color = {.6, .3, .3},
42 music = 'path'
44 Genie = {
45 color = {.6, .4, .3},
46 music = 'frula'
48 Hive = {
49 color = {.7, .6, .3},
50 music = 'amnesia'
52 Island = {
53 color = {.3, .6, .6},
54 music = 'sacred_ground'
56 Jail = {
57 color = {.3, .3, .3},
58 music = 'jail'
60 Knockout = {
61 color = {.3, .7, .5},
62 music = 'beta'
64 Lighthouse = {
65 color = {.3, .5, .5},
66 music = 'cliffs'
68 Monastery = {
69 color = {.1, 0, 0},
70 music = 'bells'
72 Narrow = {
73 color = {.4, .3, .2},
74 music = 'walk'
76 Overcharge = {
77 color = {.7, .1, .5},
78 music = 'papian'
80 Purple = {
81 color = {.6, .1, .6},
82 music = 'loop'
84 Quicksand = {
85 color = {.7, .6, .2},
86 music = 'shakes'
88 Remorse = {
89 color = {.1, .2, .6},
90 music = 'remorse'
92 Secrets = {
93 color = {0, 0, 0},
94 music = 'cave_of_secrets'
100 sounds = {}
103 function load_sounds()
104 for name, volume in pairs{
105 click = .3,
106 tone = .3,
107 teleport = .9,
108 open_gifts = 1,
109 turn = 1,
110 arrows = .3,
111 dead = .9,
112 backwards = .3,
113 pickup = .7,
114 } do
115 if not sounds[name] then
116 sounds[name] = love.audio.newSource('snd/' .. name .. '.wav', 'static')
118 sounds[name]:setVolume(volume * settings.sounds_volume)
123 function play_music(title, repeatable)
124 if not (title and settings.music) then return end
125 local filename = title
126 -- if title isn't in backgrounds, assume it's a filename
127 if backgrounds[title] then filename = backgrounds[title].music end
128 if not repeatable and current.played == filename then return end
129 current.played = filename
130 filename = 'snd/' .. (filename or title) .. '.it'
131 if not love.filesystem.getInfo(filename) then
132 print('Music not found: ' .. title)
133 return
135 if current.music then
136 current.music:stop()
137 current.music:release()
138 current.music = nil
140 current.music = love.audio.newSource(filename, 'stream')
141 current.music:setVolume(settings.music_volume)
142 current.music:play()
146 function play_sound(s)
147 if s == 'dead' and settings.vibrate then love.system.vibrate(.3) end
148 if not settings.sounds then return end
149 sounds[s]:stop()
150 sounds[s]:play()
154 function draw_background()
155 local b = current.background or
156 backgrounds[level_labels[game.currentlevel]].color or {0, 0, 0}
157 love.graphics.clear(b)