summaryrefslogtreecommitdiff
path: root/2d
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2014-05-07 18:35:36 -0400
committerDavid Thompson <dthompson2@worcester.edu>2014-05-07 18:35:36 -0400
commit9aaf017b70fb9474d3c5be22a27dfcc86d8b41c1 (patch)
treee0e4d7ea975c483ceab1b748c6ae9264f731a303 /2d
parenta316893a68ae44a100d6dc5be34bf2c7d582e9ca (diff)
Make sprites immutable.
* 2d/sprite.scm (<sprite>): Make immutable. (set-sprite-drawable!, set-sprite-position!, set-sprite-scale!) (set-sprite-rotation!, set-sprite-color!, set-sprite-anchor!): Delete. (set-sprite-drawable, set-sprite-position, set-sprite-scale) (set-sprite-rotation, set-sprite-color, set-sprite-anchor): New procedures. * examples/coroutine.scm: * examples/particles.scm: Use immutable sprite setters.
Diffstat (limited to '2d')
-rw-r--r--2d/sprite.scm30
1 files changed, 14 insertions, 16 deletions
diff --git a/2d/sprite.scm b/2d/sprite.scm
index c050a39..c3dc4f1 100644
--- a/2d/sprite.scm
+++ b/2d/sprite.scm
@@ -25,6 +25,7 @@
(define-module (2d sprite)
#:use-module (srfi srfi-1)
#:use-module (srfi srfi-9)
+ #:use-module (srfi srfi-9 gnu)
#:use-module (gl)
#:use-module (gl contrib packed-struct)
#:use-module ((sdl sdl) #:prefix SDL:)
@@ -46,16 +47,16 @@
animated-sprite?
sprite-drawable
sprite-position
- set-sprite-drawable!
- set-sprite-position!
- set-sprite-scale!
- set-sprite-rotation!
- set-sprite-color!
- set-sprite-anchor!
sprite-scale
sprite-rotation
sprite-color
sprite-anchor
+ set-sprite-drawable
+ set-sprite-position
+ set-sprite-scale
+ set-sprite-rotation
+ set-sprite-color
+ set-sprite-anchor
load-sprite
draw-sprite))
@@ -78,15 +79,15 @@
;; The <sprite> type represents a drawable object (texture,
;; texture-region, animation, etc.) with a given position, scale,
;; rotation, and color.
-(define-record-type <sprite>
+(define-immutable-record-type <sprite>
(%make-sprite drawable position scale rotation color anchor vertices animator)
sprite?
- (drawable sprite-drawable set-sprite-drawable!)
- (position sprite-position set-sprite-position!)
- (scale sprite-scale set-sprite-scale!)
- (rotation sprite-rotation set-sprite-rotation!)
- (color sprite-color set-sprite-color!)
- (anchor sprite-anchor %set-sprite-anchor!)
+ (drawable sprite-drawable set-sprite-drawable)
+ (position sprite-position set-sprite-position)
+ (scale sprite-scale set-sprite-scale)
+ (rotation sprite-rotation set-sprite-rotation)
+ (color sprite-color set-sprite-color)
+ (anchor sprite-anchor set-sprite-anchor)
(vertices sprite-vertices)
(animator sprite-animator))
@@ -151,9 +152,6 @@ optional keyword arguments."
(drawable-texture (sprite-drawable sprite)
(sprite-animator sprite))))
-(define (set-sprite-anchor! sprite anchor)
- (%set-sprite-anchor! sprite (anchor-texture (sprite-texture sprite) anchor)))
-
(define (update-sprite-animator! sprite)
(animator-update! (sprite-animator sprite))
(update-sprite-vertices! sprite))