|
Post by B+ on Sept 19, 2018 16:17:07 GMT
Testing new Shorthand Basic Interpreter and came up with this fun code easily translated to JB.
Remember Text based games and the first popular game program of all time?
' translated to JB (v2.0 but version wont matter here) from ' Infinite Pong the Movie (for SB by B+ 2018-09-19)
' Under JB IDE Menu check or reset Columns and Rows to at least ' Setup > Prefernces Main Window Columns 80 Rows 30
'constants p1y = 2 p2y = 28 pw = 10
'ball bx = 30 by = 14 bdx = 2 bdy = 1
'main Do Scan Cls Gosub [P1] Gosub [P2] Gosub [B] Call Pause 60 Loop Until theCowsComeHome
[P1] p1x = bx - 5 Locate p1x, p1y Print "1111111111"; Return
[P2] p2x = bx - 5 Locate p2x, p2y Print "2222222222"; Return
[B] If bx + bdx < 7 Then bdx = bdx * -1 + Int(Rnd(0) * 3) - 1 End If If bx + bdx > 73 Then bdx = bdx * -1 + Int(Rnd(0) * 3) - 1 End If If by + bdy < 3 Then bdy = bdy * -1 bdx = bdx + Int(Rnd(0) * 3) - 1 End If If by + bdy > 27 Then bdy = bdy * -1 bdx = bdx + Int(Rnd(0) * 3) - 1 End If bx = bx + bdx by = by + bdy Locate bx, by Print "O"; Locate 1, 1 Return
sub Pause mil 'tsh version has scan built-in t0 = time$("ms") while time$("ms") < t0 + mil : scan : wend end sub
Edit: fixed the little line stuck to the ball with Locate 1, 1 before the last Return statement.
|
|
|
Post by tsh73 on Sept 24, 2018 6:49:26 GMT
Cool effect. Really small code too. Provides that coding itching
|
|