fix: another PNG CRC error
[poca-love.git] / trinkets.lua
blob96b8e6ef4bc8b2ba95f3a683a961f8d140d9c9b6
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 trinkets = {
20 ['1000points'] = {
21 name = '1000 Points',
22 bmp = love.graphics.newImage('gfx/trinkets/1000points.png'),
24 ['2000points'] = {
25 name = '2000 Points',
26 bmp = love.graphics.newImage('gfx/trinkets/2000points.png'),
27 description = 'Not bad.',
29 ['3000points'] = {
30 name = '3000 Points',
31 bmp = love.graphics.newImage('gfx/trinkets/3000points.png'),
32 description = 'Not one, not two, but three thousand points, found in Lighthouse.',
34 ['4000points'] = {
35 name = '4000 Points',
36 bmp = love.graphics.newImage('gfx/trinkets/4000points.png'),
37 description = 'Congratulations! These are all points in the game.',
39 beastfang = {
40 name = 'Beast Fang',
41 bmp = love.graphics.newImage('gfx/trinkets/beastfang.png'),
42 description = 'A fang that once belonged to an ancient beast, sent to museum, but unfortunately lost in transport.'
44 cigarettes = {
45 name = 'A Box of Cigarettes',
46 bmp = love.graphics.newImage('gfx/trinkets/cigarettes.png'),
47 description = 'A box of highly addictive cigarettes found in the City.',
49 casette = {
50 name = 'POCA Soundtrack',
51 bmp = love.graphics.newImage('gfx/trinkets/casette.png'),
52 onclick = function() change_screen('menu_casette') end
54 chocolate = {
55 name = 'Chocolate',
56 bmp = love.graphics.newImage('gfx/trinkets/chocolate.png'),
58 frame = {
59 name = 'Scintilating frame',
60 bmp = love.graphics.newImage('gfx/trinkets/frame.png'),
61 onclick = function() change_screen('menu_frame') end,
62 description = 'A display of some sort, not immediately useful.'
64 gameglitch = {
65 name = 'Game Glitch',
66 bmp = love.graphics.newImage('gfx/trinkets/gameglitch.png'),
67 onclick = function() gg:main() end,
69 gpl3 = {
70 name = 'A copy of the GNU GPL',
71 bmp = love.graphics.newImage('gfx/trinkets/gpl3.png'),
72 onclick = function() license:main() end
74 hints_book = {
75 name = 'Book of Hints',
76 bmp = love.graphics.newImage('gfx/trinkets/hints_book.png'),
77 description = 'This book is badly damaged and can only be opened a few times. Please use sparingly!',
78 onclick = function() change_screen('menu_hints') end
80 marbles = {
81 name = 'Marbles',
82 bmp = love.graphics.newImage('gfx/trinkets/marbles.png'),
83 description = 'Three glass marbles',
85 map = {
86 name = 'Map',
87 bmp = love.graphics.newImage('gfx/map.png'),
88 onclick = function() change_screen('menu_map') end
90 matches = {
91 name = 'A Matchbook',
92 bmp = love.graphics.newImage('gfx/trinkets/matches.png'),
93 description = 'Matches are used to light cigarettes or illuminate dark places.',
94 onclick = function () change_screen('menu_matches') end,
96 pencil = {
97 name = '3-color pencil',
98 bmp = love.graphics.newImage('gfx/trinkets/pencil.png'),
99 description = 'A huge pencil, that can add color to the playfield, should it become too dull',
100 onclick = function()
101 current.painting = not current.painting
102 playfield.paint_mode = nil
103 change_screen('playfield')
104 end,
106 photos = {
107 name = 'Photo Booth Photos',
108 bmp = love.graphics.newImage('gfx/trinkets/photos.png'),
109 description = 'Photos of me & my dad.',
111 pistol = {
112 name = 'Pistol',
113 bmp = love.graphics.newImage('gfx/trinkets/pistol.png'),
114 description = 'A dangerous object, not very useful in this game'
116 pocketexplosions = {
117 name = 'Pocket explosions',
118 bmp = love.graphics.newImage('gfx/trinkets/pocketexplosions.png'),
119 onclick = function() pe:main() end,
120 description = 'A hard game',
122 rabbit = {
123 name = 'Snow Dome with Rabbit',
124 bmp = love.graphics.newImage('gfx/trinkets/rabbit.png'),
125 description = 'A rabbit is underneath a tiny dome. When you shake it, flakes unsettle and slowly fall, like snow.'
127 rainbowring = {
128 name = 'Rainbow Ring',
129 bmp = love.graphics.newImage('gfx/trinkets/rainbowring.png'),
130 onclick = function() rr:main() end,
132 raregem = {
133 name = 'Rare Gem',
134 bmp = love.graphics.newImage('gfx/trinkets/raregem.png'),
136 robotoy = {
137 name = 'RoboToy',
138 bmp = love.graphics.newImage('gfx/trinkets/robotoy.png'),
139 description = 'A toy that says: "We are the space robots. We are here to protect you."'
141 rubenspyramid = {
142 name = 'Ruben\'s Pyramid',
143 bmp = love.graphics.newImage('gfx/trinkets/rubenspyramid.png'),
144 onclick = function() rp:main() end,
146 tinyheart = {
147 name = 'Tiny Heart',
148 bmp = love.graphics.newImage('gfx/trinkets/tinyheart.png'),
150 teleport_ul = {
151 name = 'Pocket Teleport',
152 bmp = love.graphics.newImage('gfx/trinkets/teleport_ul.png'),
153 onclick = function()
154 change_screen('playfield')
155 current.phase = 'play'
156 secrets_arrow(-1, -1)
157 next_phase()
158 end,
160 teleport_dl = {
161 name = 'Pocket Teleport',
162 bmp = love.graphics.newImage('gfx/trinkets/teleport_dl.png'),
163 onclick = function()
164 change_screen('playfield')
165 current.phase = 'play'
166 secrets_arrow(-1, 1)
167 next_phase()
168 end,
170 teleport_ur = {
171 name = 'Pocket Teleport',
172 bmp = love.graphics.newImage('gfx/trinkets/teleport_ur.png'),
173 onclick = function()
174 change_screen('playfield')
175 current.phase = 'play'
176 secrets_arrow(1, -1)
177 next_phase()
178 end,
180 titmagazine = {
181 name = 'Tit Magazine',
182 bmp = love.graphics.newImage('gfx/trinkets/titmagazine.png'),
183 description = 'A magazine full of interesting pictures',
185 toyhorse = {
186 name = 'Toy Horse',
187 bmp = love.graphics.newImage('gfx/trinkets/toyhorse.png'),
189 woodenflower = {
190 name = 'Wooden Flower in a Vase',
191 bmp = love.graphics.newImage('gfx/trinkets/woodenflower.png'),
193 autodescribe = function(self)
194 for k, e in pairs(self) do
195 if (type(e) == 'table') and (not e.description) and (not e.onclick) then
196 for l = 1, #levels do
197 if levels[l].trinket == k then
198 self[k].description = self[k].name ..
199 ', found in ' .. level_labels[l] .. '.'
200 break
205 end,
208 add_scale(trinkets)
209 trinkets:autodescribe()
212 function select_trinket(d)
213 if #game.trinkets > 0 then
214 return (current.trinket - 1 + d) % #game.trinkets + 1
215 else
216 return false
221 function get_trinket(trinket_name)
222 if not trinket_name then return end
223 play_sound('pickup')
224 local place = #game.trinkets + 1
225 if trinket_name == '1000points' then -- if new 1000points are picked up
226 place = place - 1
227 if game.trinkets[#game.trinkets] == '1000points' then
228 trinket_name = '2000points'
229 elseif game.trinkets[#game.trinkets] == '2000points' then
230 trinket_name = '3000points'
231 elseif game.trinkets[#game.trinkets] == '3000points' then
232 trinket_name = '4000points'
233 else -- first 1000 points
234 place = place + 1
237 game.trinkets[place] = trinket_name
238 game.former_trinkets[#game.former_trinkets + 1] = trinket_name
239 current.trinket = place
243 -- shifts back all trinkets after the replaced one
244 function lose_trinket(trinket_name)
245 print('lose_trinket(' .. trinket_name .. ')')
246 if not has_trinket(trinket_name) then return end
247 local replace = false
248 for a = 1, #game.trinkets do
249 if game.trinkets[a] == trinket_name then
250 replace = true
251 elseif replace then
252 game.trinkets[a - 1] = game.trinkets[a]
255 game.trinkets[#game.trinkets] = nil
259 function had_trinket(t)
260 for _, gt in ipairs(game.former_trinkets) do
261 if gt == t then return true end
263 return false
267 function has_trinket(t)
268 for _, gt in ipairs(game.trinkets) do
269 if gt == t then return true end
271 return false
275 function click_corpse()
276 local content = 'You search the remains of a dead explorer and find '
277 local s = game.searched_corpses[game.currentlevel]
278 game.searched_corpses[game.currentlevel] = true
279 if not (s or had_trinket('map')) then
280 get_trinket('map')
281 content = content .. 'a map.'
282 elseif not (s or had_trinket('rubenspyramid')) then
283 if not has_trinket('hints_book') then
284 get_trinket('hints_book')
285 content = content .. 'a Book of Hints and '
287 get_trinket('rubenspyramid')
288 content = content .. 'a strange puzzle.'
289 else
290 content = content .. 'nothing special.'
292 return content