~crc-x/+junk/old-forthlets

« back to all changes in this revision

Viewing changes to games/console/map.retro

  • Committer: Charles Childers
  • Date: 2009-12-27 01:53:04 UTC
  • Revision ID: git-v1:4c4d472c6b93cbe5a808d9ac16031ae1f1ca55fc
use ijkl in console game demos

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
(  - ASCII graphics                                         )
6
6
(  - 16x16 map                                              )
7
7
(  - Collision Detection w/map items                        )
8
 
(  - Move using the arrow keys                              )
9
 
(                                                           )
10
 
( This version has only been tested under OS X and may need )
11
 
( changes to the key handlers to work on other OSes.        )
 
8
(  - Move using ijkl keys                                   )
12
9
( ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ )
13
10
( Distributed under the Creative Commons Zero License:      )
14
11
(                                                           )
111
108
 
112
109
( ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ )
113
110
( Handle various keys                                       )
114
 
( For arrow keys:                                           )
115
 
(   OS X returns three values: 27 91 key, we use isArrow?   )
116
 
(   to eat the first two and then deal with the last one.   )
117
111
( ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ )
118
 
: up?      k @  65 =if rst 1 ly -! then ;
119
 
: down?    k @  66 =if rst 1 ly +! then ;
120
 
: left?    k @  67 =if rst 1 lx +! then ;
121
 
: right?   k @  68 =if rst 1 lx -! then ;
122
 
: isArrow? k @  27 =if kx kx up? down? left? right? then ;
123
 
: quit?    k @ 113 =if bye then ;
 
112
: up?      k @  char: i =if rst 1 ly -! then ;
 
113
: down?    k @  char: k =if rst 1 ly +! then ;
 
114
: left?    k @  char: j =if rst 1 lx -! then ;
 
115
: right?   k @  char: l =if rst 1 lx +! then ;
 
116
: isArrow? up? down? left? right? ;
 
117
: quit?    k @ char: q =if bye then ;
124
118
 
125
119
: get-input kx isArrow? quit? ;
126
120