~crc-x/+junk/old-forthlets

« back to all changes in this revision

Viewing changes to games/console/maze.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 the ijkl keys                               )
12
9
( ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ )
13
10
( Distributed under the Creative Commons Zero License:      )
14
11
(                                                           )
116
113
 
117
114
( ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ )
118
115
( Handle various keys                                       )
119
 
( For arrow keys:                                           )
120
 
(   OS X returns three values: 27 91 key, we use isArrow?   )
121
 
(   to eat the first two and then deal with the last one.   )
122
116
( ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ )
123
 
: up?      k @  65 =if rst 1 ly -! then ;
124
 
: down?    k @  66 =if rst 1 ly +! then ;
125
 
: left?    k @  67 =if rst 1 lx +! then ;
126
 
: right?   k @  68 =if rst 1 lx -! then ;
127
 
: isArrow? k @  27 =if kx kx up? down? left? right? then ;
128
 
: quit?    k @ 113 =if bye then ;
 
117
: up?      k @  char: i =if rst 1 ly -! then ;
 
118
: down?    k @  char: k =if rst 1 ly +! then ;
 
119
: left?    k @  char: j =if rst 1 lx -! then ;
 
120
: right?   k @  char: l =if rst 1 lx +! then ;
 
121
: isArrow? up? down? left? right? ;
 
122
: quit?    k @ char: q =if bye then ;
129
123
 
130
124
: get-input kx isArrow? quit? ;
131
125
 
134
128
( Main Game Loop                                            )
135
129
( ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ )
136
130
: play get 0 0 put repeat display get-input wall? end? put update again ;
137
 
' play is boot
138
 
save bye