Browse Source

Clarify screen-space

master
Macoy Madson 3 years ago
parent
commit
0ef6f59fda
  1. 12
      src/Main.cake

12
src/Main.cake

@ -304,18 +304,18 @@
(set piece-size (vec2-multiply piece-size piece-grid-size))
(return piece-size))
(defun-local is-within-game-piece (piece (* (const board-piece)) point-to-test vec2 &return bool)
(defun-local is-within-game-piece (piece (* (const board-piece)) screen-point-to-test vec2 &return bool)
(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))
;; (vec-xy screen-point-to-test))
(return
(and
(>= (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)))))
(>= (vec-x screen-point-to-test) (vec-x piece-top-left-px))
(>= (vec-y screen-point-to-test) (vec-y piece-top-left-px))
(< (vec-x screen-point-to-test) (vec-x piece-bottom-right-px))
(< (vec-y screen-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)))

Loading…
Cancel
Save