From 1b5d9454c95625c8175f40c09a867f0d421631b3 Mon Sep 17 00:00:00 2001 From: David Thompson Date: Sun, 16 Jun 2013 14:39:29 -0400 Subject: Add a make-sprite procedure with keyword arguments. --- 2d/sprite.scm | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to '2d/sprite.scm') diff --git a/2d/sprite.scm b/2d/sprite.scm index 4415974..cbce56b 100644 --- a/2d/sprite.scm +++ b/2d/sprite.scm @@ -45,7 +45,7 @@ ;; The object represents a texture with a given position, scale, and ;; rotation. (define-record-type - (make-sprite texture x y scale-x scale-y rotation color) + (%make-sprite texture x y scale-x scale-y rotation color) sprite? (texture sprite-texture) (x sprite-x set-sprite-x!) @@ -55,6 +55,10 @@ (rotation sprite-rotation set-sprite-rotation!) (color sprite-color set-sprite-color!)) +(define* (make-sprite texture #:optional (x 0) (y 0) (scale-x 0) (scale-y 0) + (rotation 0) (color '(1 1 1))) + (%make-sprite texture x y scale-x scale-y rotation color)) + (define (set-sprite-scale! sprite scale) "Sets sprite scale-x and scale-y to the same value." (set-sprite-scale-x! sprite scale) @@ -62,7 +66,7 @@ (define (load-sprite filename) "Loads a sprite from file with default position, scaling, and rotation values." - (make-sprite (load-texture filename) 0 0 1 1 0 '(1 1 1))) + (make-sprite (load-texture filename))) (define (draw-sprite sprite) "Renders a sprite." -- cgit v1.2.3