Function: bubbles--initialize

bubbles--initialize is a byte-compiled function defined in bubbles.el.gz.

Signature

(bubbles--initialize)

Documentation

Initialize Bubbles game.

Source Code

;; Defined in /usr/src/emacs/lisp/play/bubbles.el.gz
(defun bubbles--initialize ()
  "Initialize Bubbles game."
  (bubbles--initialize-faces)
  (bubbles--initialize-images)
  (remove-overlays)

  (switch-to-buffer (get-buffer-create "*bubbles*"))
  (bubbles--compute-offsets)
  (let ((inhibit-read-only t))
    (set-buffer-modified-p nil)
    (erase-buffer)
    (insert " ")
    (put-text-property (point-min) (point)
                       'display
                       (cons 'space (list :height
                                          (list bubbles--row-offset))))
    (insert "\n")
    (let ((max-char (length (bubbles--colors))))
      (dotimes (_ (bubbles--grid-height))
        (let ((p (point)))
          (insert " ")
          (put-text-property p (point)
                             'display
                             (cons 'space (list :width
                                                (list bubbles--col-offset)))))
        (dotimes (_ (bubbles--grid-width))
          (let* ((index (random max-char))
                 (char (nth index bubbles-chars)))
            (insert char)
            (add-text-properties (1- (point)) (point) (list 'index index))))
        (insert "\n"))
      (insert "\n ")
      (put-text-property (1- (point)) (point)
                         'display
                         (cons 'space (list :width
                                            (list bubbles--col-offset)))))
    (put-text-property (point-min) (point-max) 'pointer 'arrow))
  (bubbles-mode)
  (bubbles--reset-score)
  (bubbles--update-faces-or-images)
  (bubbles--goto 0 0)
  (setq buffer-undo-list t)
  (force-mode-line-update)
  (redisplay))