1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
|
!*
* TANK MODE
*
* Drive an ASCII tank around your buffer.
* Invoke via EIQ[$SCITECOPATH]/tank.tes
*!
[tank.sprite.0] !* background *!
!* FIXME: Perhaps encode the gun's top in the integer cell *!
[tank.sprite.1]
█▓█▓
╠════○
▓█▓█
[tank.sprite.2]
█▓█▓
○════╣
▓█▓█
[tank.sprite.3]
┌┐
▓││█
█││▓
▓┴┴█
[tank.sprite.4]
█┬┬▓
▓││█
█││▓
└┘
!*
* f,tM[tank.rand] - LCG pseudo random number generator for values between f and t
* This is based on the version in the BSD libc.
*!
::U[tank.rand]
@[tank.rand]{
U.tU.f
(1103515245*Q[tank.rand]+12345) & (2^*31-1)U[tank.rand]
(Q[tank.rand]^/(Q.t-Q.f+1)+Q.f)
}
!* x,yM[tank.goto] -> success|failure *!
@[tank.goto]{
U.yU.x
Q.x"< 0 ' Q.y"< 0 '
J Q.y:L"F 0 '
Q.x<0A"< I F> ' 0A-10"= I F> ' C>
-1
}
!* x,y,spriteM[tank.blit] *!
@[tank.blit]{
U.sU.yU.x Q.xU.#x0
Q.s"N
10[tank.sprite.0] !* background *!
%[tank.blit]
'
<
%.iQ[tank.sprite.\.s]U.c Q.c:;
Q[tank.blit]&1"=
!* toggle the chain character to simulate movements *!
Q.c-█"= ▓U.c | Q.c-▓"= █U.c ' '
'
Q.c-10"=
%.y Q.#x0U.x
Q.s"N 10:[tank.sprite.0] '
|
Q.x,Q.yM[tank.goto];
Q.s"N !* not background sprite *!
Q.c- "=
!* space is "transparent" - copy background unmodified *!
0A"< I | 0A-10"= I | C ' '
-A:[tank.sprite.0]
%.x F<
'
!* "destroy" fields we have touched *!
U.d
0A"F 0A-10"N 0A- "N 33,126M[tank.rand]U.d ' ' '
Q.d:[tank.sprite.0]
'
0A"F 0A-10"N D ' ' Q.cI
%.x
'
>
}
@[tank.explode]{
!!.[explosion]*oO%.
.[explosion]✹✸✶✧·
:Q.[explosion]<
0A"F 0A-10"N D ' '
%.i-1Q.[explosion]IR
>
}
0U[tank.score]
@[tank.shoot]{
U.#dr U.yU.x
!* FIXME: Could also be encoded into a map *!
Q.#dr-1Oright,left,up,down
!right!
6-1%.x %.y
1U.#dx 0U.#dy
Oend
!left!
%.y
-U.#dx 0U.#dy
Oend
!up!
2-1%.x
0U.#dx -U.#dy
Oend
!down!
2-1%.x 3%.y
0U.#dx 1U.#dy
!* fall through *!
!end!
<
(Q.#dx%.x),(Q.#dy%.y)M[tank.goto]"F '
0A"< ' Q.#dy"= 0A-10"= ' '
0A- "N 0A-10"N 1; ' '
0A"F 0A-10"N D ' ' I●
-DI
>
M[tank.explode]
%[tank.score] SCORE: \[tank.score]
}
@[tank.selfdestruct]{
U.yU.x Q.x+2U.#cx Q.y+2U.#cy
.[explosion]✹✹✸✸✶✶✧✧·
10<
Q.#cx-10U.x 20<
Q.x-1"< %.x F> '
Q.#cy-10U.y 20<
!* d = sqrt((x - cx)^2 + ((y - cy) * aspect)^2) *!
(Q.x-Q.#cx)^*2 + ((Q.y-Q.#cy)*2)^*2 U.#d2
Q.r^*2 - Q.#d2"<
Q.#d2 - (Q.r+2)^*2"<
!* on shock wave *!
Q.x,Q.yM[tank.goto]"F %.y F> '
-D Q.rQ.[explosion]I
'
|
!* within shock wave *!
Q.x,Q.yM[tank.goto]"F %.y F> '
-D I
'
%.y>
%.x>
1
%.r>
Q.#cx,Q.#cyM[tank.goto]
}
ESGETCOLUMNU.x :-1U.y
Q.xU.#xo Q.yU.#yo
!*
* Normalize identations to spaces -- assumed by M[goto]
* FIXME: Will not work well with character representations.
*!
ESGETTABDRAWMODE-2"N
J <S^I;
ESGETCOLUMN-(-1ESGETCOLUMN)U.w
-D Q.w<I >
>
'
CONTROL: W A S D. SHOOT: SPACE. QUIT: ESCAPE. PRESS ANY KEY TO START.
ESGETCARETSTYLEU.[caretstyle]
0ESSETCARETSTYLE
1U.[sprite]
<
Q.#xo,Q.#yo,0M[tank.blit] !* redraw background *!
Q.xU.#xo Q.yU.#yo
Q.x,Q.y,Q.[sprite]M[tank.blit]
0 U.c
:Okey.U.c
F>
!key.w!
Q.y"> -%.y ' 3U.[sprite]
F>
!key.a!
Q.x,Q.y,0M[tank.blit] !* redraw background *!
Q.x"> -%.x ' 2U.[sprite]
F>
!key.s!
Q.x,Q.y,0M[tank.blit] !* redraw background *!
%.y 4U.[sprite]
F>
!key.d!
Q.x,Q.y,0M[tank.blit] !* redraw background *!
%.x 1U.[sprite]
F>
!key. !
!* FIXME: this also scrolls due to *!
Q.x,Q.y,Q.[sprite]M[tank.shoot]
F>
!key.!
Q.x,Q.yM[tank.selfdestruct]
1;
>
Q.[caretstyle]ESSETCARETSTYLE
|