Handbook
Glossary
pong-gadget
Vocabulary
pong
Definition
USING:
ui.gadgets
;
IN:
pong
TUPLE:
pong-gadget
<
gadget
timer ball player computer game-over?
;
Methods
USING:
accessors
arrays
colors
kernel
math
opengl
pong
ranges
sequences
ui.render
ui.text
;
M::
pong-gadget
draw-gadget*
( PONG -- )
COLOR:
gray80
gl-color
15 390 20
<range>
[
197
2array
{
10 6
}
gl-fill-rect
]
each
COLOR:
black
gl-color
{
0 0
}
{
10 400
}
gl-fill-rect
{
390 0
}
{
10 400
}
gl-fill-rect
PONG
computer>>
0
2array
PADDLE-DIM
gl-fill-rect
PONG
player>>
390
2array
PADDLE-DIM
gl-fill-rect
PONG
ball>>
pos>>
BALL-DIM
gl-fill-rect
PONG
game-over?>>
[
FONT
48
>>size
PONG
ball>>
pos>>
second
200
<
"YOU WIN!"
"YOU LOSE!"
?
[
text-width
390
swap
-
2
/
100
2array
]
[
[
draw-text
]
2curry
with-translation
]
2bi
]
[
PONG
timer>>
thread>>
[
FONT
24
>>size
{
" N - New Game"
"SPACE - Pause"
}
[
text-width
390
swap
-
2
/
100
2array
]
[
[
draw-text
]
2curry
with-translation
]
2bi
]
unless
]
if
;
USING:
kernel
pong
ui.gadgets
;
M:
pong-gadget
pref-dim*
drop
{
400 400
}
;
USING:
accessors
generic
kernel
pong
timers
ui.gadgets
;
M:
pong-gadget
ungraft*
[
timer>>
stop-timer
]
[
M\
pong-gadget
ungraft*
(call-next-method)
]
bi
;