]> git.jsancho.org Git - gacela.git/commitdiff
Gacela as Guile modules.
authorjsancho <devnull@localhost>
Tue, 6 Dec 2011 13:03:45 +0000 (13:03 +0000)
committerjsancho <devnull@localhost>
Tue, 6 Dec 2011 13:03:45 +0000 (13:03 +0000)
src/gacela_misc.scm [deleted file]
src/gacela_widgets.scm [deleted file]
src/math.scm [new file with mode: 0644]
src/ttf.scm
src/widgets/timer.scm [new file with mode: 0755]

diff --git a/src/gacela_misc.scm b/src/gacela_misc.scm
deleted file mode 100644 (file)
index 8e8db13..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-;;; Gacela, a GNU Guile extension for fast games development
-;;; Copyright (C) 2009 by Javier Sancho Fernandez <jsf at jsancho dot org>
-;;;
-;;; This program is free software: you can redistribute it and/or modify
-;;; it under the terms of the GNU General Public License as published by
-;;; the Free Software Foundation, either version 3 of the License, or
-;;; (at your option) any later version.
-;;;
-;;; This program is distributed in the hope that it will be useful,
-;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-;;; GNU General Public License for more details.
-;;;
-;;; You should have received a copy of the GNU General Public License
-;;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-
-
-;;; Additional modules
-
-(use-modules (srfi srfi-1))
-
-
-;;; Constants
-
-(define *pi* (* (asin 1) 2))
-
-
-;;; Geometry
-
-(define (degrees-to-radians angle)
-  (/ (* angle *pi*) 180))
-
-(define (radians-to-degrees angle)
-  (/ (* angle 180) *pi*))
-
-(define (distance-between-points p1 p2)
-  (define (add-power-of-two p1 p2)
-    (cond ((null? p1)
-          0)
-         (else
-          (+ (expt (- (car p1) (car p2)) 2)
-             (add-power-of-two (cdr p1) (cdr p2))))))
-
-  (cond ((not (= (length p1) (length p2)))
-        #f)
-       (else
-        (sqrt (add-power-of-two p1 p2)))))
-
-
-;;; Functions
-
-(define (nearest-power-of-two n)
-  (define (power p n)
-    (cond ((> (* p 2) n) p)
-         (else (power (* p 2) n))))
-  (power 1 n))
-
-;(define-macro (pushnew elem list)
-;  `(cond ((not (find (lambda (e) (eq? e ,elem)) ,list))
-;        (set! ,list (cons ,elem ,list)))))
-
-(define (assoc-multiple-set! alist . pairs)
-  (define (amset! alist pairs)
-    (cond ((< (length pairs) 2)
-          alist)
-         (else
-          (assoc-set! alist (car pairs) (cadr pairs))
-          (amset! alist (cddr pairs)))))
-  (amset! alist pairs))
diff --git a/src/gacela_widgets.scm b/src/gacela_widgets.scm
deleted file mode 100755 (executable)
index b5ddc47..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-;;; Gacela, a GNU Guile extension for fast games development
-;;; Copyright (C) 2009 by Javier Sancho Fernandez <jsf at jsancho dot org>
-;;;
-;;; This program is free software: you can redistribute it and/or modify
-;;; it under the terms of the GNU General Public License as published by
-;;; the Free Software Foundation, either version 3 of the License, or
-;;; (at your option) any later version.
-;;;
-;;; This program is distributed in the hope that it will be useful,
-;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-;;; GNU General Public License for more details.
-;;;
-;;; You should have received a copy of the GNU General Public License
-;;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-
-;;; Timers
-
-(define (make-timer)
-  (let ((start 0) (paused 0) (state 'stopped))
-    (lambda (op)
-      (case op
-       ((start-timer)
-        (set! start (SDL_GetTicks))
-        (set! state 'running))
-
-       ((stop-timer)
-        (set! state 'stopped))
-
-       ((get-time)
-        (cond ((eq? state 'stopped) 0)
-              ((eq? state 'paused) paused)
-              (else (- (SDL_GetTicks) start))))
-
-       ((get-state)
-        state)
-
-       ((pause-timer)
-        (cond ((eq? state 'running)
-               (set! paused (- (SDL_GetTicks) start))
-               (set! state 'paused))))
-
-       ((resume-timer)
-        (cond ((eq? state 'paused)
-               (set! start (- (SDL_GetTicks) paused))
-               (set! state 'running))))))))
-
-(define (start-timer timer)
-  (timer 'start-timer))
-
-(define (stop-timer timer)
-  (timer 'stop-timer))
-
-(define (get-time timer)
-  (timer 'get-time))
-
-(define (get-state timer)
-  (timer 'get-state))
-
-(define (pause-timer timer)
-  (timer 'pause-timer))
-
-(define (resume-timer timer)
-  (timer 'resume-timer))
diff --git a/src/math.scm b/src/math.scm
new file mode 100644 (file)
index 0000000..64317dd
--- /dev/null
@@ -0,0 +1,59 @@
+;;; Gacela, a GNU Guile extension for fast games development
+;;; Copyright (C) 2009 by Javier Sancho Fernandez <jsf at jsancho dot org>
+;;;
+;;; This program is free software: you can redistribute it and/or modify
+;;; it under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation, either version 3 of the License, or
+;;; (at your option) any later version.
+;;;
+;;; This program is distributed in the hope that it will be useful,
+;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+
+(define-module (gacela math)
+  #:export (*pi*
+           degrees-to-radians
+           radians-to-degrees
+           distance-between-points
+           nearest-power-of-two))
+
+
+;;; Constants
+
+(define *pi* (* (asin 1) 2))
+
+
+;;; Geometry
+
+(define (degrees-to-radians angle)
+  (/ (* angle *pi*) 180))
+
+(define (radians-to-degrees angle)
+  (/ (* angle 180) *pi*))
+
+(define (distance-between-points p1 p2)
+  (define (add-power-of-two p1 p2)
+    (cond ((null? p1)
+          0)
+         (else
+          (+ (expt (- (car p1) (car p2)) 2)
+             (add-power-of-two (cdr p1) (cdr p2))))))
+
+  (cond ((not (= (length p1) (length p2)))
+        #f)
+       (else
+        (sqrt (add-power-of-two p1 p2)))))
+
+
+;;; Functions
+
+(define (nearest-power-of-two n)
+  (define (power p n)
+    (cond ((> (* p 2) n) p)
+         (else (power (* p 2) n))))
+  (power 1 n))
index 5c02e544708c936656a67bdf2ea7705556b2541e..8185edadc452cad38900cbbf0980e7e0acba8a5b 100644 (file)
 
 
 (define-module (gacela ttf)
-  #:use-module (gacela ftgl))
+  #:use-module (gacela ftgl)
+  #:use-module (ice-9 optargs)
+  #:export (load-font
+           render-text))
 
 (define* (load-font font-file #:key (size 40) (encoding ft_encoding_unicode))
   (let* ((key (list font-file))
diff --git a/src/widgets/timer.scm b/src/widgets/timer.scm
new file mode 100755 (executable)
index 0000000..39899f7
--- /dev/null
@@ -0,0 +1,74 @@
+;;; Gacela, a GNU Guile extension for fast games development
+;;; Copyright (C) 2009 by Javier Sancho Fernandez <jsf at jsancho dot org>
+;;;
+;;; This program is free software: you can redistribute it and/or modify
+;;; it under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation, either version 3 of the License, or
+;;; (at your option) any later version.
+;;;
+;;; This program is distributed in the hope that it will be useful,
+;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+
+(define-module (gacela widgets timer)
+  #:use-module (gacela sdl)
+  #:export (make-timer
+           start-timer
+           stop-timer
+           get-time
+           get-state
+           pause-timer
+           resume-timer))
+
+
+(define (make-timer)
+  (let ((start 0) (paused 0) (state 'stopped))
+    (lambda (op)
+      (case op
+       ((start-timer)
+        (set! start (SDL_GetTicks))
+        (set! state 'running))
+
+       ((stop-timer)
+        (set! state 'stopped))
+
+       ((get-time)
+        (cond ((eq? state 'stopped) 0)
+              ((eq? state 'paused) paused)
+              (else (- (SDL_GetTicks) start))))
+
+       ((get-state)
+        state)
+
+       ((pause-timer)
+        (cond ((eq? state 'running)
+               (set! paused (- (SDL_GetTicks) start))
+               (set! state 'paused))))
+
+       ((resume-timer)
+        (cond ((eq? state 'paused)
+               (set! start (- (SDL_GetTicks) paused))
+               (set! state 'running))))))))
+
+(define (start-timer timer)
+  (timer 'start-timer))
+
+(define (stop-timer timer)
+  (timer 'stop-timer))
+
+(define (get-time timer)
+  (timer 'get-time))
+
+(define (get-state timer)
+  (timer 'get-state))
+
+(define (pause-timer timer)
+  (timer 'pause-timer))
+
+(define (resume-timer timer)
+  (timer 'resume-timer))