fix: another PNG CRC error
[poca-love.git] / images.lua
blob3ef4fb5096b3887d11802652f2b480f1a456f665
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/>.
18 -- retro style
19 love.graphics.setDefaultFilter('linear', 'nearest')
21 images = {
22 ['0'] = { -- tile
23 color = {.3, .3, .3},
24 shape = 'floortile',
26 ['1'] = { -- greenx
27 color = {0, 1, 0},
28 center = 'plain',
30 ['2'] = { -- green+
31 color = {0, 1, 0},
32 center = 'plain',
34 ['3'] = { -- yellowx
35 color = {1, 1, 0},
36 center = 'plain',
38 ['4'] = { -- yellow+
39 color = {1, 1, 0},
40 center = 'plain',
42 ['5'] = { -- redx
43 color = {1, 0, 0},
44 center = 'dot',
46 ['6'] = { -- red+
47 color = {1, 0, 0},
48 center = 'dot',
50 ['7'] = { -- regenex
51 color = {0, 1, 0},
52 center = 'bmp',
53 bmp = love.graphics.newImage('gfx/ankh.png'),
55 ['8'] = { -- regene+
56 color = {0, 1, 0},
57 center = 'bmp',
58 bmp = love.graphics.newImage('gfx/ankh.png'),
60 ['9'] = { -- regenex - pressed
61 shape = 'floortile',
63 A = { -- regene+ - pressed
64 shape = 'floortile',
66 C = { -- hint
67 shape = 'sign',
69 D = { -- blackload
70 shape = 'hole',
72 H = { -- loadredx
73 color = {1, 0, 0},
74 center = 'dot',
76 I = { -- loadred+
77 color = {1, 0, 0},
78 center = 'dot',
80 J = { -- box
81 color = {.3, .3, .3},
82 shape = 'gift',
84 K = { -- genie box
85 color = {1, 0, 0},
86 shape = 'gift',
88 N = { -- wise man
89 shape = 'bmp',
90 bmp = love.graphics.newImage('gfx/wiseman.png'),
92 O = { -- pill
93 shape = 'bmp',
94 bmp = love.graphics.newImage('gfx/pill.png'),
96 P = { -- purple+
97 color = {.6, 0, .6},
98 center = 'purple',
100 Q = { -- purplex
101 color = {.6, 0, .6},
102 center = 'purple',
104 R = { -- killed
105 shape = 'bmp',
106 bmp = love.graphics.newImage('gfx/dead.png'),
108 V = { -- arrow left
109 shape = 'left',
111 W = { -- arrow up
112 shape = 'up',
114 X = { -- arrow right
115 shape = 'right',
117 Y = { -- arrow down
118 shape = 'down',
120 Z = { -- trinket
121 shape = 'trinket',
123 a = { -- green+ - memory
124 memory = true,
126 b = { -- greenx - memory
127 memory = true,
129 c = { -- loadred+ - memory
130 memory = true,
132 d = { -- loadredx - memory
133 memory = true,
135 e = { -- red+ - memory
136 memory = true,
138 f = { -- redx - memory
139 memory = true,
141 g = { -- regene+ - pressed - memory
142 -- doesn't render, but unused
143 memory = true,
145 h = { -- regenex - memory
146 memory = true,
148 i = { -- regenex - pressed - memory
149 -- doesn't render, but unused
150 memory = true,
152 j = { -- yellow+ - memory
153 memory = true,
155 k = { -- yellowx - memory
156 memory = true,
158 l = { -- regene+ - memory
159 memory = true,
161 m = { -- purple+ - memory
162 memory = true,
164 n = { -- purplex - memory
165 memory = true,
167 floor_regene_x = {
168 bmp = love.graphics.newImage('gfx/floor_regene_x.png'),
170 floor_regene_plus = {
171 bmp = love.graphics.newImage('gfx/floor_regene_plus.png'),
173 cursor = {
174 shape = 'cursor',
175 color = {.6, .6, 1},
176 width = 1,
178 cursor_wide = {
179 shape = 'cursor',
180 color = {.6, .6, 1},
181 width = 2,
183 pencil_r = {
184 shape = 'bmp',
185 bmp = love.graphics.newImage('gfx/pencil_r.png'),
187 pencil_g = {
188 shape = 'bmp',
189 bmp = love.graphics.newImage('gfx/pencil_g.png'),
191 pencil_y = {
192 shape = 'bmp',
193 bmp = love.graphics.newImage('gfx/pencil_y.png'),
195 dark_object = {
196 shape = 'bmp',
197 bmp = love.graphics.newImage('gfx/object.png'),
199 po = { -- title
200 shape = 'bmp',
201 bmp = love.graphics.newImage('gfx/po.png'),
203 ca = { -- title
204 shape = 'bmp',
205 bmp = love.graphics.newImage('gfx/ca.png'),
207 version = { -- title
208 shape = 'bmp',
209 bmp = love.graphics.newImage('gfx/version.png'),
211 stop = { -- casette
212 shape = 'bmp',
213 bmp = love.graphics.newImage('gfx/stop.png'),
214 scale = 150,
216 play = { -- casette
217 shape = 'bmp',
218 bmp = love.graphics.newImage('gfx/play.png'),
220 ffwd = { -- casette
221 shape = 'bmp',
222 bmp = love.graphics.newImage('gfx/ffwd.png'),
224 rewind = { -- casette
225 shape = 'bmp',
226 bmp = love.graphics.newImage('gfx/rewind.png'),
228 eject = { -- casette
229 shape = 'bmp',
230 bmp = love.graphics.newImage('gfx/eject.png'),
232 loop_1 = { -- casette
233 shape = 'bmp',
234 bmp = love.graphics.newImage('gfx/loop-1.png'),
236 loop_all = { -- casette
237 shape = 'bmp',
238 bmp = love.graphics.newImage('gfx/loop-all.png'),
240 loop_none = { -- casette
241 shape = 'bmp',
242 bmp = love.graphics.newImage('gfx/loop-none.png'),
244 cw = { -- rainbow ring, restart
245 shape = 'bmp',
246 bmp = love.graphics.newImage('gfx/cw.png'),
250 function add_scale(t)
251 for k, v in pairs(t) do if type(v) == 'table' and v.bmp then
252 -- determine correct scale and offset for bitmaps
253 local sizex, sizey = v.bmp:getWidth(), v.bmp:getHeight()
254 v.scale = v.scale or math.max(sizex, sizey)
255 v.offsetx = v.offsetx or (1 - sizex / v.scale) / 2
256 v.offsety = v.offsety or (1 - sizey / v.scale) / 2
257 end end
260 add_scale(images)
263 function draw_floor(x, y, stepped, sleep, shape, scale)
264 love.graphics.push()
265 love.graphics.scale(screen.tilesize)
266 love.graphics.translate(x, y)
267 if scale then love.graphics.scale(scale) end
268 love.graphics.setColor(images['0'].color, 1)
269 love.graphics.rectangle('fill', -.5,-.5, 1,1)
270 love.graphics.setColor(1,1,1, .4)
271 if stepped then
272 love.graphics.polygon('fill', .5,-.5, .5,.5, -.5,.5)
273 else
274 love.graphics.polygon('fill', -.5,-.5, .5,-.5, -.5,.5)
276 love.graphics.setColor(0,0,0, .4)
277 if stepped then
278 love.graphics.polygon('fill', -.5,-.5, .5,-.5, .5,.5)
279 else
280 love.graphics.polygon('fill', -.5,-.5, .5,.5, -.5,.5)
282 love.graphics.setColor(images['0'].color, 1)
283 love.graphics.rectangle('fill', -.45,-.45, .9,.9)
284 if not current.symbolic and sleep then
285 love.graphics.setColor(1,1,1, 1)
286 local img
287 if shape == '+' then img = images.floor_regene_plus else img = images.floor_regene_x end
288 love.graphics.draw(img.bmp, img.offsetx - .5, img.offsety - .5, 0, 1 / img.scale, 1 / img.scale)
290 if shape == 'hole' then
291 love.graphics.setColor(0,0,0, 1)
292 love.graphics.circle('fill', 0, 0, .3)
293 love.graphics.setColor(1,1,1, 1)
295 love.graphics.pop()
299 function draw_symbolic_direction(shape, used)
300 if used then
301 love.graphics.setColor(1,1,1, 1)
302 else
303 love.graphics.setColor(0,0,0, 1)
305 if shape == 'left' then
306 love.graphics.line(.5,0, -.5,0)
307 love.graphics.line(0,-.5, -.5,0, 0,.5)
308 elseif shape == 'right' then
309 love.graphics.line(-.5,0, .5,0)
310 love.graphics.line(0,-.5, .5,0, 0,.5)
311 elseif shape == 'up' then
312 love.graphics.line(0,.5, 0,-.5)
313 love.graphics.line(-.5,0, 0,-.5, .5,0)
314 elseif shape == 'down' then
315 love.graphics.line(0,-.5, 0,.5)
316 love.graphics.line(-.5,0, 0,.5, .5,0)
318 love.graphics.setColor(1,1,1, 1)
322 function draw_image(pftile, x, y, phase, scale, symbolic, symbolic_colored)
323 if not phase then phase = 0 end
324 function arrow(color, angle, distance, base)
325 base = ((base or 0) + 1) / 10
326 if angle % (math.pi / 2) > .1 then
327 distance = distance * math.sqrt(2)
328 -- important when arrows are flying away
329 -- initial distance is 0
331 local shaft = .5
332 if symbolic then
333 shaft = shaft / math.cos((angle + math.pi/4) % (math.pi/2) - math.pi/4)
335 distance = distance + shaft
336 local ox, oy = math.sin(angle) * (distance - shaft), math.cos(angle) * (distance - shaft)
337 local ex, ey = math.sin(angle) * distance, math.cos(angle) * distance
338 if not symbolic then
339 love.graphics.setColor(color)
340 love.graphics.polygon('fill', ex, ey,
341 ox + math.sin(angle + math.pi / 2) * base, oy + math.cos(angle + math.pi / 2) * base,
342 ox - math.sin(angle + math.pi / 2) * base, oy - math.cos(angle + math.pi / 2) * base
344 else
345 if not symbolic_colored then love.graphics.setColor(0,0,0, 1) end
346 love.graphics.line(ox, oy, ex, ey)
350 if not pftile.name then return end
351 if images[pftile.name].memory then
352 draw_image(pftile.memory, x, y, phase, (scale or 1) * .5)
353 return
355 love.graphics.push()
356 love.graphics.setLineWidth(.01)
357 love.graphics.scale(screen.tilesize)
358 love.graphics.translate(x, y)
359 if scale then love.graphics.scale(scale) end
360 love.graphics.push()
361 local function gifts_aperture()
362 local ph = playfield.giftsphase
363 love.graphics.rectangle('fill', -.5 * ph, -.5 * ph, 1 * ph, 1 * ph)
365 if not symbolic then
366 if pftile.ingift then -- draw gift surface without aperture
367 love.graphics.stencil(gifts_aperture, 'replace', 1)
368 love.graphics.setStencilTest('less', 1)
370 if pftile.ingift or images[pftile.name].shape == 'gift' then
371 if pftile.ingift == 'devil' or pftile.name == 'K' then
372 love.graphics.setColor(images.K.color, 1)
373 else
374 love.graphics.setColor(images.J.color, 1)
376 love.graphics.rectangle('fill', -.5, -.5, 1, 1)
377 love.graphics.setColor(1,1,1, .4)
378 love.graphics.polygon('fill', -.50,-.50, .50,-.50, -.50,.50)
379 love.graphics.setColor(0,0,0, .4)
380 love.graphics.polygon('fill', -.50,-.50, .50,.50, -.50,.50)
382 if pftile.ingift then -- invert stencil to draw gift contents
383 love.graphics.setStencilTest('gequal', 1)
385 else -- symbolic
386 if images[pftile.name].shape == 'gift' then
387 love.graphics.setColor(0,0,0, 1)
388 love.graphics.line(-.5,0, 0,-.5, .5,0, 0,.5, -.5,0)
391 if images[pftile.name].color then
392 love.graphics.setColor(images[pftile.name].color, 1)
393 else
394 love.graphics.setColor(1,1,1, 1)
396 if pftile.kind == 'regene' then
397 for a = 1, 8 do if pftile.arrows[a] then
398 arrow(pftile.color or images[pftile.name].color, math.pi / 4 * (a + 1) , pftile.arrows[a], phase) --!!
399 end end
400 elseif pftile.arrows then
401 for a = 1, 8 do if pftile.arrows[a] then
402 arrow(pftile.color or images[pftile.name].color, math.pi / 4 * (a + 1 + phase) , pftile.arrows[a], nil)
403 end end
405 if images[pftile.name].shape == 'sign' then
406 love.graphics.setColor(.8,.8,.8, 1)
407 if os.time() % 2 == 0 then -- moving arrow
408 love.graphics.polygon('fill', -.06, -.25, 0, -.39, .06, -.25)
409 love.graphics.rectangle('fill', -.02, -.25, .04, .15)
410 else
411 love.graphics.polygon('fill', -.06, -.27, 0, -.41, .06, -.27)
412 love.graphics.rectangle('fill', -.02, -.27, .04, .15)
414 love.graphics.printf(levels[game.currentlevel].sign,
415 -.5, -.05, screen.tilesize, 'center', nil, 1 / screen.tilesize
418 if images[pftile.name].shape == 'bmp' then
419 love.graphics.setColor(1,1,1, 1)
420 love.graphics.draw(images[pftile.name].bmp,
421 images[pftile.name].offsetx - .5, images[pftile.name].offsety - .5,
422 0, 1 / images[pftile.name].scale, 1 / images[pftile.name].scale
425 if images[pftile.name].shape == 'hole' then
426 -- actual hole drawn in draw_floor()
427 love.graphics.setColor(1,1,1, 1)
428 if screen.defaultfont then
429 love.graphics.print(pretty_name(playfield.skiplevel, true),
430 -.11, -.11,
431 nil, 1 / screen.tilesize
435 if images[pftile.name].shape == 'trinket' then
436 local trinket = levels[game.currentlevel].trinket
437 local t
438 if symbolic then t = images.dark_object else t = trinkets[trinket] end
439 love.graphics.setColor(1,1,1, 1)
440 love.graphics.draw(t.bmp,
441 t.offsetx -.50, t.offsety -.50,
442 0, 1 / t.scale, 1 / t.scale
445 if images[pftile.name].shape == 'cursor' then
446 local w = images[pftile.name].width
447 local r, g, b, a = love.graphics.getColor()
448 love.graphics.setColor(r, g, b, .1)
449 love.graphics.rectangle('fill', -.5, -.5, w, 1)
450 love.graphics.setColor(r, g, b, .8)
451 love.graphics.rectangle('line', -.5, -.5, w, 1)
452 love.graphics.rectangle('line', -.4, -.4, w - .2, .8)
454 if symbolic then
455 draw_symbolic_direction(images[pftile.name].shape, pftile.used)
456 if pftile.contains and pftile.used then
457 draw_symbolic_direction(images[pftile.contains.name].shape, pftile.used)
460 love.graphics.pop()
461 if not symbolic and images[pftile.name].center then
462 --center == 'plain'
463 love.graphics.setColor(.5,.5,.5, 1)
464 if pftile.devil then love.graphics.setColor(.9,.3,.3, 1) end
465 love.graphics.rectangle('fill', -.15,-.15, .3,.3)
466 if pftile.center == 'dot' or images[pftile.name].center == 'dot' then
467 love.graphics.setColor(.1,.1,.1, 1)
468 love.graphics.circle('fill', 0,0, .1)
470 if images[pftile.name].center == 'purple' then
471 love.graphics.setColor(.1,.1,.1, 1)
472 if current.temppurple then
473 love.graphics.rectangle('fill', -.05,-.05, .1, .1)
474 else
475 love.graphics.rectangle('line', -.05,-.05, .1, .1)
478 if images[pftile.name].center == 'bmp' then
479 love.graphics.setColor(1,1,1, 1)
480 love.graphics.draw(images[pftile.name].bmp, images[pftile.name].offsetx -.50, images[pftile.name].offsety -.50, 0, 1/images[pftile.name].scale, 1/images[pftile.name].scale)
483 if pftile.ingift and not symbolic then -- darken gifts content
484 love.graphics.setColor(0,0,0, .9 - playfield.giftsphase)
485 gifts_aperture()
487 love.graphics.setStencilTest()
488 love.graphics.pop()
489 love.graphics.setColor(1, 1, 1, 1)
490 -- small images in loadred
491 if pftile.name ~= 'R' and pftile.arrowgift then
492 if pftile.arrowgift.shape == 'hole' then
493 -- grow temporary hole before drawing it on the bottom layer
494 draw_floor(x, y, false, false, 'hole',
495 (pftile.arrowgiftphase or .4) * (scale or 1)
498 draw_image(pftile.arrowgift, x, y, 0, pftile.arrowgiftphase or (scale or 1) * .4)
503 function draw_initial_playfield()
504 -- layer 1: background
505 inplayfield(function (x, y, p)
506 draw_floor(x - .5, y - .5, false, p.sleep, p.shape)
507 end)
508 if game.shuffled then -- draw wise man bg
509 love.graphics.setBlendMode('screen')
510 draw_image({name = 'N'}, 2, 2, nil, 4)
511 love.graphics.setBlendMode('alpha')
513 -- layer 2: all images and arrows
514 inplayfield(function (x, y, p)
515 local q = get_initial_tile(game.currentlevel, x, y)
516 if q.name ~= '0' or q.shape or q.ingift then
517 draw_image(q, x - .5, y - .5, q.phase, nil, current.symbolic)
519 end)
523 function draw_playfield()
524 local selected_playfield = playfield
525 -- layer 1: background
526 if not (big_playfield.selectedx and level_labels[game.currentlevel] == 'Secrets') then
527 inplayfield(function (x, y, p)
528 local stepped = small_playfield.clickedx == x and small_playfield.clickedy == y
529 draw_floor(x - .5, y - .5, stepped, p.sleep, p.shape)
530 end)
531 if game.shuffled then -- draw wise man bg
532 love.graphics.setBlendMode('screen')
533 draw_image({name = 'N'}, 2, 2, nil, 4)
534 love.graphics.setBlendMode('alpha')
536 else
537 local stepped = big_playfield.clickedx == big_playfield.selectedx and big_playfield.clickedy == big_playfield.selectedy
538 local bgtile = big_playfield[big_playfield.selectedx][big_playfield.selectedy]
539 draw_floor(2, 2, stepped, nil, nil, 4)
540 draw_image(bgtile, 2, 2, nil, 4)
542 playfield = small_playfield
543 -- layer 2: all images and arrows
544 inplayfield(function (x, y, p)
545 if p.name ~= '0' or p.shape or p.ingift then
546 draw_image(p, x - .5, y - .5, p.phase, nil, current.symbolic)
548 end)
549 playfield = selected_playfield
550 -- layer 3: dead player
551 if current.showkill and playfield.clickedx then
552 draw_image(recognizeink('R'), playfield.clickedx - .5, playfield.clickedy - .5)
554 playfield = selected_playfield
558 function draw_fade()
559 -- covers progressively bigger area of the playfield
560 -- each time, stencil value is increased by 1
561 love.graphics.push()
562 love.graphics.translate(screen.playfieldx, screen.playfieldy)
563 love.graphics.scale(screen.tilesize)
564 local order = {0, 1, 2, 3, 7, 11, 15, 14, 13, 12, 8, 4, 5, 6, 10, 9 }
565 for a = 1, 16 do for b = 1, a do
566 local x = order[b] % 4
567 local y = math.floor(order[b] / 4)
568 love.graphics.rectangle('fill', x, y, 1, 1)
569 end end
570 love.graphics.pop()
574 -- draw spots of paint made when using pencil or matches
575 function draw_paint()
576 if not level_colors then return end
577 love.graphics.push()
578 love.graphics.translate(screen.playfieldx, screen.playfieldy)
579 love.graphics.scale(screen.tilesize)
580 love.graphics.draw(level_colors)
581 love.graphics.pop()
585 function draw_shuffled()
586 love.graphics.push()
587 inplayfield(function(x, y, p)
588 love.graphics.draw(screen.pfcanvas, screen.pfquads[x][y],
589 screen.playfieldx + (game.shuffled[x][y].x - 1) * screen.tilesize,
590 screen.playfieldy + (game.shuffled[x][y].y - 1) * screen.tilesize
592 end)
593 love.graphics.pop()
597 function draw_restart_button(p)
598 if p < .7 then return end
599 love.graphics.push()
600 love.graphics.translate(
601 screen.playfieldx + screen.playfieldsize / 2,
602 screen.playfieldy + screen.playfieldsize / 2
604 local size = (p - .7) * 3.33
605 love.graphics.setColor(.6, .6, .6, .5)
606 love.graphics.polygon('fill',
607 0, screen.tilesize * size / 2,
608 - screen.tilesize * size / 2, 0,
609 0, - screen.tilesize * size / 2,
610 screen.tilesize * size / 2, 0
612 draw_image({name = 'cw'}, 0, 0, nil, .55 * size)
613 love.graphics.setColor(1, 1, 1)
614 love.graphics.pop()
618 function draw_foreground()
619 if game.shuffled then
620 draw_shuffled()
621 else
622 -- draw straight
623 if playfield.fade_phase then
624 local phase = 16 - playfield.fade_phase
625 love.graphics.stencil(draw_fade, 'increment')
626 -- reveals more or less of the underlying playfield
627 -- according to pre-drawn stencil image
628 love.graphics.setStencilTest('less', phase)
630 if playfield.afterdeath_phase then
631 love.graphics.setShader(hatch)
633 love.graphics.draw(screen.pfcanvas, screen.playfieldx, screen.playfieldy)
634 love.graphics.setShader()
635 if playfield.afterdeath_phase then
636 draw_restart_button(playfield.afterdeath_phase)
639 draw_paint()
640 -- cursor
641 if small_playfield.selectedx then
642 if (small_playfield.selectedx > 1) and
643 (small_playfield.selectedx < 4) and
644 (small_playfield.selectedy < 1)
645 then
646 draw_image({name = 'cursor_wide'},
647 2 - .5 + screen.playfieldx / screen.tilesize,
648 small_playfield.selectedy - .5 + screen.playfieldy / screen.tilesize
650 else
651 draw_image({name = 'cursor'},
652 small_playfield.selectedx - .5 + screen.playfieldx / screen.tilesize,
653 small_playfield.selectedy - .5 + screen.playfieldy / screen.tilesize
660 function draw_minimap() -- in Secrets
661 if level_labels[game.currentlevel] ~= 'Secrets' then return end
662 love.graphics.setColor(.5,.5,.5, 1)
663 love.graphics.draw(trinkets.frame.bmp,
664 - screen.tilesize * 1.5 / 10 , - screen.tilesize * 1.5 / 10,
665 nil, screen.tilesize / trinkets.frame.scale * 1.1
667 love.graphics.push()
668 love.graphics.scale(screen.tilesize / 5)
669 for a = 0, 3 do for b = 0, 3 do
670 if not game.seen_levels[level_labels['Secrets'] + a + b * 4] then
671 love.graphics.setColor(0, 0, 0, .5)
672 love.graphics.rectangle('fill', a, b, 1, 1)
673 else
674 local t = big_playfield[a + 1][b + 1]
675 draw_image(t, (a + .5) / screen.tilesize, (b + .5) / screen.tilesize, nil, 1 / screen.tilesize, true, true)
677 end end
678 love.graphics.setColor(1, 1, 1)
679 love.graphics.rectangle('line',
680 big_playfield.selectedx - 1, big_playfield.selectedy - 1, 1, 1
682 love.graphics.pop()
686 -- draw map or square at desired location
687 function show_minimap(solved, all) -- in Secrets
688 local x = screen.playfieldx + 3 * screen.tilesize
689 local y = screen.playfieldy - screen.tilesize
690 local d = screen.tilesize / 5
691 if all then
692 love.graphics.setColor(1,1,1, 1)
693 love.graphics.draw(screen.minimap, x + d / 2, y + d / 2)
694 else
695 love.graphics.setColor(.5,.5,.5, 1)
696 love.graphics.rectangle('line', x + d / 2, y + d / 2, d * 4, d * 4)
698 love.graphics.setColor(1,1,1, 1)
699 if solved then
700 love.graphics.rectangle('line', x + d / 2, y + d / 2, d * 4, d * 4)
705 function draw_pencil() -- in Secrets or when painting
706 local y = screen.playfieldy - screen.tilesize
707 local image = trinkets.pencil
708 if playfield.paint_mode == 1 then
709 image = images.pencil_g
710 elseif playfield.paint_mode == 2 then
711 image = images.pencil_r
712 elseif playfield.paint_mode == 3 then
713 image = images.pencil_y
715 love.graphics.draw(image.bmp,
716 screen.playfieldx + screen.tilesize * .15, y + screen.tilesize * .15,
717 nil, screen.tilesize / 70
719 love.graphics.setColor(1,1,1, 1)
723 function draw_pencil_stop() -- when painting
724 local st = screen.tilesize / 4
725 local x = screen.playfieldx + 14 * st
726 local y = screen.playfieldy - 2 * st
727 love.graphics.setColor(.5,.5,.5, 1)
728 love.graphics.polygon('fill',
729 x - st / 1.5, y,
730 x, y + st,
731 x, y + st / 2
733 love.graphics.polygon('fill',
734 x, y + st,
735 x, y + st / 2,
736 x + st / 1.5 * 2, y - st
738 love.graphics.setColor(1,1,1, 1)
742 function draw_osd()
743 -- level name with arrows for traversing levels
744 -- or pencil and minimap in Secrets
745 local y = screen.playfieldy - screen.tilesize
746 local offsety = (screen.tilesize - screen.defaultfont:getHeight()) / 2
747 love.graphics.setColor(1, 1, 1)
748 -- level name
749 love.graphics.printf(pretty_name(game.currentlevel), screen.playfieldx, y + offsety, screen.playfieldsize, 'center')
750 -- arrows for traversing levels
751 if not (current.symbolic or current.painting) then
752 local enabled
753 if traversable(-1) then enabled = 'fill' else enabled = 'line' end
754 love.graphics.polygon(enabled,
755 screen.playfieldx + screen.tilesize * .35, y + screen.tilesize / 2,
756 screen.playfieldx + screen.tilesize * .6, y + screen.tilesize * .35,
757 screen.playfieldx + screen.tilesize * .6, y + screen.tilesize * .65
759 if traversable(1) then enabled = 'fill' else enabled = 'line' end
760 love.graphics.polygon(enabled,
761 screen.playfieldsize + screen.playfieldx - screen.tilesize * .35, y + screen.tilesize / 2,
762 screen.playfieldsize + screen.playfieldx - screen.tilesize * .6, y + screen.tilesize * .35,
763 screen.playfieldsize + screen.playfieldx - screen.tilesize * .6, y + screen.tilesize * .65
766 if current.painting then
767 draw_pencil()
768 draw_pencil_stop()
770 if level_labels[game.currentlevel] == 'Secrets' then
771 if has_trinket('pencil') then draw_pencil() end
772 show_minimap(game.solved_levels[game.currentlevel], has_trinket('frame'))