MMCT TEAM
Server IP : 111.118.215.189  /  Your IP : 3.128.31.200
Web Server : Apache
System : Linux md-in-83.webhostbox.net 4.19.286-203.ELK.el7.x86_64 #1 SMP Wed Jun 14 04:33:55 CDT 2023 x86_64
User : a1673wkz ( 2475)
PHP Version : 8.2.25
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON
Directory (0755) :  /usr/share/emacs/24.3/lisp/play/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : //usr/share/emacs/24.3/lisp/play/snake.elc
;ELC
;;; Compiled by mockbuild@buildfarm06-new.corp.cloudlinux.com on Fri Oct 11 10:06:37 2024
;;; from file /builddir/build/BUILD/emacs-24.3/lisp/play/snake.el
;;; in Emacs version 24.3.1
;;; 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.

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


(require 'gamegrid)
#@42 Non-nil means use glyphs when available.
(defvar snake-use-glyphs-flag t (#$ . 573))
#@41 Non-nil means use color when available.
(defvar snake-use-color-flag t (#$ . 664))
#@29 Name used for Snake buffer.
(defvar snake-buffer-name "*Snake*" (#$ . 753))
#@34 Width of used portion of buffer.
(defvar snake-buffer-width 30 (#$ . 835))
#@35 Height of used portion of buffer.
(defvar snake-buffer-height 22 (#$ . 916))
#@24 Width of playing area.
(defvar snake-width 30 (#$ . 999))
#@25 Height of playing area.
(defvar snake-height 20 (#$ . 1063))
#@26 Initial length of snake.
(defvar snake-initial-length 5 (#$ . 1130))
#@30 Initial X position of snake.
(defvar snake-initial-x 10 (#$ . 1205))
#@30 Initial Y position of snake.
(defvar snake-initial-y 10 (#$ . 1280))
#@30 Initial X velocity of snake.
(defvar snake-initial-velocity-x 1 (#$ . 1355))
#@30 Initial Y velocity of snake.
(defvar snake-initial-velocity-y 0 (#$ . 1438))
#@61 The default time taken for the snake to advance one square.
(defvar snake-tick-period 0.2 (#$ . 1521))
#@31 Hook run upon starting Snake.
(defvar snake-mode-hook nil (#$ . 1630))
#@22 X position of score.
(defvar snake-score-x 0 (#$ . 1707))
#@22 Y position of score.
(defvar snake-score-y snake-height (#$ . 1771))
#@31 File for holding high scores.
(defvar snake-score-file "snake-scores" (#$ . 1846))
(defvar snake-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 "black"))))
(defvar snake-snake-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 "yellow"))))
(defvar snake-dot-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 "red"))))
(defvar snake-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 "white"))))
(defvar snake-space-options '(((t 32)) nil nil))
(defconst snake-blank 0)
(defconst snake-snake 1)
(defconst snake-dot 2)
(defconst snake-border 3)
(defconst snake-space 4)
(defvar snake-length 0)
(defvar snake-velocity-x 1)
(defvar snake-velocity-y 0)
(defvar snake-positions nil)
(defvar snake-cycle 0)
(defvar snake-score 0)
(defvar snake-paused nil)
(defvar snake-moved-p nil)
#@475 This queue stores the velocities requested too quickly by user.
They will take effect one at a time at each clock-interval.
This is necessary for proper behavior.

For instance, if you are moving right, you press up and then left, you
want the snake to move up just once before starting to move left.  If
we implemented all your keystrokes immediately, the snake would
effectively never move up.  Thus, we need to move it up for one turn
and then start moving it leftwards.
(defvar snake-velocity-queue nil (#$ . 3012))
(byte-code "\300\301!\210\300\302!\210\300\303!\210\300\304!\210\300\305!\210\300\306!\210\300\307!\210\300\310!\210\300\311!\207" [make-variable-buffer-local snake-length snake-velocity-x snake-velocity-y snake-positions snake-cycle snake-score snake-paused snake-moved-p snake-velocity-queue] 2)
(defvar snake-mode-map (byte-code "\301\302!\303\304\305#\210\303\306\307#\210\303\310\311#\210\303\312\313#\210\303\314\315#\210\303\316\317#\210\303\320\321#\210)\207" [map make-sparse-keymap snake-mode-map define-key "n" snake-start-game "q" snake-end-game "p" snake-pause-game [left] snake-move-left [right] snake-move-right [up] snake-move-up [down] snake-move-down] 4))
(defvar snake-null-map (byte-code "\301\302!\303\304\305#\210)\207" [map make-sparse-keymap snake-null-map define-key "n" snake-start-game] 4))
(defalias 'snake-display-options #[nil "\306\307\310\"\307\311	\nW\203T	\211U\203\f\202K	
U\203&\202K	\fU\2032
\202K	U\203>\202K	U\203J\202K\312I\210	T\211\202\n*)\207" [options c --dotimes-limit-- snake-blank snake-blank-options snake-snake make-vector 256 nil 0 (nil nil nil) snake-snake-options snake-dot snake-dot-options snake-border snake-border-options snake-space snake-space-options] 5])
(defalias 'snake-update-score #[nil "\306\307\"\211G\211\310\fW\205$\311
\\\n	H#\210T\211\202
,\207" [snake-score string len x --dotimes-limit-- snake-score-x format "Score:  %05d" 0 gamegrid-set-cell snake-score-y] 6])
(defalias 'snake-init-buffer #[nil "\306	\n#\210\307\f\310\f
\fW\203<
\310\f\fW\2034\311
#\210T\211\202*
T\211\202*\312\f\313Z
X\203u\312
\313ZX\203m\311
#\210T\211\202V*
T\211\202E+\307\207" [snake-buffer-width snake-buffer-height snake-space buffer-read-only snake-height y gamegrid-init-buffer nil 0 gamegrid-set-cell 1 2 --dotimes-limit-- snake-width x snake-border #1=#:--cl-var-- #2=#:--cl-var-- snake-blank] 5])
(defalias 'snake-reset-game #[nil "\306 \210\307 \210\n\f\310\311\312\310\211\310	\312W\203]\313#\210\314\"B\\
\\T\211\202.,\315 \207" [snake-initial-length snake-length snake-initial-velocity-x snake-velocity-x snake-initial-velocity-y snake-velocity-y gamegrid-kill-timer snake-init-buffer nil 1 0 gamegrid-set-cell vector snake-update-score snake-positions snake-cycle snake-score snake-paused snake-moved-p snake-velocity-queue snake-initial-x snake-initial-y y x i --dotimes-limit-- snake-snake] 5])
#@131 Called on each clock tick.
Advances the snake one square, testing for collision.
Argument SNAKE-BUFFER is the name of the buffer.
(defalias 'snake-update-game #[(snake-buffer) "?\205\244p	=\205\244\306 \210\n@\211\307H\f\\\310H\\\311
\"\211U\2045U\203:\312 \202\243U\203RTT\313 \210\202\217\314Z\n\233\211\211A@)\211\307H\310H\315\316\246\307U\203\200\202\202#\210T\317\241\210,\315
#\210\320
\"\nB\317\211,\207" [snake-paused snake-buffer snake-positions pos snake-velocity-x x snake-update-velocity 0 1 gamegrid-get-cell snake-end-game snake-update-score 2 gamegrid-set-cell 5 nil vector snake-velocity-y y c snake-border snake-snake snake-dot snake-length snake-score last-cons tail-pos x0 y0 snake-cycle snake-blank snake-moved-p] 6 (#$ . 6070)])
(defalias 'snake-update-velocity #[nil "?\205!	\203\306	!@\211@\n\211A@)	\237A\237)\307\211\207" [snake-moved-p snake-velocity-queue new-vel snake-velocity-x x snake-velocity-y last t] 3])
(defalias 'snake-final-x-velocity #[nil "\211@@)\206\n\n\207" [snake-velocity-queue x snake-velocity-x] 2])
(defalias 'snake-final-y-velocity #[nil "@\211A@)\206\n\207" [snake-velocity-queue x snake-velocity-y] 2])
#@27 Make the snake move left.
(defalias 'snake-move-left #[nil "\301\302 !\205\f\303B\211\207" [snake-velocity-queue zerop snake-final-x-velocity (-1 0)] 2 (#$ . 7325) nil])
#@28 Make the snake move right.
(defalias 'snake-move-right #[nil "\301\302 !\205\f\303B\211\207" [snake-velocity-queue zerop snake-final-x-velocity (1 0)] 2 (#$ . 7504) nil])
#@25 Make the snake move up.
(defalias 'snake-move-up #[nil "\301\302 !\205\f\303B\211\207" [snake-velocity-queue zerop snake-final-y-velocity (0 -1)] 2 (#$ . 7684) nil])
#@27 Make the snake move down.
(defalias 'snake-move-down #[nil "\301\302 !\205\f\303B\211\207" [snake-velocity-queue zerop snake-final-y-velocity (0 1)] 2 (#$ . 7859) nil])
#@29 Terminate the current game.
(defalias 'snake-end-game #[nil "\303 \210\304!\210\305	\n\"\207" [snake-null-map snake-score-file snake-score gamegrid-kill-timer use-local-map gamegrid-add-score] 3 (#$ . 8037) nil])
#@28 Start a new game of Snake.
(defalias 'snake-start-game #[nil "\302 \210\303!\210\304	\305\"\207" [snake-mode-map snake-tick-period snake-reset-game use-local-map gamegrid-start-timer snake-update-game] 3 (#$ . 8257) nil])
#@37 Pause (or resume) the current game.
(defalias 'snake-pause-game #[nil "?\301\205	\302!\207" [snake-paused message "Game paused (press p to resume)"] 2 (#$ . 8486) nil])
(defalias 'snake-active-p #[nil "\301 =\207" [snake-mode-map current-local-map] 2])
(put 'snake-mode 'mode-class 'special)
#@74 A mode for playing Snake.

Snake mode keybindings:
   \{snake-mode-map}

(defalias 'snake-mode #[nil "\306 \210\307\310\311\312\313$\210\314!\210\315\316
\317\320 !\210\321\322!\207" [snake-null-map major-mode mode-name snake-use-glyphs-flag gamegrid-use-glyphs snake-use-color-flag kill-all-local-variables add-hook kill-buffer-hook gamegrid-kill-timer nil t use-local-map snake-mode "Snake" gamegrid-init snake-display-options run-mode-hooks snake-mode-hook gamegrid-use-color] 5 (#$ . 8789)])
#@515 Play the Snake game.
Move the snake around without colliding with its tail or with the border.

Eating dots causes the snake to get longer.

Snake mode keybindings:
   \<snake-mode-map>
\[snake-start-game]	Starts a new game of Snake
\[snake-end-game]	Terminates the current game
\[snake-pause-game]	Pauses (or resumes) the current game
\[snake-move-left]	Makes the snake move left
\[snake-move-right]	Makes the snake move right
\[snake-move-up]	Makes the snake move up
\[snake-move-down]	Makes the snake move down
(defalias 'snake #[nil "\301!\210\302 \210\303 \210\304 \207" [snake-buffer-name switch-to-buffer gamegrid-kill-timer snake-mode snake-start-game] 2 (#$ . 9299) nil])
(provide 'snake)

MMCT - 2023