fennel_love2d_experiments/two_player_cleaning_game/main.fnl
Travis Shears e9b36dc9e1
render colors
Press any key to quit" 10 10))
Press any key to quit" 10 10))
2026-04-05 21:59:23 +02:00

49 lines
1.3 KiB
Fennel

(var player-sprite nil) ; 20x20 pixels
(local game-state {
:player-pos [0 0]
})
(fn love.load []
(love.window.setMode 600 640)
(set player-sprite (love.graphics.newImage "assets/player_001.png"))
;; start a thread listening on stdin
(: (love.thread.newThread "require('love.event')
while 1 do love.event.push('stdin', io.read('*line')) end") :start))
(fn love.handlers.stdin [line]
;; evaluate lines read from stdin as fennel code
(let [(ok val) (pcall fennel.eval line)]
(print (if ok (fennel.view val) val))))
;; drawing
(lambda color [full-r full-g full-b]
(let [(r g b) (love.math.colorFromBytes full-r full-g full-b)]
[r g b]
))
(local off-white (color 237 230 200))
(local black [0 0 0])
(fn draw-game-outline []
(love.graphics.setColor (unpack black))
(love.graphics.rectangle "line" 50 50 500 500))
(fn draw-player []
(love.graphics.setColor 1 1 1) ; reset color to white (no tinting)
(love.graphics.draw player-sprite 50 50 0 1.25 1.25))
(fn love.draw []
;; clear the screen and set bg to off white
(love.graphics.clear)
(love.graphics.setColor (unpack off-white))
(love.graphics.rectangle "fill" 0 0 600 640)
(draw-player)
(draw-game-outline)
)
; (love.graphics.print "Hello from Fennel!\nPress any key to quit" 10 10))
(fn love.keypressed [key]
(love.event.quit))