(gamegrid-init): Set line-spacing to 0.
[bpt/emacs.git] / lisp / play / bubbles.el
CommitLineData
a79b55e5
TTN
1;;; bubbles.el --- Puzzle game for Emacs.
2
3;; Copyright (C) 2007 Free Software Foundation, Inc.
4
a79b55e5 5;; Author: Ulf Jasper <ulf.jasper@web.de>
a79b55e5
TTN
6;; URL: http://ulf.epplejasper.de/
7;; Created: 5. Feb. 2007
2f123a54 8;; Keywords: games
a79b55e5 9
2f123a54 10;; This file is part of GNU Emacs.
a79b55e5 11
2f123a54 12;; GNU Emacs is free software; you can redistribute it and/or modify
a79b55e5 13;; it under the terms of the GNU General Public License as published by
2f123a54
TTN
14;; the Free Software Foundation; either version 3, or (at your option)
15;; any later version.
a79b55e5 16
2f123a54
TTN
17;; GNU Emacs is distributed in the hope that it will be useful,
18;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20;; GNU General Public License for more details.
a79b55e5
TTN
21
22;; You should have received a copy of the GNU General Public License
2f123a54
TTN
23;; along with GNU Emacs; see the file COPYING. If not, write to the
24;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
25;; Boston, MA 02110-1301, USA.
a79b55e5
TTN
26
27;;; Commentary:
28
29;; Bubbles is a puzzle game. Its goal is to remove as many bubbles as
30;; possible in as few moves as possible.
31
32;; Bubbles is an implementation of the "Same Game", similar to "Same
2f123a54 33;; GNOME" and many others, see <http://en.wikipedia.org/wiki/SameGame>.
a79b55e5
TTN
34
35;; Installation
36;; ------------
37
38;; Add the following lines to your Emacs startup file (`~/.emacs').
39;; (add-to-list 'load-path "/path/to/bubbles/")
40;; (autoload 'bubbles "bubbles" "Play Bubbles" t)
41
42;; ======================================================================
43
44;;; History:
45
46;; 0.4 (2007-08-27)
47;; - Allow for undoing last move.
48;; - Bonus for removing all bubbles.
49;; - Speed improvements.
50;; - Animation enhancements.
51;; - Added `bubbles-mode-hook'.
52;; - Fixes: Don't move point.
53;; - New URL.
54
55;; 0.3 (2007-03-11)
56;; - Renamed shift modes and thus names of score files. All
57;; highscores are lost, unless you rename the score files from
58;; bubbles-shift-... to bubbles-...!
59;; - Bugfixes: Check for successful image creation.
60;; Disable menus and counter when game is over.
61;; Tested with GNU Emacs 22.0.93
62
63;; 0.2 (2007-02-24)
64;; - Introduced game themes.
65;; - Introduced graphics themes (changeable while playing).
66;; - Added menu.
67;; - Customization: grid size, colors, chars, shift mode.
68;; - More keybindings.
69;; - Changed shift direction from to-right to to-left.
70;; - Bugfixes: Don't remove single-bubble regions;
71;; Animation glitches fixed.
72;; Tested with GNU Emacs 22.0.93 and 21.4.1.
73
74;; 0.1 (2007-02-11)
75;; Initial release. Tested with GNU Emacs 22.0.93 and 21.4.1.
76
77;; ======================================================================
78
79;;; Code:
80
2f123a54
TTN
81(defconst bubbles-version "0.4" "Version number of bubbles.el.")
82
a79b55e5
TTN
83(require 'gamegrid)
84(require 'cl)
85
86;; User options
87
88;; Careful with that axe, Eugene! Order does matter in the custom
89;; section below.
90
91(defcustom bubbles-game-theme
92 'easy
93 "Overall game theme.
94The overall game theme specifies a grid size, a set of colors,
95and a shift mode."
96 :type '(radio (const :tag "Easy" easy)
97 (const :tag "Medium" medium)
98 (const :tag "Difficult" difficult)
99 (const :tag "Hard" hard)
100 (const :tag "User defined" user-defined))
101 :group 'bubbles)
102
103(defun bubbles-set-game-easy ()
104 "Set game theme to 'easy'."
105 (interactive)
106 (setq bubbles-game-theme 'easy)
107 (bubbles))
108
109(defun bubbles-set-game-medium ()
110 "Set game theme to 'medium'."
111 (interactive)
112 (setq bubbles-game-theme 'medium)
113 (bubbles))
114
115(defun bubbles-set-game-difficult ()
116 "Set game theme to 'difficult'."
117 (interactive)
118 (setq bubbles-game-theme 'difficult)
119 (bubbles))
120
121(defun bubbles-set-game-hard ()
122 "Set game theme to 'hard'."
123 (interactive)
124 (setq bubbles-game-theme 'hard)
125 (bubbles))
126
127(defun bubbles-set-game-userdefined ()
128 "Set game theme to 'user-defined'."
129 (interactive)
130 (setq bubbles-game-theme 'user-defined)
131 (bubbles))
132
133(defgroup bubbles nil
134 "Bubbles, a puzzle game."
135 :group 'games)
136
137(defcustom bubbles-graphics-theme
138 'circles
139 "Graphics theme.
140It is safe to choose a graphical theme. If Emacs cannot display
141images the `ascii' theme will be used."
142 :type '(radio (const :tag "Circles" circles)
143 (const :tag "Squares" squares)
144 (const :tag "Diamonds" diamonds)
145 (const :tag "Balls" balls)
146 (const :tag "Emacs" emacs)
147 (const :tag "ASCII (no images)" ascii))
148 :group 'bubbles)
149
150(defconst bubbles--grid-small '(10 . 10)
151 "Predefined small bubbles grid.")
152
153(defconst bubbles--grid-medium '(15 . 10)
154 "Predefined medium bubbles grid.")
155
156(defconst bubbles--grid-large '(20 . 15)
157 "Predefined large bubbles grid.")
158
159(defconst bubbles--grid-huge '(30 . 20)
160 "Predefined huge bubbles grid.")
161
162(defcustom bubbles-grid-size
163 bubbles--grid-medium
164 "Size of bubbles grid."
165 :type `(radio (const :tag "Small" ,bubbles--grid-small)
166 (const :tag "Medium" ,bubbles--grid-medium)
167 (const :tag "Large" ,bubbles--grid-large)
168 (const :tag "Huge" ,bubbles--grid-huge)
169 (cons :tag "User defined"
170 (integer :tag "Width")
171 (integer :tag "Height")))
172 :group 'bubbles)
173
174(defconst bubbles--colors-2 '("orange" "violet")
175 "Predefined bubbles color list with two colors.")
176
177(defconst bubbles--colors-3 '("lightblue" "palegreen" "pink")
178 "Predefined bubbles color list with three colors.")
179
180(defconst bubbles--colors-4 '("firebrick" "sea green" "steel blue" "chocolate")
181 "Predefined bubbles color list with four colors.")
182
183(defconst bubbles--colors-5 '("firebrick" "sea green" "steel blue"
184 "sandy brown" "bisque3")
185 "Predefined bubbles color list with five colors.")
186
187(defcustom bubbles-colors
188 bubbles--colors-3
189 "List of bubble colors.
190The length of this list determines how many different bubble
191types are present."
192 :type `(radio (const :tag "Red, darkgreen" ,bubbles--colors-2)
193 (const :tag "Red, darkgreen, blue" ,bubbles--colors-3)
194 (const :tag "Red, darkgreen, blue, orange" ,bubbles--colors-4)
195 (const :tag "Red, darkgreen, blue, orange, violet"
196 ,bubbles--colors-5)
197 (repeat :tag "User defined" color))
198 :group 'bubbles)
199
200(defcustom bubbles-chars
201