summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2020-11-18 17:24:49 -0500
committerDavid Thompson <dthompson2@worcester.edu>2020-11-18 17:24:49 -0500
commit61cdbd49ae1b4a0ab769af9bde02adb8fc1b1911 (patch)
tree0cba998d44431911ab65d1d5baff5746e6c1896f
parent3d858f1f2fc864d9ef29e8ba35e2dc9ce526eb72 (diff)
graphics: tiled: Remove region argument from draw-tile-map.
-rw-r--r--chickadee/graphics/tiled.scm19
-rw-r--r--doc/api.texi24
2 files changed, 13 insertions, 30 deletions
diff --git a/chickadee/graphics/tiled.scm b/chickadee/graphics/tiled.scm
index 46dfea3..5b3e9bf 100644
--- a/chickadee/graphics/tiled.scm
+++ b/chickadee/graphics/tiled.scm
@@ -468,26 +468,23 @@
(define *position* (vec2 0.0 0.0))
(define *region* (make-rect 0.0 0.0 0.0 0.0))
-;; Make a default region that is as big as the viewport.
-(define (default-region tile-map position)
- (let ((vp (current-viewport)))
- (set-rect-x! *region* (vec2-x position))
- (set-rect-y! *region* (vec2-y position))
- (set-rect-width! *region* (viewport-width vp))
- (set-rect-height! *region* (viewport-height vp))
- *region*))
-
(define* (draw-tile-map tile-map
#:key
layers
(camera %null-vec2)
(position %null-vec2)
- (region (default-region tile-map camera))
(origin %null-vec2)
(scale %default-scale)
(rotation 0.0))
"Draw TILE-MAP. By default, all layers are drawn. The LAYERS
argument may be used to specify a list of layers to draw, instead."
+ ;; Make the region as big as the current viewport.
+ (let ((vp (current-viewport)))
+ (set-rect-x! *region* (vec2-x camera))
+ (set-rect-y! *region* (vec2-y camera))
+ (set-rect-width! *region* (viewport-width vp))
+ (set-rect-height! *region* (viewport-height vp)))
+ ;; Translation must be adjusted by inverse of camera.
(vec2-copy! camera *position*)
(vec2-mult! *position* -1.0)
(vec2-add! *position* position)
@@ -496,4 +493,4 @@ argument may be used to specify a list of layers to draw, instead."
#:position *position*
#:rotation rotation
#:scale scale)
- (draw-tile-map* tile-map *matrix* region #:layers layers))
+ (draw-tile-map* tile-map *matrix* *region* #:layers layers))
diff --git a/doc/api.texi b/doc/api.texi
index e93263e..14310a2 100644
--- a/doc/api.texi
+++ b/doc/api.texi
@@ -2051,19 +2051,15 @@ Translate the pixel coordinates (@var{x}, @var{y}) into tile
coordinates.
@end deffn
-@deffn {Procedure} draw-tile-map tile-map [#:layers] [#:region] @
+@deffn {Procedure} draw-tile-map tile-map [#:layers] [#:camera] @
[#:origin] [#:position] [#:scale] [#:rotation]
-Draw the layers of @var{tile-map}. By default, all layers are drawn.
-To draw a subset of the available layers, pass a list of layer ids
-using the @var{layers} keyword argument.
-
-Refer to @code{draw-sprite} (@pxref{Sprites}) for information about
-the other arguments.
+Draw the layers of @var{tile-map} as viewed from @var{camera}, a 2D
+vector offset. By default, all layers are drawn. To draw a subset of
+the available layers, pass a list of layer ids using the @var{layers}
+keyword argument.
@end deffn
-@subsubsection Tilesets
-
@deffn {Procedure} tileset? obj
Return @code{#t} if @var{obj} is a tileset.
@end deffn
@@ -2100,8 +2096,6 @@ Return the tiles in @var{tileset}.
Return the custom properties of @var{tileset}.
@end deffn
-@subsubsection Tiles
-
@deffn {Procedure} tile? obj
Return @code{#t} if @var{obj} is a tile.
@end deffn
@@ -2118,8 +2112,6 @@ Return the animation for @var{tile}.
Return the custom properties of @var{tile}.
@end deffn
-@subsubsection Animations
-
@deffn {Procedure} animation-frame? obj
Return @code{#t} if @var{obj} is an animation frame.
@end deffn
@@ -2132,8 +2124,6 @@ Return the tile for @var{frame}.
Return the duration of @var{frame}.
@end deffn
-@subsubsection Layers
-
@deffn {Procedure} tile-layer? obj
Return @code{#t} if @var{obj} is a tile layer.
@end deffn
@@ -2174,8 +2164,6 @@ Return the objects for @var{layer}.
Return the custom properties of @var{layer}.
@end deffn
-@subsubsection Objects
-
@deffn {Procedure} map-object? obj
Return @code{#t} if @var{obj} is a map object.
@end deffn
@@ -2200,8 +2188,6 @@ Return the shape of @var{obj}.
Return the custom properties of @var{obj}.
@end deffn
-@subsubsection Polygons
-
@deffn {Procedure} polygon? obj
Return @code{#t} if @var{obj} is a polygon.
@end deffn