source: abuse/trunk/data-frabs/lisp/input.lsp @ 581

Last change on this file since 581 was 44, checked in by Sam Hocevar, 12 years ago
  • Importing abuse-frabs 2.10.
File size: 2.6 KB
Line 
1;; Copyright 1995 Crack dot Com,  All Rights reserved
2;; See licensing information for more details on usage rights
3;;(setf player1 'joystick)
4
5
6;; note : this function is called by the game when it collects input from
7;; the local player (the machine you are playing on in net games)
8;; because it is only executed locally it should not change any global varible
9;; Also the rest of the game should not use any input gathering routines such as
10;; joy_stat & key_presed.
11
12;;  The returned input from this routine is passed on to the server where it is
13;; distributed to other clients.
14;; The format for return is '(xv yv B1 B2 B3 mx my)
15
16;; xv = movement left right (-1=left, 0=none, 1=right)
17;; yv = movement up and down (-1=up,  0=none, 1=right)
18;; B1 = using special power (T or nil)
19;; B2 = firing button (T or nil)
20;; B3 = toggle to weapons (-1 toggle weapons to the left, 0=no toggle, 1 toggle to the right)
21;; mx = mouse x position on the screen
22;; my = mouse y position on the screen
23
24;; other possible key names for get_key_code include :
25;;   "Up_Arrow","Down_Arrow","Left_Arrow","Right_Arrow",
26;;   "Left_Ctrl","Right_Ctrl","Left_Alt","Right_Alt",
27;;   "Left_Shift","Right_Shift","Caps_Lock","Num_Lock",
28;;   "Home","End","Del","F1","F2","F3","F4","F5","F6",
29;;   "F7","F8","F9","F10","Insert"
30;;   "a", "b", "c", ...
31;; though not all of these keys will work on all operating systems
32
33
34;; note : at this current time weapon toggle input is ignored and
35;; CTRL & INS are used... sorry :)  These have to be event based,
36;; not polled so no key pressed are missed.
37
38(setq left-key          (get_key_code "left_arrow"))
39(setq right-key         (get_key_code "right_arrow"))
40(setq up-key            (get_key_code "up_arrow"))
41(setq down-key          (get_key_code "down_arrow"))
42(setq weapon-left-key   (get_key_code "right_ctrl"))
43(setq weapon-right-key  (get_key_code "insert"))
44
45
46(defun get_local_input ()
47  (let ((mstat (mouse_stat)))
48    (list (if (local_key_pressed left-key) -1 (if (local_key_pressed right-key) 1 0))  ;; xv
49          (if (local_key_pressed up-key) -1   (if (local_key_pressed down-key)  1 0))  ;; yv
50          (eq (fourth mstat) 1)                                            ;; special button
51          (eq (third mstat) 1)                                             ;; fire button
52         
53          (if (or (eq (fifth mstat) 1)
54                  (local_key_pressed weapon-left-key)) -1                             ;; weapon toggle
55              (if (local_key_pressed weapon-right-key)  1 0))
56          (first mstat)                                                    ;; mx
57          (second mstat)                                                   ;; my
58          )))
59
60
61       
62
63       
64
65
66
Note: See TracBrowser for help on using the repository browser.