From a586780bf88efb2a54df1e2af26600a549f7113d Mon Sep 17 00:00:00 2001 From: Javier Sancho Date: Fri, 21 Apr 2017 01:39:14 +0200 Subject: [PATCH] Moving scenes --- gacela/image.scm | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/gacela/image.scm b/gacela/image.scm index 278a7d7..e6c8f4e 100644 --- a/gacela/image.scm +++ b/gacela/image.scm @@ -24,9 +24,14 @@ #:use-module ((sdl2 surface) #:prefix sdl2:) #:use-module (gl) #:export (image - move-xy + move scale)) +(define (calculate proc-or-value) + (if (procedure? proc-or-value) + (proc-or-value) + proc-or-value)) + (define (image filename) (make-scene "image" @@ -52,15 +57,14 @@ (gl-vertex (- w/2) (- h/2) 0)) (gl-disable (oes-framebuffer-object texture-2d)))))) -(define (move-xy x y scene) - (define (to-integer n) - (inexact->exact (round n))) +(define* (move scene x y #:optional (z 0)) (make-scene - "move-xy" + "move" (lambda () - (let ((xy (list (to-integer (if (procedure? x) (x) x)) - (to-integer (if (procedure? y) (y) y))))) - (display-scene scene #:xy xy))))) + (gl-translate (calculate x) + (calculate y) + (calculate z)) + (display-scene scene)))) (define* (scale scene x #:optional (y x) (z y)) (make-scene -- 2.39.5