Draw tiled ground texture with nested for loop
This commit is contained in:
parent
55f875cb44
commit
c7075d6251
19
game.lisp
19
game.lisp
@ -34,8 +34,24 @@
|
|||||||
|
|
||||||
(defun game-update (state) '())
|
(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)
|
(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))
|
(rl:draw-fps 10 5))
|
||||||
|
|
||||||
(defun main ()
|
(defun main ()
|
||||||
@ -48,7 +64,6 @@
|
|||||||
:do (game-input *game-state*)
|
:do (game-input *game-state*)
|
||||||
(game-update *game-state*)
|
(game-update *game-state*)
|
||||||
(rl:with-drawing
|
(rl:with-drawing
|
||||||
(rl:clear-background :raywhite)
|
|
||||||
(game-draw *game-state*)))
|
(game-draw *game-state*)))
|
||||||
(loop for value being the hash-values of (game-state-textures *game-state*)
|
(loop for value being the hash-values of (game-state-textures *game-state*)
|
||||||
do (rl:unload-texture value)))))
|
do (rl:unload-texture value)))))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user