Handbook
Glossary
on-tick ( GADGET -- )
Vocabulary
pong
Inputs
GADGET
an
object
Outputs
None
Definition
USING:
accessors
combinators.short-circuit
kernel
math
sequences
ui.gadgets
;
IN:
pong
::
on-tick
( GADGET -- )
GADGET
move-player
GADGET
move-ball
GADGET
move-computer
GADGET
ball>>
:>
BALL GADGET
player>>
:>
PLAYER GADGET
computer>>
:>
COMPUTER BALL
pos>>
first2
:>
( X Y ) BALL
vel>>
first2
:>
( DX DY )
{
[
DY 0
>
]
[
Y 380
>=
]
}
0&&
[
BALL GADGET PLAYER
?bounce-off-paddle
]
when
{
[
DY 0
<
]
[
Y 10
<=
]
}
0&&
[
BALL GADGET COMPUTER
?bounce-off-paddle
]
when
X
{
[
10
<=
]
[
380
>=
]
}
1||
[
BALL
bounce-off-wall
]
when
GADGET
relayout-1
;