-;;; Gacela configuration
+;;; Guile configuration
-(defun launch-gacela ()
+(defun launch-guile ()
(interactive)
- (start-process "gacela" "gacela" "/home/jsancho/proyectos/gacela/trunk/src/gacela" "--dev"))
+ (let ((process-connection-type nil))
+ (start-process "guile" "guile" "/usr/bin/guile")))
-(defun send-to-gacela ()
+(defun send-to-guile ()
(interactive)
- (cond ((not (get-process "gacela"))
- (launch-gacela)))
- (process-send-string "gacela" "(begin ")
- (cond ((use-region-p)
- (process-send-region "gacela" (region-beginning) (region-end)))
- (t
- (process-send-string "gacela" "(run-game) (hide-all-mobs)")
- (process-send-region "gacela" (point-min-marker) (point-max-marker))))
- (process-send-string "gacela" "\n)\n"))
+ (cond ((not (get-process "guile"))
+ (launch-guile)))
-(define-key global-map [(ctrl x) (ctrl g)] 'send-to-gacela)
+ (process-send-string
+ "guile"
+ (replace-regexp-in-string
+ "\t" " "
+ (cond ((use-region-p)
+ (buffer-substring-no-properties (region-beginning) (region-end)))
+ (t
+ (buffer-substring-no-properties (point-min-marker) (point-max-marker)))))))
-(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))
+
+(define-key global-map [(ctrl x) (ctrl g)] 'send-to-guile)
+
+(define-key-after global-map [menu-bar tools guile] (cons "Guile" (make-sparse-keymap "hoot hoot")) 'games)
+(define-key global-map [menu-bar tools guile send] '("Send to Guile" . send-to-guile))
+(define-key global-map [menu-bar tools guile launch] '("Launch Guile" . launch-guile))
+#!/usr/bin/guile \
+-e gacela-script -s
+!#
+
+(use-modules (gacela gacela)
+ (gacela widgets timer))
+(init-gacela)
+
(set-game-properties! #:title "Gacela Tetris" #:fps 15)
(define (tetramine-i)
(set! points (+ points (* (more-lines-better l) 10)))
(set! lines (+ lines l)))))
-(define game #f)
+(define game-func #f)
(define display-game-over #f)
(define tetramine #f)
(font (load-font "lazy.ttf" #:size 20))
(game-over #f))
- (set! game
+ (set! game-func
(lambda ()
(if game-over (display-game-over) (tetramine))))
(let ((frame 0.0) (fps (make-timer)) (update (make-timer)))
(start-timer update)
(start-timer fps)
- (run-game
- (game)
+ (game
+ (game-func)
(set! frame (+ frame 1))
(cond ((> (get-time update) 1000)
(display (/ frame (/ (get-time fps) 1000.0)))
init-gacela
quit-gacela
game-loop
+ gacela-script
game-running?
set-game-code
show-mob-hash
(game-loop)))))
(define (init-gacela)
- (set! game-loop-thread (call-with-new-thread (lambda () (game))))
+ (hide-all-mobs)
+ (set-game-code (lambda () #f))
+ (cond ((not game-loop-thread)
+ (set! game-loop-thread (call-with-new-thread (lambda () (game))))))
(while (not loop-flag))
#t)
(define (quit-gacela)
+ (hide-all-mobs)
+ (set-game-code (lambda () #f))
(set! game-loop-thread #f)
(set! loop-flag #f))
(delay-frame))))
(quit-video))
+(define (gacela-script args)
+ (while loop-flag (sleep 1)))
+
(define (game-running?)
loop-flag)