render colors
Press any key to quit" 10 10)) Press any key to quit" 10 10))
This commit is contained in:
parent
6b2980ffe6
commit
e9b36dc9e1
10 changed files with 204 additions and 1 deletions
|
|
@ -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))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue