(defvar bubbles--score 0
"Current Bubbles score.")
-(defvar bubbles--neighbourhood-score 0
+(defvar bubbles--neighborhood-score 0
"Score of active bubbles neighborhood.")
(defvar bubbles--faces nil
(buffer-disable-undo)
(force-mode-line-update)
(redisplay)
- (add-hook 'post-command-hook 'bubbles--mark-neighbourhood t t))
+ (add-hook 'post-command-hook 'bubbles--mark-neighborhood t t))
;;;###autoload
(defun bubbles ()
(char-after (point))
nil)))
-(defun bubbles--mark-direct-neighbours (row col char)
+(defun bubbles--mark-direct-neighbors (row col char)
"Mark direct neighbors of bubble at ROW COL with same CHAR."
(save-excursion
(let ((count 0))
(add-text-properties (point) (1+ (point))
'(active t face 'bubbles--highlight-face))
(setq count (+ 1
- (bubbles--mark-direct-neighbours row (1+ col) char)
- (bubbles--mark-direct-neighbours row (1- col) char)
- (bubbles--mark-direct-neighbours (1+ row) col char)
- (bubbles--mark-direct-neighbours (1- row) col char))))
+ (bubbles--mark-direct-neighbors row (1+ col) char)
+ (bubbles--mark-direct-neighbors row (1- col) char)
+ (bubbles--mark-direct-neighbors (1+ row) col char)
+ (bubbles--mark-direct-neighbors (1- row) col char))))
count)))
-(defun bubbles--mark-neighbourhood (&optional pos)
+(defun bubbles--mark-neighborhood (&optional pos)
"Mark neighborhood of point.
Use optional parameter POS instead of point if given."
(when bubbles--playing
'(face default active nil))
(let ((count 0))
(when (and row col (not (eq char (bubbles--empty-char))))
- (setq count (bubbles--mark-direct-neighbours row col char))
+ (setq count (bubbles--mark-direct-neighbors row col char))
(unless (> count 1)
(add-text-properties (point-min) (point-max)
'(face default active nil))
(setq count 0)))
- (bubbles--update-neighbourhood-score count))
+ (bubbles--update-neighborhood-score count))
(put-text-property (point-min) (point-max) 'pointer 'arrow)
(bubbles--update-faces-or-images)
(sit-for 0)))))
-(defun bubbles--neighbourhood-available ()
+(defun bubbles--neighborhood-available ()
"Return t if another valid neighborhood is available."
(catch 'found
(save-excursion
(defun bubbles--reset-score ()
"Reset bubbles score."
- (setq bubbles--neighbourhood-score 0
+ (setq bubbles--neighborhood-score 0
bubbles--score 0)
(bubbles--update-score))
(defun bubbles--update-score ()
"Calculate and display new bubbles score."
- (setq bubbles--score (+ bubbles--score bubbles--neighbourhood-score))
+ (setq bubbles--score (+ bubbles--score bubbles--neighborhood-score))
(bubbles--show-scores))
-(defun bubbles--update-neighbourhood-score (size)
+(defun bubbles--update-neighborhood-score (size)
"Calculate and display score of active neighborhood from its SIZE."
(if (> size 1)
- (setq bubbles--neighbourhood-score (expt (- size 1) 2))
- (setq bubbles--neighbourhood-score 0))
+ (setq bubbles--neighborhood-score (expt (- size 1) 2))
+ (setq bubbles--neighborhood-score 0))
(bubbles--show-scores))
(defun bubbles--show-scores ()
(let ((inhibit-read-only t)
(pos (point)))
(delete-region (point) (point-max))
- (insert (format "Selected: %4d\n" bubbles--neighbourhood-score))
+ (insert (format "Selected: %4d\n" bubbles--neighborhood-score))
(insert " ")
(add-text-properties (1- (point)) (point)
(list 'intangible t 'display
"Remove active bubbles region."
(interactive)
(when (and bubbles--playing
- (> bubbles--neighbourhood-score 0))
+ (> bubbles--neighborhood-score 0))
(setq bubbles--save-data (list bubbles--score (buffer-string)))
(let ((inhibit-read-only t))
- ;; blank out current neighbourhood
+ ;; blank out current neighborhood
(let ((row (bubbles--row (point)))
(col (bubbles--col (point))))
(goto-char (point-max))
(bubbles--update-faces-or-images)
(sit-for 0)))
(put-text-property (point-min) (point-max) 'removed nil)
- (unless (bubbles--neighbourhood-available)
+ (unless (bubbles--neighborhood-available)
(bubbles--game-over)))
;; undo
(setq buffer-undo-list '((apply bubbles-undo . nil)))