+++ /dev/null
-;;; Gacela configuration
-
-(defun launch-gacela ()
- (interactive)
- (start-process "gacela" "gacela" "/home/jsancho/proyectos/gacela/trunk/src/gacela" "--dev"))
-
-(defun send-to-gacela ()
- (interactive)
- (cond ((not (get-process "gacela"))
- (launch-gacela)))
- (cond ((use-region-p)
- (process-send-region "gacela" (region-beginning) (region-end)))
- (t
- (process-send-region "gacela" (point-min-marker) (point-max-marker)))))
-
-(define-key global-map [(ctrl x) (ctrl g)] 'send-to-gacela)
-
-(define-key-after global-map [menu-bar tools gacela] (cons "Gacela" (make-sparse-keymap "hoot hoot")) 'games)
-(define-key global-map [menu-bar tools gacela send] '("Send to Gacela" . send-to-gacela))
-(define-key global-map [menu-bar tools gacela launch] '("Launch Gacela" . launch-gacela))
-
--- /dev/null
+;;; Gacela configuration
+
+(defun launch-gacela ()
+ (interactive)
+ (start-process "gacela" "gacela" "/home/jsancho/proyectos/gacela/trunk/src/gacela" "--dev"))
+
+(defun send-to-gacela ()
+ (interactive)
+ (cond ((not (get-process "gacela"))
+ (launch-gacela)))
+ (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-string "gacela" "\n"))
+
+(define-key global-map [(ctrl x) (ctrl g)] 'send-to-gacela)
+
+(define-key-after global-map [menu-bar tools gacela] (cons "Gacela" (make-sparse-keymap "hoot hoot")) 'games)
+(define-key global-map [menu-bar tools gacela send] '("Send to Gacela" . send-to-gacela))
+(define-key global-map [menu-bar tools gacela launch] '("Launch Gacela" . launch-gacela))
+
(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)))))
--- /dev/null
+(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)))