render colors

Press any key to quit" 10 10))
Press any key to quit" 10 10))
This commit is contained in:
Travis Shears 2026-04-03 18:35:13 +02:00
parent 6b2980ffe6
commit e9b36dc9e1
Signed by: travisshears
GPG key ID: CB9BF1910F3F7469
10 changed files with 204 additions and 1 deletions

BIN
two_player_cleaning_game/.DS_Store vendored Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 434 B

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 220 B

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 184 B

View file

@ -1,4 +1,12 @@
(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))
@ -8,8 +16,34 @@ while 1 do love.event.push('stdin', io.read('*line')) end") :start))
(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 []
(love.graphics.print "Hello from Fennel!\nPress any key to quit" 10 10))
;; 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))