comparison lisp/play/blackbox.el @ 826:e9b9a1cff2c9

*** empty log message ***
author Jim Blandy <jimb@redhat.com>
date Tue, 21 Jul 1992 04:09:28 +0000
parents e9e34745ae3b
children 213978acbc1e
comparison
equal deleted inserted replaced
825:f3eb45ffe06d 826:e9b9a1cff2c9
79 (define-key blackbox-mode-map "\C-p" 'bb-up) 79 (define-key blackbox-mode-map "\C-p" 'bb-up)
80 (define-key blackbox-mode-map "\C-n" 'bb-down) 80 (define-key blackbox-mode-map "\C-n" 'bb-down)
81 (define-key blackbox-mode-map "\C-e" 'bb-eol) 81 (define-key blackbox-mode-map "\C-e" 'bb-eol)
82 (define-key blackbox-mode-map "\C-a" 'bb-bol) 82 (define-key blackbox-mode-map "\C-a" 'bb-bol)
83 (define-key blackbox-mode-map " " 'bb-romp) 83 (define-key blackbox-mode-map " " 'bb-romp)
84 (define-key blackbox-mode-map [insert] 'bb-romp)
84 (define-key blackbox-mode-map "\C-m" 'bb-done) 85 (define-key blackbox-mode-map "\C-m" 'bb-done)
86 (define-key blackbox-mode-map [kp-enter] 'bb-done)
85 87
86 ;; This is a kluge. What we really want is a general 88 ;; This is a kluge. What we really want is a general
87 ;; feature for reminding terminal keys to the functions 89 ;; feature for reminding terminal keys to the functions
88 ;; corresponding to them in local maps 90 ;; corresponding to them in local maps.
89 (if (featurep 'keypad) 91 (mapcar (function
90 (let (keys) 92 (lambda (funk)
91 (if (setq keys (function-key-sequence ?u)) ; Up Arrow 93 (mapcar (function
92 (define-key blackbox-mode-map keys 'bb-up)) 94 (lambda (key)
93 (if (setq keys (function-key-sequence ?d)) ; Down Arrow 95 (define-key blackbox-mode-map key funk)))
94 (define-key blackbox-mode-map keys 'bb-down)) 96 (where-is-internal funk))))
95 (if (setq keys (function-key-sequence ?l)) ; Left Arrow 97 '(previous-line next-line backward-character forward-character)))
96 (define-key blackbox-mode-map keys 'bb-left))
97 (if (setq keys (function-key-sequence ?r)) ; Right Arrow
98 (define-key blackbox-mode-map keys 'bb-right))
99 (if (setq keys (function-key-sequence ?e)) ; Enter
100 (define-key blackbox-mode-map keys 'bb-done))
101 (if (setq keys (function-key-sequence ?I)) ; Insert
102 (define-key blackbox-mode-map keys 'bb-romp))
103 )))
104
105 98
106 ;; Blackbox mode is suitable only for specially formatted data. 99 ;; Blackbox mode is suitable only for specially formatted data.
107 (put 'blackbox-mode 'mode-class 'special) 100 (put 'blackbox-mode 'mode-class 'special)
108 101
109 (defun blackbox-mode () 102 (defun blackbox-mode ()
137 the hidden balls. The fewer rays you use to find the balls, the lower 130 the hidden balls. The fewer rays you use to find the balls, the lower
138 your score. 131 your score.
139 132
140 Overview of play: 133 Overview of play:
141 134
142 To play blackbox, call the function `blackbox'. An optional prefix 135 \\<blackbox-mode-map>\
143 argument specifies the number of balls to be hidden in the box; the 136 To play blackbox, type \\[blackbox]. An optional prefix argument
144 default is four. 137 specifies the number of balls to be hidden in the box; the default is
138 four.
145 139
146 The cursor can be moved around the box with the standard cursor 140 The cursor can be moved around the box with the standard cursor
147 movement keys. 141 movement keys.
148 142
149 To shoot a ray, move the cursor to the edge of the box and press SPC. 143 To shoot a ray, move the cursor to the edge of the box and press SPC.
150 The result will be determined and the playfield updated. 144 The result will be determined and the playfield updated.
151 145
152 You may place or remove balls in the box by moving the cursor into the 146 You may place or remove balls in the box by moving the cursor into the
153 box and pressing \\<bb-romp>. 147 box and pressing \\[bb-romp].
154 148
155 When you think the configuration of balls you have placed is correct, 149 When you think the configuration of balls you have placed is correct,
156 press \\<bb-done>. You will be informed whether you are correct or not, and 150 press \\[bb-done]. You will be informed whether you are correct or
157 be given your score. Your score is the number of letters and numbers 151 not, and be given your score. Your score is the number of letters and
158 around the outside of the box plus five for each incorrectly placed 152 numbers around the outside of the box plus five for each incorrectly
159 ball. If you placed any balls incorrectly, they will be indicated 153 placed ball. If you placed any balls incorrectly, they will be
160 with `x', and their actual positions indicated with `o'. 154 indicated with `x', and their actual positions indicated with `o'.
161 155
162 Details: 156 Details:
163 157
164 There are three possible outcomes for each ray you send into the box: 158 There are three possible outcomes for each ray you send into the box:
165 159
406 (t 400 (t
407 (bb-goto (car list-1)) 401 (bb-goto (car list-1))
408 (bb-update-board c) 402 (bb-update-board c)
409 (1+ (bb-show-bogus-balls-2 (cdr list-1) list-2 c))))) 403 (1+ (bb-show-bogus-balls-2 (cdr list-1) list-2 c)))))
410 404
411 ;; blackbox.el ends here 405 (defun bb-outside-box (x y)
406 (or (= x -1) (= x 8) (= y -1) (= y 8)))
412 407
413 (defun bb-goto (pos) 408 (defun bb-goto (pos)
414 (goto-char (+ (* (car pos) 2) (* (cdr pos) 22) 26))) 409 (goto-char (+ (* (car pos) 2) (* (cdr pos) 22) 26)))
415 410
416 (defun bb-update-board (c) 411 (defun bb-update-board (c)