Function: pong-init-buffer

pong-init-buffer is a byte-compiled function defined in pong.el.gz.

Signature

(pong-init-buffer)

Documentation

Initialize pong buffer and draw stuff thanks to gamegrid library.

Source Code

;; Defined in /usr/src/emacs/lisp/play/pong.el.gz
(defun pong-init-buffer ()
  "Initialize pong buffer and draw stuff thanks to gamegrid library."
  (get-buffer-create pong-buffer-name)
  (switch-to-buffer pong-buffer-name)
  (use-local-map pong-mode-map)

  (setq gamegrid-use-glyphs t)
  (setq gamegrid-use-color t)
  (gamegrid-init (pong-display-options))

  (gamegrid-init-buffer pong-width
			(+ 2 pong-height)
			?\s)

  (let ((buffer-read-only nil))
    (dotimes (y pong-height)
      (dotimes (x pong-width)
        (gamegrid-set-cell x y pong-border)))
    (cl-loop for y from 1 to (- pong-height 2) do
             (cl-loop for x from 1 to (- pong-width 2) do
                      (gamegrid-set-cell x y pong-blank))))

  (cl-loop for y from pong-bat-player1
           to (1- (+ pong-bat-player1 pong-bat-width))
           do (gamegrid-set-cell 2 y pong-bat))
  (cl-loop for y from pong-bat-player2
           to (1- (+ pong-bat-player2 pong-bat-width))
           do (gamegrid-set-cell (- pong-width 3) y pong-bat)))