Browse Source

Indent, fix is-within-game-piece

master
Macoy Madson 3 years ago
parent
commit
e5e7ffa6b5
  1. 38
      src/Main.cake

38
src/Main.cake

@ -146,7 +146,7 @@
(on-each-existing-board-piece
piece piece-index
(when debug-log-enabled
(print-board-piece piece piece-index))
(print-board-piece piece piece-index))
(var num-cells int (path piece > num-cells))
@ -308,12 +308,14 @@
(var piece-top-left-px vec2 (game-piece-position-to-screen-position piece))
(var piece-bottom-right-px vec2 (game-piece-get-screen-size piece))
(set piece-bottom-right-px (vec2-add piece-top-left-px piece-bottom-right-px))
;; (printf "%f %f -> %f %f vs. (%f %f)\n" (vec-xy piece-top-left-px) (vec-xy piece-bottom-right-px)
;; (vec-xy point-to-test))
(return
(and
(>= (vec-x piece-top-left-px) (vec-x point-to-test))
(>= (vec-y piece-top-left-px) (vec-y point-to-test))
(< (vec-x piece-bottom-right-px) (vec-x point-to-test))
(< (vec-y piece-bottom-right-px) (vec-y point-to-test)))))
(>= (vec-x point-to-test) (vec-x piece-top-left-px))
(>= (vec-y point-to-test) (vec-y piece-top-left-px))
(< (vec-x point-to-test) (vec-x piece-bottom-right-px))
(< (vec-y point-to-test) (vec-y piece-bottom-right-px)))))
(defun-local pick-game-piece-from-screen-position (x int y int &return (* board-piece))
(var position vec2 (array (type-cast x float) (type-cast y float)))
@ -335,8 +337,8 @@
(unless (!= -1 piece-index)
(return null))
(var piece (* board-piece) (addr (at piece-index g-game-board-pieces)))
;; (unless (is-within-game-piece piece position) ;; TODO Broken
;; (return null))
(unless (is-within-game-piece piece position)
(return null))
(return piece))
;;
@ -431,15 +433,15 @@ Rush Hour database from Michael Fogleman.\n\n")
\tgame board margin px: %d\n
\tgame board cell size px: %d\n
\tgame board inner top left px: %.2f %.2f\n\n"
g-window-width
g-window-height
g-window-safe-area-margin-px
g-game-board-outer-size-px
(vec-xy g-game-board-outer-top-left-px)
g-game-board-grid-size
g-game-board-margin-px
g-game-board-cell-size-px
(vec-xy g-game-board-inner-top-left-px))
g-window-width
g-window-height
g-window-safe-area-margin-px
g-game-board-outer-size-px
(vec-xy g-game-board-outer-top-left-px)
g-game-board-grid-size
g-game-board-margin-px
g-game-board-cell-size-px
(vec-xy g-game-board-inner-top-left-px))
;;
;; Initialization
@ -562,8 +564,8 @@ Rush Hour database from Michael Fogleman.\n\n")
(vec-xy-to-int piece-size)))
(unless (= 0 (SDL_RenderCopy renderer pieces-texture
(addr src-rect) (addr dest-rect)))
(sdl-print-error)
(set exit-reason "Render error")))
(sdl-print-error)
(set exit-reason "Render error")))
(SDL_RenderPresent renderer))

Loading…
Cancel
Save