From: jsancho Date: Fri, 2 Sep 2011 07:54:51 +0000 (+0000) Subject: (no commit message) X-Git-Url: https://git.jsancho.org/?a=commitdiff_plain;h=cb2786421d0ccb887eccacaafc42ae310535cf3a;p=gacela.git --- diff --git a/games/asteroids/asteroids.scm b/games/asteroids/asteroids.scm index d684e07..c36ae05 100644 --- a/games/asteroids/asteroids.scm +++ b/games/asteroids/asteroids.scm @@ -106,6 +106,12 @@ (assoc-ref (car a) 'size)) (killed-ship? s (cdr a)))))) +(define (kill-asteroids s a) + (cond ((or (null? s) (null? a)) (values s a)) + (else + (let ((s1 (car s)) (a1 (car a))) + (cond ((or (< (sqrt (+ (expt (- (assoc-ref + (let ((asteroids #f) (ship #f) (shots #f)) (define (new-game n) (set! asteroids (make-asteroids n)) diff --git a/src/gacela_misc.scm b/src/gacela_misc.scm index a9393ca..6dd13b1 100644 --- a/src/gacela_misc.scm +++ b/src/gacela_misc.scm @@ -26,6 +26,28 @@ (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) @@ -34,12 +56,6 @@ (else (power (* p 2) n)))) (power 1 n)) -(define (degrees-to-radians angle) - (/ (* angle *pi*) 180)) - -(define (radians-to-degrees angle) - (/ (* angle 180) *pi*)) - (define-macro (pushnew elem list) `(cond ((not (find (lambda (e) (eq? e ,elem)) ,list)) (set! ,list (cons ,elem ,list)))))