diff options
author | David Thompson <dthompson2@worcester.edu> | 2016-02-27 20:45:09 -0500 |
---|---|---|
committer | David Thompson <dthompson2@worcester.edu> | 2016-02-27 20:45:09 -0500 |
commit | 873d00e01e7d714fd3cbbb86d3da88380c179145 (patch) | |
tree | 3f6d34fa1cdf08ec17475126451f93fd86847ecf /sly/input | |
parent | a319acd01ac950d479d43d77c07d44a9af3012cd (diff) |
math: Rewrite vector math library to use packed f64 bytevectors.
The big consequence of this change to the rest of the codebase is that
we can no longer use record destructuring when pattern matching, so I
had to rewrite every place where pattern matching was used. It was
probably a bad idea to expose the record type descriptors publicly in
the first place.
* sly/math/vector.scm: Reimplement everything in terms of an f64 packed
bytevector record type. Do not expose record type descriptors.
* sly/game.scm (run-game-loop): Convert viewport width/height to exact
numbers.
* sly/window.scm (open-window): Likewise.
* sly/input/mouse.scm (mouse-position): Rewrite pattern matching.
* sly/math/quaternion (make-quaternion, vector->quaternion): Likewise.
* sly/math/rect.scm (rect-clamp): Likewise.
* sly/math/transform.scm (translate!, translate, scale): Likewise.
* sly/render/mesh.scm (vertices-bytevector): Likewise.
* examples/mines/mines.scm: Likewise.
Diffstat (limited to 'sly/input')
-rw-r--r-- | sly/input/mouse.scm | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/sly/input/mouse.scm b/sly/input/mouse.scm index c6d2b96..815fee6 100644 --- a/sly/input/mouse.scm +++ b/sly/input/mouse.scm @@ -53,8 +53,10 @@ ;; Sly uses the bottom-left as the origin, so invert ;; the y-axis for convenience. (match-lambda - (($ <vector2> x y) - (vector2 x (- (signal-ref window-height) y)))))) + ((? vector2? v) + (vector2 (vector2-x v) + (- (signal-ref window-height) + (vector2-y v))))))) (define-signal mouse-x (signal-map vx mouse-position)) (define-signal mouse-y (signal-map vy mouse-position)) |