X-Git-Url: http://git.hcoop.net/bpt/emacs.git/blobdiff_plain/ac3232837188f7e1c4ffe34b76edede0ccb54f5e..51751aa26f9935609630f04e781a954b54ecc82e:/lisp/play/bubbles.el diff --git a/lisp/play/bubbles.el b/lisp/play/bubbles.el index 290a43c0a7..f2b7294e2d 100644 --- a/lisp/play/bubbles.el +++ b/lisp/play/bubbles.el @@ -1,6 +1,6 @@ -;;; bubbles.el --- Puzzle game for Emacs. +;;; bubbles.el --- Puzzle game for Emacs -;; Copyright (C) 2007, 2008 Free Software Foundation, Inc. +;; Copyright (C) 2007-2011 Free Software Foundation, Inc. ;; Author: Ulf Jasper ;; URL: http://ulf.epplejasper.de/ @@ -82,7 +82,7 @@ (defconst bubbles-version "0.5" "Version number of bubbles.el.") (require 'gamegrid) -(require 'cl) +(eval-when-compile (require 'cl)) ; for 'case ;; User options @@ -209,7 +209,7 @@ the number of colors, see `bubbles-colors'." (defcustom bubbles-shift-mode 'default "Shift mode. -Available modes are `shift-default' and`shift-always'." +Available modes are `shift-default' and `shift-always'." :type '(radio (const :tag "Default" default) (const :tag "Shifter" always) ;;(const :tag "Mega Shifter" 'mega) @@ -719,57 +719,57 @@ static char * dot3d_xpm[] = { (defsubst bubbles--grid-width () "Return the grid width for the current game theme." (car (case bubbles-game-theme - ('easy + (easy bubbles--grid-small) - ('medium + (medium bubbles--grid-medium) - ('difficult + (difficult bubbles--grid-large) - ('hard + (hard bubbles--grid-huge) - ('user-defined + (user-defined bubbles-grid-size)))) (defsubst bubbles--grid-height () "Return the grid height for the current game theme." (cdr (case bubbles-game-theme - ('easy + (easy bubbles--grid-small) - ('medium + (medium bubbles--grid-medium) - ('difficult + (difficult bubbles--grid-large) - ('hard + (hard bubbles--grid-huge) - ('user-defined + (user-defined bubbles-grid-size)))) (defsubst bubbles--colors () "Return the color list for the current game theme." (case bubbles-game-theme - ('easy + (easy bubbles--colors-2) - ('medium + (medium bubbles--colors-3) - ('difficult + (difficult bubbles--colors-4) - ('hard + (hard bubbles--colors-5) - ('user-defined + (user-defined bubbles-colors))) (defsubst bubbles--shift-mode () "Return the shift mode for the current game theme." (case bubbles-game-theme - ('easy + (easy 'default) - ('medium + (medium 'default) - ('difficult + (difficult 'always) - ('hard + (hard 'always) - ('user-defined + (user-defined bubbles-shift-mode))) (defun bubbles-save-settings () @@ -782,7 +782,7 @@ static char * dot3d_xpm[] = { (defsubst bubbles--empty-char () "The character used for removed bubbles (empty grid cells)." - ? ) + ?\s) (defun bubbles-set-graphics-theme-ascii () "Set graphics theme to `ascii'." @@ -918,24 +918,30 @@ static char * dot3d_xpm[] = { map) "Mode map for bubbles.") -(defun bubbles-mode () +(define-derived-mode bubbles-mode nil "Bubbles" "Major mode for playing bubbles. \\{bubbles-mode-map}" - (kill-all-local-variables) - (use-local-map bubbles-mode-map) - (setq major-mode 'bubbles-mode) - (setq mode-name "Bubbles") - (setq buffer-read-only t) + (setq buffer-read-only t + show-trailing-whitespace nil) (buffer-disable-undo) - (setq buffer-undo-list t) (force-mode-line-update) (redisplay) - (add-hook 'post-command-hook 'bubbles--mark-neighbourhood t t) - (run-hooks 'bubbles-mode-hook)) + (add-hook 'post-command-hook 'bubbles--mark-neighbourhood t t)) ;;;###autoload (defun bubbles () - "Play Bubbles game." + "Play Bubbles game. +\\ +The goal is to remove all bubbles with as few moves as possible. +\\[bubbles-plop] on a bubble removes that bubble and all +connected bubbles of the same color. Unsupported bubbles fall +down, and columns that do not contain any bubbles suck the +columns on its right towards the left. + +\\[bubbles-set-game-easy] sets the difficulty to easy. +\\[bubbles-set-game-medium] sets the difficulty to medium. +\\[bubbles-set-game-difficult] sets the difficulty to difficult. +\\[bubbles-set-game-hard] sets the difficulty to hard." (interactive) (switch-to-buffer (get-buffer-create "*bubbles*")) (when (or (not bubbles--playing) @@ -1154,7 +1160,7 @@ Use optional parameter POS instead of point if given." (bubbles--update-score)) (defun bubbles--update-score () - "Calculate and display new bubble score." + "Calculate and display new bubbles score." (setq bubbles--score (+ bubbles--score bubbles--neighbourhood-score)) (bubbles--show-scores)) @@ -1312,8 +1318,7 @@ Use optional parameter POS instead of point if given." Return t if new char is non-empty." (save-excursion (when (bubbles--goto row col) - (let ((char-org (char-after (point))) - (char-new (bubbles--empty-char)) + (let ((char-new (bubbles--empty-char)) (removed nil) (trow row) (tcol col) @@ -1341,11 +1346,11 @@ Return t if new char is non-empty." (when (and (display-images-p) (not (eq bubbles-graphics-theme 'ascii))) (let ((template (case bubbles-graphics-theme - ('circles bubbles--image-template-circle) - ('balls bubbles--image-template-ball) - ('squares bubbles--image-template-square) - ('diamonds bubbles--image-template-diamond) - ('emacs bubbles--image-template-emacs)))) + (circles bubbles--image-template-circle) + (balls bubbles--image-template-ball) + (squares bubbles--image-template-square) + (diamonds bubbles--image-template-diamond) + (emacs bubbles--image-template-emacs)))) (setq bubbles--empty-image (create-image (replace-regexp-in-string "^\"\\(.*\\)\t.*c .*\",$" @@ -1372,7 +1377,7 @@ Return t if new char is non-empty." (g (nth 1 crgb)) (b (nth 2 crgb)) (brightness (/ (+ r g b) 3.0 256 256)) - (val (sin (* brightness (/ pi 2)))) + (val (sin (* brightness (/ float-pi 2)))) (rr (* red val)) (gg (* green val)) (bb (* blue val)) @@ -1411,9 +1416,8 @@ Return t if new char is non-empty." (dotimes (i (bubbles--grid-height)) (dotimes (j (bubbles--grid-width)) (bubbles--goto i j) - (let* ((index (get-text-property (point) 'index)) - (face (nth index bubbles--faces)) - (fg-col (face-foreground face))) + (let ((face (nth (get-text-property (point) 'index) + bubbles--faces))) (when (get-text-property (point) 'active) (set-face-foreground 'bubbles--highlight-face "#ff0000") (setq face 'bubbles--highlight-face)) @@ -1429,8 +1433,7 @@ Return t if new char is non-empty." (save-excursion (goto-char (point-min)) (forward-line 1) - (let ((inhibit-read-only t) - char) + (let ((inhibit-read-only t)) (dotimes (i (bubbles--grid-height)) (dotimes (j (bubbles--grid-width)) (forward-char 1) @@ -1455,5 +1458,4 @@ Return t if new char is non-empty." (provide 'bubbles) -;; arch-tag: 2cd7237a-b0ad-400d-a7fd-75f676dceb70 ;;; bubbles.el ends here