on-tick ( GADGET -- )


Vocabulary
pong

Inputs
GADGETan object


Outputs
None

Definition


:: 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 ;