Generalize drawing sprites

This commit is contained in:
Joseph Ferano 2024-11-22 16:31:17 +07:00
parent 732f98d038
commit 2f9e663523

View File

@ -80,6 +80,8 @@
(defun game-input ()
(when (rl:is-mouse-button-pressed 0)
(setf (click-pos *game-state*) (print (rl:get-mouse-position))))
(when (rl:is-mouse-button-pressed 1)
(setf (click-pos *game-state*) (print (rl:get-mouse-position)))))
;; (with-slots ((pos archer-pos) (kpos knight-pos)) *game-state*
;; (let ((dx 0.0) (dy 0.0))
@ -159,15 +161,15 @@
(rl:clear-background (rl:make-rgba 71 171 169 1))
(draw-ground)
(rl:draw-texture-v (gethash 'tower *textures*) (vec 80 150) :white)
(draw-sprite (sprite *knight*) (pos *knight*))
(draw-sprite (sprite *archer*) (pos *archer*))
(dolist (entity (entities *game-state*))
(draw-sprite (sprite entity) (pos entity)))
(rl:draw-fps 10 10))
(defun game ()
(let* ((screen-width 900)
(screen-height 500))
(rl:with-window (screen-width screen-height "RTS")
(rl:set-target-fps 120)
(rl:set-target-fps 240)
(game-init)
(loop :until (rl:window-should-close)
:do (livesupport:continuable (game-input)