%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/local/share/emacs/27.2/lisp/play/
Upload File :
Create Path :
Current File : //usr/local/share/emacs/27.2/lisp/play/pong.elc

;ELC
;;; Compiled
;;; in Emacs version 27.2
;;; with all optimizations.

;;; This file uses dynamic docstrings, first added in Emacs 19.29.

;;; This file does not contain utf-8 non-ASCII characters,
;;; and so can be loaded in Emacs versions earlier than 23.

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


(byte-code "\300\301!\210\302\303\304\305\306\307\310\311&\210\312\313\314\315\310\303\316\317&\210\312\320\321\322\310\303\316\323&\210\312\324\325\326\310\303\316\327&\210\312\330\331\332\310\303\316\333&\210\312\334\335\336\310\303\316\337&\210\312\340\341\342\310\303\316\337&\210\312\343\344\345\310\303\316\337&\210\312\346\347\350\310\303\316\337&\210\312\351\352\353\310\303\316\354&\210\312\355\356\357\310\303\316\360&\210\312\361\362\363\310\303\316\364&\210\312\365\366\367\310\303\316\370&\210\312\371\372\373\310\303\316\374&\210\312\375\376\377\310\303\316\201@&\210\312\201A\376\201B\310\303\316\201C&\210\312\201D\201E\201F\310\303\316\201G&\207" [require gamegrid custom-declare-group pong nil "Emacs-Lisp implementation of the classical game pong." :tag "Pong" :group games custom-declare-variable pong-buffer-name "*Pong*" "Name of the buffer used to play." :type (string) pong-width 50 "Width of the playfield." (integer) pong-height (min 30 (- (frame-height) 6)) "Height of the playfield." (integer) pong-bat-width 3 "Width of the bats for pong." (integer) pong-blank-color "black" "Color used for background." color pong-bat-color "yellow" "Color used for bats." pong-ball-color "red" "Color used for the ball." pong-border-color "white" "Color used for pong borders." pong-left-key "4" "Alternate key to press for bat 1 to go up (primary one is [left])." (restricted-sexp :match-alternatives (stringp vectorp)) pong-right-key "6" "Alternate key to press for bat 1 to go down (primary one is [right])." (restricted-sexp :match-alternatives (stringp vectorp)) pong-up-key "8" "Alternate key to press for bat 2 to go up (primary one is [up])." (restricted-sexp :match-alternatives (stringp vectorp)) pong-down-key "2" "Alternate key to press for bat 2 to go down (primary one is [down])." (restricted-sexp :match-alternatives (stringp vectorp)) pong-quit-key "q" "Key to press to quit pong." (restricted-sexp :match-alternatives (stringp vectorp)) pong-pause-key "p" "Key to press to pause pong." (restricted-sexp :match-alternatives (stringp vectorp)) pong-resume-key "Key to press to resume pong." (restricted-sexp :match-alternatives (stringp vectorp)) pong-timer-delay 0.1 "Time to wait between every cycle." number] 8)
(defvar pong-blank-options '(((glyph colorize) (t 32)) ((color-x color-x) (mono-x grid-x) (color-tty color-tty)) (((glyph color-x) [0 0 0]) (color-tty pong-blank-color))))
(defvar pong-bat-options '(((glyph colorize) (emacs-tty 79) (t 32)) ((color-x color-x) (mono-x mono-x) (color-tty color-tty) (mono-tty mono-tty)) (((glyph color-x) [1 1 0]) (color-tty pong-bat-color))))
(defvar pong-ball-options '(((glyph colorize) (t 42)) ((color-x color-x) (mono-x grid-x) (color-tty color-tty)) (((glyph color-x) [1 0 0]) (color-tty pong-ball-color))))
(defvar pong-border-options '(((glyph colorize) (t 43)) ((color-x color-x) (mono-x grid-x) (color-tty color-tty)) (((glyph color-x) [0.5 0.5 0.5]) (color-tty pong-border-color))))
(defconst pong-blank 0)
(defconst pong-bat 1)
(defconst pong-ball 2)
(defconst pong-border 3)
#@31 Horizontal speed of the ball.
(defvar pong-xx nil (#$ . 3497))
#@29 Vertical speed of the ball.
(defvar pong-yy nil (#$ . 3566))
#@34 Horizontal position of the ball.
(defvar pong-x nil (#$ . 3633))
#@32 Vertical position of the ball.
(defvar pong-y nil (#$ . 3704))
#@29 Vertical position of bat 1.
(defvar pong-bat-player1 nil (#$ . 3773))
#@29 Vertical position of bat 2.
(defvar pong-bat-player2 nil (#$ . 3849))
(defvar pong-score-player1 nil)
(defvar pong-score-player2 nil)
#@24 Modemap for pong-mode.
(defvar pong-mode-map (byte-code "\306\307!\310\311\312#\210\310\313\314#\210\310\315\316#\210\310\317\320#\210\310	\312#\210\310\n\314#\210\310\316#\210\310\f\320#\210\310
\321#\210\310\322#\210)\207" [map pong-left-key pong-right-key pong-up-key pong-down-key pong-quit-key make-sparse-keymap pong-mode-map define-key [left] pong-move-left [right] pong-move-right [up] pong-move-up [down] pong-move-down pong-quit pong-pause pong-pause-key] 4) (#$ . 3989))
#@25 Null map for pong-mode.
(defvar pong-null-map (make-sparse-keymap 'pong-null-map) (#$ . 4492))
#@61 Computes display options (required by gamegrid for colors).
(defalias 'pong-display-options #[nil "\306\307\310\"\307\311	\nW\203H	\211U\203\f\202?	
U\203&\202?	\fU\2032
\202?	U\203>\202?\312I\210	T\211\202\n*)\207" [options c --dotimes-limit-- pong-blank pong-blank-options pong-bat make-vector 256 nil 0 (nil nil nil) pong-bat-options pong-ball pong-ball-options pong-border pong-border-options] 5 (#$ . 4593)])
#@67 Initialize pong buffer and draw stuff thanks to gamegrid library.
(defalias 'pong-init-buffer #[nil "\306!\210\307!\210\310	!\210\311\211\312\313 !\210\314\f\315
\\\316#\210\317
\320W\203X\f\320W\203N\321#\210T\211\2026*T\211\202(*\322
\315ZX\203\225\322\f\315ZX\203\213\321#\210T\211\202s*T\211\202c+\\SX\203\273\321\315#\210T\211\202\244*  \\S!!X\203\343\321\f\323Z#\210T\211\202\312*\317\207" [pong-buffer-name pong-mode-map gamegrid-use-glyphs gamegrid-use-color pong-width pong-height get-buffer-create switch-to-buffer use-local-map t gamegrid-init pong-display-options gamegrid-init-buffer 2 32 nil 0 gamegrid-set-cell 1 3 buffer-read-only y --dotimes-limit-- x pong-border #1=#:--cl-var-- #2=#:--cl-var-- pong-blank pong-bat-player1 pong-bat-width #3=#:--cl-var-- pong-bat pong-bat-player2 #4=#:--cl-var--] 5 (#$ . 5039) nil])
#@128 Move bat 1 up.
This is called left for historical reasons, since in some pong
implementations you move with left/right paddle.
(defalias 'pong-move-left #[nil "\301V\205S\211\205\302\303\"\207" [pong-bat-player1 1 pong-update-bat 2] 3 (#$ . 5999) nil])
#@18 Move bat 1 down.
(defalias 'pong-move-right #[nil "	\\\nSW\205T\211\205\303\304\"\207" [pong-bat-player1 pong-bat-width pong-height pong-update-bat 2] 3 (#$ . 6266) nil])
#@16 Move bat 2 up.
(defalias 'pong-move-up #[nil "\302V\205S\211\205\303	\304Z\"\207" [pong-bat-player2 pong-width 1 pong-update-bat 3] 3 (#$ . 6451) nil])
#@18 Move bat 2 down.
(defalias 'pong-move-down #[nil "	\\\nSW\205T\211\205\304\305Z\"\207" [pong-bat-player2 pong-bat-width pong-height pong-width pong-update-bat 3] 3 (#$ . 6617) nil])
#@70 Move a bat (suppress a cell and draw another one on the other side).
(defalias 'pong-update-bat #[(x y) "\306p!\230\2055\307	\n#\210\307	\n\f\\S#\210\n\310V\203$\307	\nS
#\210\n\f\\	SW\2055\307	\n\f\\
#\207" [pong-buffer-name x y pong-bat pong-bat-width pong-blank buffer-name gamegrid-set-cell 1 pong-height] 4 (#$ . 6814)])
#@20 Initialize a game.
(defalias 'pong-init #[nil "\306	\307#\210\310\311\312\313\314$\210\nZ\315\245T\211\316\317\315\245\n\315\245\320 \210\321 \210\322\323\"\210\324 \207" [pong-mode-map pong-pause-key pong-height pong-bat-width pong-bat-player1 pong-bat-player2 define-key pong-pause add-hook kill-buffer-hook pong-quit nil t 2 -1 0 pong-init-buffer gamegrid-kill-timer gamegrid-start-timer pong-update-game pong-update-score pong-xx pong-yy pong-width pong-x pong-y pong-timer-delay] 6 (#$ . 7153)])
#@181 "Main" function for pong.
It is called every pong-cycle-delay seconds and
updates ball and bats positions.  It is responsible of collision
detection and checks if a player scores.
(defalias 'pong-update-game #[(pong-buffer) "p=\204	\306 \207	\n\307V\203H
SW\203H\f\310U\203'\307W\2047\f\311ZU\203A\307V\203A\312\f#\210\202H\312\f#\210	\\\n\\\307X\203`[\313\202\216\n\\
SY\203v[
\310Z\202\216\n\\\211\313X\204\211\n
\310ZY\203\216[\n\307V\203\242\n
SW\203\242\312	\n#\210	\311U\204\256	\310U\203\354\307V\203\354\nY\203\354\n\\W\203\354\nU\203\323\314\202\340\nTU\203\337\307\202\340\313\\[\211\202[	\315ZU\204\376	\311ZU\203<\307W\203<\nY\203<\n\\W\203<\nU\203#\314\2020\nTU\203/\307\2020\313\\[\211\202[	\313W\203LT\316 \202[	SY\205[T\316 *\207" [pong-buffer pong-x pong-y old-y old-x pong-height pong-pause 0 2 3 gamegrid-set-cell 1 -1 4 pong-init pong-xx pong-width pong-bat pong-blank pong-yy pong-ball pong-bat-player1 pong-bat-width pong-bat-player2 pong-score-player2 pong-score-player1] 5 (#$ . 7677)])
#@55 Update score and print it on bottom of the game grid.
(defalias 'pong-update-score #[nil "\306\307	#\211G\211\310\f
W\205,\311p!\230\203%\312\f\f\n\fH#\210\fT\211\202,\207" [pong-score-player1 pong-score-player2 string len x --dotimes-limit-- format "Score:  %d / %d" 0 buffer-name gamegrid-set-cell pong-buffer-name pong-height] 6 (#$ . 8830)])
#@17 Pause the game.
(defalias 'pong-pause #[nil "\302 \210\303\304!\210\305	\306#\207" [pong-mode-map pong-resume-key gamegrid-kill-timer cancel-function-timers pong-update-game define-key pong-resume] 4 (#$ . 9195) nil])
#@23 Resume a paused game.
(defalias 'pong-resume #[nil "\303	\304#\210\305\n\306\"\207" [pong-mode-map pong-pause-key pong-timer-delay define-key pong-pause gamegrid-start-timer pong-update-game] 4 (#$ . 9420) nil])
#@41 Quit the game and kill the pong buffer.
(defalias 'pong-quit #[nil "\302 \210\303\304\305	$\207" [pong-timer-delay pong-buffer-name gamegrid-kill-timer run-with-timer nil kill-buffer] 5 (#$ . 9639) nil])
#@209 Play pong and waste time.
This is an implementation of the classical game pong.
Move left and right bats and try to bounce the ball to your opponent.

pong-mode keybindings:\<pong-mode-map>

\{pong-mode-map}
(defalias 'pong #[nil "\302\211\303 \207" [pong-score-player1 pong-score-player2 0 pong-init] 2 (#$ . 9851) nil])
(provide 'pong)

Zerion Mini Shell 1.0