38 ['9'] = { -- regenex - pressed
42 A
= { -- regene+ - pressed
48 bmp
= love
.graphics
.newImage('gfx/bluesave.png'),
52 bmp
= love
.graphics
.newImage('gfx/blueload.png'),
56 bmp
= love
.graphics
.newImage('gfx/blackload.png'),
60 bmp
= love
.graphics
.newImage('gfx/redsave.png'),
80 bmp
= love
.graphics
.newImage('gfx/blacksave.png'),
84 bmp
= love
.graphics
.newImage('gfx/wiseman.png'),
88 bmp
= love
.graphics
.newImage('gfx/pill.png'),
100 bmp
= love
.graphics
.newImage('gfx/dead.png'),
106 a
= { -- green+ - memory
111 b
= { -- greenx - memory
116 c
= { --loadred+ - memory
121 d
= { --loadredx - memory
126 e
= { -- red+ - memory
131 f
= { -- redx - memory
136 g
= { -- regene+ - pressed - memory
137 color
= {.6, .3, .3},
141 h
= { -- regenex - memory
142 color
= {.6, .3, .3},
146 i
= { -- regenex - pressed - memory
147 color
= {.6, .3, .3},
151 j
= { -- yellow+ - memory
156 k
= { -- yellowx - memory
161 l
= { -- regene+ - memory
162 color
= {.6, .3, .3},
166 m
= { -- purple+ - memory
171 n
= { -- purplex - memory
177 bmp
= love
.graphics
.newImage('gfx/floor_regene_x.png'),
179 floor_regene_plus
= {
180 bmp
= love
.graphics
.newImage('gfx/floor_regene_plus.png'),
184 function add_scale(t
)
185 for k
, v
in pairs(t
) do if type(v
) == 'table' and v
.bmp
then
186 -- determine correct scale and offset for bitmaps
187 local sizex
, sizey
= v
.bmp
:getWidth(), v
.bmp
:getHeight()
188 v
.scale
= math
.max(sizex
, sizey
)
189 v
.offsetx
= (v
.scale
- sizex
) / 2 / v
.scale
190 v
.offsety
= (v
.scale
- sizey
) / 2 / v
.scale
192 v
.bmp
:setFilter('linear', 'nearest')
199 function draw_floor(x
, y
, stepped
, sleep
, shape
)
201 love
.graphics
.scale(screen
.tilesize
)
202 love
.graphics
.translate(x
, y
)
203 love
.graphics
.setColor(images
['0'].color
, 1)
204 love
.graphics
.rectangle('fill', -.50,-.50, 1.00,1.00)
205 love
.graphics
.setColor(1,1,1, .4)
207 love
.graphics
.polygon('fill', .50,-.50, .50,.50, -.50,.50)
209 love
.graphics
.polygon('fill', -.50,-.50, .50,-.50, -.50,.50)
211 love
.graphics
.setColor(0,0,0, .4)
213 love
.graphics
.polygon('fill', -.50,-.50, .50,-.50, .50,.50)
215 love
.graphics
.polygon('fill', -.50,-.50, .50,.50, -.50,.50)
217 love
.graphics
.setColor(images
['0'].color
, 1)
218 love
.graphics
.rectangle('fill', -.45,-.45, .90,.90)
220 love
.graphics
.setColor(1,1,1, 1)
222 if shape
== '+' then img
= images
.floor_regene_plus
else img
= images
.floor_regene_x
end
223 love
.graphics
.draw(img
.bmp
, img
.offsetx
-.50, img
.offsety
-.50, 0, 1/img
.scale
, 1/img
.scale
)
229 function draw_image(pftile
, x
, y
, phase
, scale
)
230 if not phase
then phase
= 0 end
231 function arrow(color
, angle
, distance
, base
)
232 if not quality
then quality
= 'fill' end
233 base
= ((base
or 0) + 1) / 10
234 if angle
% (math
.pi
/ 2) > .1 then
235 distance
= distance
* math
.sqrt(2)
237 distance
= distance
+ .5
238 local ox
, oy
= math
.sin(angle
) * (distance
- .5), math
.cos(angle
) * (distance
- .5)
239 local ex
, ey
= math
.sin(angle
) * distance
, math
.cos(angle
) * distance
240 love
.graphics
.setColor(color
)
241 love
.graphics
.polygon(quality
, ex
, ey
,
242 ox
+ math
.sin(angle
+ math
.pi
/ 2) * base
, oy
+ math
.cos(angle
+ math
.pi
/ 2) * base
,
243 ox
- math
.sin(angle
+ math
.pi
/ 2) * base
, oy
- math
.cos(angle
+ math
.pi
/ 2) * base
247 if not pftile
.name
then return end
248 if images
[pftile
.name
].memory
then
249 draw_image(pftile
.memory
, x
, y
, phase
, .5)
253 love
.graphics
.setLineWidth(0.01)
254 love
.graphics
.scale(screen
.tilesize
)
255 love
.graphics
.translate(x
, y
)
256 if scale
then love
.graphics
.scale(scale
) end
258 local function gifts_aperture()
259 local ph
= playfield
.giftsphase
260 love
.graphics
.rectangle('fill', -.5 * ph
, -.5 * ph
, 1 * ph
, 1 * ph
)
262 if pftile
.ingift
then --draw gift surface without aperture
263 love
.graphics
.stencil(gifts_aperture
, "replace", 1)
264 love
.graphics
.setStencilTest("less", 1)
266 if pftile
.ingift
or images
[pftile
.name
].shape
== 'gift' then
267 if images
[pftile
.name
].shape
== 'gift' then
268 love
.graphics
.setColor(images
[pftile
.name
].color
, 1)
269 love
.graphics
.rectangle('fill', -.5, -.5, 1, 1)
271 love
.graphics
.setColor(1,1,1, .4)
272 love
.graphics
.polygon('fill', -.50,-.50, .50,-.50, -.50,.50)
273 love
.graphics
.setColor(0,0,0, .4)
274 love
.graphics
.polygon('fill', -.50,-.50, .50,.50, -.50,.50)
276 if pftile
.ingift
then --invert stencil to draw gift contents
277 love
.graphics
.setStencilTest("gequal", 1)
280 if images
[pftile
.name
].color
then
281 love
.graphics
.setColor(images
[pftile
.name
].color
, 1)
283 love
.graphics
.setColor(1,1,1, 1)
285 if pftile
.kind
== 'regene' then
286 for a
= 1, 8 do if pftile
.arrows
[a
] then
287 arrow(pftile
.color
or images
[pftile
.name
].color
, math
.pi
/ 4 * (a
+ 1) , pftile
.arrows
[a
], phase
) --!!
289 elseif pftile
.arrows
then
290 for a
= 1, 8 do if pftile
.arrows
[a
] then
291 arrow(pftile
.color
or images
[pftile
.name
].color
, math
.pi
/ 4 * (a
+ 1 + phase
) , pftile
.arrows
[a
], nil)
294 if images
[pftile
.name
].shape
== 'bmp' then
295 love
.graphics
.setColor(1,1,1, 1)
296 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
)
298 if images
[pftile
.name
].shape
== 'trinket' then
299 local trinket
= levels
[game
.currentlevel
].trinket
300 if not trinkets
[trinket
] then trinket
= 'cigarettes' end --!! until all trinkets are implemented
301 love
.graphics
.setColor(1,1,1, 1)
302 love
.graphics
.draw(trinkets
[trinket
].bmp
, trinkets
[trinket
].offsetx
-.50, trinkets
[trinket
].offsety
-.50, 0, 1/trinkets
[trinket
].scale
, 1/trinkets
[trinket
].scale
)
305 if images
[pftile
.name
].center
then
307 love
.graphics
.setColor(.5,.5,.5, 1)
308 if pftile
.devil
then love
.graphics
.setColor(.9,.3,.3, 1) end
309 love
.graphics
.rectangle('fill', -.15,-.15, .30,.30)
310 if pftile
.center
== 'dot' or images
[pftile
.name
].center
== 'dot' then
311 love
.graphics
.setColor(.1,.1,.1, 1)
312 love
.graphics
.circle('fill', 0,0, .1)
314 if images
[pftile
.name
].center
== 'purple' then
315 love
.graphics
.setColor(.1,.1,.1, 1)
316 if game
.temppurple
then
317 love
.graphics
.rectangle('fill', -.05,-.05, .1, .1)
319 love
.graphics
.rectangle('line', -.05,-.05, .1, .1)
322 if images
[pftile
.name
].center
== 'bmp' then
323 love
.graphics
.setColor(1,1,1, 1)
324 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
)
327 if pftile
.ingift
then --darken gifts content
328 love
.graphics
.setColor(0,0,0, .9 - playfield
.giftsphase
)
331 love
.graphics
.setStencilTest()
333 love
.graphics
.setColor(1, 1, 1, 1)
334 --small images in loadred
335 if pftile
.name
~= 'R' and pftile
.arrowgift
then
336 draw_image(pftile
.arrowgift
, x
, y
, 0, pftile
.arrowgiftphase
or .4)
341 function draw_playfield()
342 -- layer 1: playfield
343 inplayfield(function (x
, y
, p
)
344 local stepped
= playfield
.clickedx
== x
and playfield
.clickedy
== y
345 draw_floor(x
- .5 + screen
.playfieldx
, y
- .5 + screen
.playfieldy
, stepped
, p
.sleep
, p
.shape
)
347 -- layer 2: all images and arrows
348 inplayfield(function (x
, y
, p
)
349 if p
.name
~= '0' or p
.shape
or p
.ingift
then
350 draw_image(p
, x
- .5 + screen
.playfieldx
, y
- .5 + screen
.playfieldy
, p
.phase
)
353 -- layer 3: dead player
354 if game
.showkill
then
355 --playfield[playfield.clickedx][playfield.clickedy].name = 'R'
356 draw_image(playfield
[playfield
.clickedx
][playfield
.clickedy
], playfield
.clickedx
- .5 + screen
.playfieldx
, playfield
.clickedy
- .5 + screen
.playfieldy
)