-;;; bubbles.el --- Puzzle game for Emacs.
+;;; bubbles.el --- Puzzle game for Emacs -*- coding: utf-8 -*-
-;; Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+;; Copyright (C) 2007-2013 Free Software Foundation, Inc.
;; Author: Ulf Jasper <ulf.jasper@web.de>
;; URL: http://ulf.epplejasper.de/
;; Installation
;; ------------
-;; Add the following lines to your Emacs startup file (`~/.emacs').
+;; Add the following lines to your init file:
;; (add-to-list 'load-path "/path/to/bubbles/")
;; (autoload 'bubbles "bubbles" "Play Bubbles" t)
;; 0.3 (2007-03-11)
;; - Renamed shift modes and thus names of score files. All
-;; highscores are lost, unless you rename the score files from
+;; high scores are lost, unless you rename the score files from
;; bubbles-shift-... to bubbles-...!
;; - Bugfixes: Check for successful image creation.
;; Disable menus and counter when game is over.
(defconst bubbles-version "0.5" "Version number of bubbles.el.")
(require 'gamegrid)
-(eval-when-compile (require 'cl)) ; for 'case
;; User options
:group 'bubbles)
(defcustom bubbles-chars
- '(?+ ?O ?# ?X ?. ?* ?& ?§)
+ '(?+ ?O ?# ?X ?. ?* ?& ?§)
"Characters used for bubbles.
Note that the actual number of different bubbles is determined by
the number of colors, see `bubbles-colors'."
(defsubst bubbles--grid-width ()
"Return the grid width for the current game theme."
- (car (case bubbles-game-theme
- ('easy
+ (car (pcase bubbles-game-theme
+ (`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
+ (cdr (pcase bubbles-game-theme
+ (`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
+ (pcase bubbles-game-theme
+ (`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
+ (pcase bubbles-game-theme
+ (`easy
'default)
- ('medium
+ (`medium
'default)
- ('difficult
+ (`difficult
'always)
- ('hard
+ (`hard
'always)
- ('user-defined
+ (`user-defined
bubbles-shift-mode)))
(defun bubbles-save-settings ()
(define-derived-mode bubbles-mode nil "Bubbles"
"Major mode for playing bubbles.
\\{bubbles-mode-map}"
- (setq buffer-read-only t)
+ (setq buffer-read-only t
+ show-trailing-whitespace nil)
(buffer-disable-undo)
(force-mode-line-update)
(redisplay)
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)
"Prepare images for playing `bubbles'."
(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))))
+ (let ((template (pcase 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))))
(setq bubbles--empty-image
(create-image (replace-regexp-in-string
"^\"\\(.*\\)\t.*c .*\",$"
(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))
(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))
(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)
(provide 'bubbles)
-;; arch-tag: 2cd7237a-b0ad-400d-a7fd-75f676dceb70
;;; bubbles.el ends here