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