From a27500cab231ad3051fba783d74f77e72990bb48 Mon Sep 17 00:00:00 2001 From: jsancho Date: Sat, 17 Sep 2011 16:27:46 +0000 Subject: [PATCH] --- games/asteroids/asteroids.scm | 29 +++++++++-------------------- 1 file changed, 9 insertions(+), 20 deletions(-) diff --git a/games/asteroids/asteroids.scm b/games/asteroids/asteroids.scm index 84c0ac4..756dd73 100644 --- a/games/asteroids/asteroids.scm +++ b/games/asteroids/asteroids.scm @@ -63,31 +63,20 @@ (define (init-asteroids n) - (define (xy n m) - (let ((n2 (- (random (* (- n m) 2)) (- n m)))) - (if (> n2 0) (+ n2 m) (- n2 m)))) - (cond ((> n 0) - (let ((x (xy max-x 100)) (y (xy max-y 100)) - (angle (random 360)) (dir (- (random 360) 180))) - (show-mob (make-asteroid #:x x #:y y #:angle angle #:dir dir))) - (init-asteroids (- n 1))))) + (let ((x (- (random (* max-x 2)) max-x)) + (y (- (random (* max-y 2)) max-y))) + (cond ((< (distance-between-points (list x y) '(0 0)) 120) + (init-asteroids n)) + (else + (let ((angle (random 360)) (dir (- (random 360) 180))) + (show-mob (make-asteroid #:x x #:y y #:angle angle #:dir dir))) + (init-asteroids (- n 1)))))))) + -;(show-mob (make-asteroid)) (init-asteroids 2) (show-mob (make-ship)) -;; (define (xy n r) -;; (let ((n2 (- (random (* n 2)) n))) -;; (cond ((and (< n2 r) (>= n2 0)) r) -;; ((and (> n2 (- r)) (< n2 0)) (- r)) -;; (else n2)))) - -;; (cond ((= n 0) '()) -;; (else -;; (cons `((x . ,(xy max-x 20)) (y . ,(xy max-y 20)) (angle . 0) (vx . 1) (vy . 1) (size . 95)) -;; (make-asteroids (- n 1)))))) - ;; (define (new-game n) ;; (set! asteroids (make-asteroids n)) ;; (set! ship '((x . 0) (y . 0) (angle . 0) (moving . #f))) -- 2.39.5