Function: bubbles-plop
bubbles-plop is an interactive and byte-compiled function defined in
bubbles.el.gz.
Signature
(bubbles-plop)
Documentation
Remove active bubbles region.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/play/bubbles.el.gz
(defun bubbles-plop ()
"Remove active bubbles region."
(interactive nil bubbles-mode)
(when (and bubbles--playing
(> bubbles--neighborhood-score 0))
(setq bubbles--save-data (list bubbles--score (buffer-string)))
(let ((inhibit-read-only t))
;; blank out current neighborhood
(let ((row (bubbles--row (point)))
(col (bubbles--col (point))))
(goto-char (point-max))
(while (not (bobp))
(backward-char)
(while (get-text-property (point) 'active)
(delete-char 1)
(insert (bubbles--empty-char))
(add-text-properties (1- (point)) (point) (list 'removed t
'index -1))))
(bubbles--goto row col))
;; show new score
(bubbles--update-score)
;; update display and wait
(bubbles--update-faces-or-images)
(sit-for 0)
(sleep-for 0.2)
(discard-input)
;; drop down
(let ((something-dropped nil))
(save-excursion
(dotimes (i (bubbles--grid-height))
(dotimes (j (bubbles--grid-width))
(bubbles--goto i j)
(while (get-text-property (point) 'removed)
(setq something-dropped (or (bubbles--shift 'top i j)
something-dropped))))))
;; update display and wait
(bubbles--update-faces-or-images)
(when something-dropped
(sit-for 0)))
(discard-input)
;; shift to left
(put-text-property (point-min) (point-max) 'removed nil)
(save-excursion
(goto-char (point-min))
(let ((removed-string (format "%c" (bubbles--empty-char))))
(while (search-forward removed-string nil t)
(put-text-property (1- (point)) (point) 'removed t))))
(let ((shifted nil))
(cond ((eq (bubbles--shift-mode) 'always)
(save-excursion
(dotimes (i (bubbles--grid-height))
(dotimes (j (bubbles--grid-width))
(bubbles--goto i j)
(while (get-text-property (point) 'removed)
(setq shifted (or (bubbles--shift 'right i j)
shifted))))))
(bubbles--update-faces-or-images)
(sleep-for 0.5))
(t ;; default shift-mode
(save-excursion
(dotimes (j (bubbles--grid-width))
(bubbles--goto (1- (bubbles--grid-height)) j)
(let ((shifted-cols 0))
(while (get-text-property (point) 'removed)
(setq shifted-cols (1+ shifted-cols))
(bubbles--shift 'right (1- (bubbles--grid-height)) j))
(dotimes (_ shifted-cols)
(let ((i (- (bubbles--grid-height) 2)))
(while (>= i 0)
(setq shifted (or (bubbles--shift 'right i j)
shifted))
(setq i (1- i))))))))))
(when shifted
;;(sleep-for 0.5)
(bubbles--update-faces-or-images)
(sit-for 0)))
(put-text-property (point-min) (point-max) 'removed nil)
(unless (bubbles--neighborhood-available)
(bubbles--game-over)))
;; undo
(setq buffer-undo-list '((apply bubbles-undo . nil)))
(force-mode-line-update)
(redisplay)))