From 61cbb86694ce19f0d5dd44ccf847c9fbd61b8f7e Mon Sep 17 00:00:00 2001 From: jsancho Date: Fri, 26 Aug 2011 07:04:56 +0000 Subject: [PATCH] --- emacs/{emacs.conf => emacs_conf.lisp} | 3 ++- gacela_tetris.scm | 21 ++++++++++----------- games/asteroids/asteroids.scm | 23 +++++++++++++++++++++++ 3 files changed, 35 insertions(+), 12 deletions(-) rename emacs/{emacs.conf => emacs_conf.lisp} (94%) create mode 100644 games/asteroids/asteroids.scm diff --git a/emacs/emacs.conf b/emacs/emacs_conf.lisp similarity index 94% rename from emacs/emacs.conf rename to emacs/emacs_conf.lisp index 65645a5..296c467 100644 --- a/emacs/emacs.conf +++ b/emacs/emacs_conf.lisp @@ -11,7 +11,8 @@ (cond ((use-region-p) (process-send-region "gacela" (region-beginning) (region-end))) (t - (process-send-region "gacela" (point-min-marker) (point-max-marker))))) + (process-send-region "gacela" (point-min-marker) (point-max-marker)))) + (process-send-string "gacela" "\n")) (define-key global-map [(ctrl x) (ctrl g)] 'send-to-gacela) diff --git a/gacela_tetris.scm b/gacela_tetris.scm index 63e0fc7..d27a086 100644 --- a/gacela_tetris.scm +++ b/gacela_tetris.scm @@ -180,14 +180,13 @@ (translate 0 -30) (render-text (format #f "Lines: ~a" (get-lines)) font)))) -(define (run-gacela-tetris) - (let ((frame 0.0) (fps (make-timer)) (update (make-timer))) - (start-timer update) - (start-timer fps) - (run-game - (game) - (set! frame (+ frame 1)) - (cond ((> (get-time update) 1000) - (display (/ frame (/ (get-time fps) 1000.0))) - (newline) - (start-timer update)))))) +(let ((frame 0.0) (fps (make-timer)) (update (make-timer))) + (start-timer update) + (start-timer fps) + (run-game + (game) + (set! frame (+ frame 1)) + (cond ((> (get-time update) 1000) + (display (/ frame (/ (get-time fps) 1000.0))) + (newline) + (start-timer update))))) diff --git a/games/asteroids/asteroids.scm b/games/asteroids/asteroids.scm new file mode 100644 index 0000000..a1e23f6 --- /dev/null +++ b/games/asteroids/asteroids.scm @@ -0,0 +1,23 @@ +(set-game-properties! #:title "Gacela Asteroids") + +(define draw-asteroid + (let ((asteroid (load-texture "Asteroid.png"))) + (lambda (a) + (to-origin) + (translate (car a) (cadr a)) + (draw-texture asteroid)))) + +(define (move-asteroid a) + (let* ((x (car a)) (y (cadr a)) + (vx (caddr a)) (vy (cadddr a)) + (nx (+ x vx)) (ny (+ y vy))) + (cond ((> nx 320) (set! vx -1)) + ((< nx -320) (set! vx 1))) + (cond ((> ny 240) (set! vy -1)) + ((< ny -240) (set! vy 1))) + (list (+ x vx) (+ y vy) vx vy))) + +(let ((asteroids '((100 100 1 1) (-100 -100 -1 1)))) + (run-game + (set! asteroids (map move-asteroid asteroids)) + (for-each draw-asteroid asteroids))) -- 2.39.2