Draw tiled ground texture with nested for loop

This commit is contained in:
Joseph Ferano 2024-11-11 18:53:18 +07:00
parent 55f875cb44
commit c7075d6251

View File

@ -34,8 +34,24 @@
(defun game-update (state) '())
(defun draw-tile (tilemap size col row)
(rl:draw-texture-rec
tilemap
(rl:make-rectangle :x (* size (mod col 5)) :y (* size (mod row 5)) :width size :height size)
(vec (* col size) (* row size))
:white))
(defun draw-ground ()
(let ((size 32)
(terrain-tex (gethash 'terrain (game-state-textures *game-state*))))
(loop for row from 0 to 16
do (loop for col from 0 to 32
do (draw-tile terrain-tex size col row)))))
(defun game-draw (state)
(rl:draw-texture-v (gethash 'terrain (game-state-textures state)) (vec 50 50) :white)
(rl:clear-background (rl:make-rgba 71 171 169 1))
(draw-ground)
;; (rl:draw-texture-v (gethash 'terrain (game-state-textures state)) (vec 50 50) :white)
(rl:draw-fps 10 5))
(defun main ()
@ -48,7 +64,6 @@
:do (game-input *game-state*)
(game-update *game-state*)
(rl:with-drawing
(rl:clear-background :raywhite)
(game-draw *game-state*)))
(loop for value being the hash-values of (game-state-textures *game-state*)
do (rl:unload-texture value)))))