REM random walk
REM T Street (superdecade Games)
MODE 10 : OFF
REM greyish background
COLOUR 1, 220, 220, 220
COLOUR 129 : CLS
REM black outline
COLOUR 2, 0,0,0
size% = 42
REM start position
x% = 720
y% = 576
REM main loop
REPEAT
*refresh off
REM get a new random colour
COLOUR 1, 0, RND(255), RND(255)
REM draw black border
GCOL 0,2
REM draw a circle
CIRCLE FILL x%, y%, size% DIV 2
REM draw coloured center
GCOL 0,1
CIRCLE FILL x%, y%, size% DIV 2 - 4
*refresh on
REM make a random walk
CASE RND(4) OF
WHEN 1 x% += size%
WHEN 2 x% -= size%
WHEN 3 y% += size%
WHEN 4 y% -= size%
ENDCASE
REM wait a mo'
WAIT 5
UNTIL FALSE
A random walk. Note, it is possible for the disks to 'walk' off the edge of the screen. |
REM random walk 2
REM T Street (superdecade Games)
MODE 10 : OFF
REM greyish background
COLOUR 1, 220, 220, 220
COLOUR 129 : CLS
REM black outline
COLOUR 2, 0,0,0
size% = 42
REM start position
x% = 720
y% = 576
REM main loop
REPEAT
*refresh off
REM get a new random colour
COLOUR 1, 0, RND(255), RND(255)
REM draw black border
GCOL 0,2
REM draw a circle
CIRCLE FILL x%, y%, size% DIV 2
REM draw coloured center
GCOL 0,1
CIRCLE FILL x%, y%, size% DIV 2 - 4
*refresh on
REM make a random walk
CASE RND(4) OF
WHEN 1 x% += size%
WHEN 2 x% -= size%
WHEN 3 y% += size%
WHEN 4 y% -= size%
ENDCASE
REM check disk hasn't walked off the screen
IF x%<0 THEN x% += (size%*2)
IF x%>1440 THEN x% -= (size%*2)
IF y%<0 THEN y% += (size%*2)
IF y%>1152 THEN y% -= (size%*2)
REM wait a mo'
WAIT 5
UNTIL FALSE
Another random walk. How would you change the size of the disks? How would you change the size of the border? How would you speed up the walk? |
REM random walk 3
MODE 10 : OFF
REM greyish background
COLOUR 1, 220, 220, 220
COLOUR 129 : CLS
REM black outline
COLOUR 2, 0,0,0
REM red highlight
COLOUR 3, 255, 0, 0
size% = 100
REM start position
x% = 720
y% = 576
REM main loop
REPEAT
*refresh off
REM get a new random colour
COLOUR 1, 0, RND(255), RND(255)
REM draw black border
GCOL 0,2
REM draw a circle
CIRCLE FILL x%, y%, size% DIV 2
REM draw coloured center
GCOL 0,3
CIRCLE FILL x%, y%, size% DIV 2 - 4
*refresh on
WAIT 2
GCOL 0,1
CIRCLE FILL x%, y%, size% DIV 2 - 4
REM make a random walk
CASE RND(4) OF
WHEN 1 x% += size%
WHEN 2 x% -= size%
WHEN 3 y% += size%
WHEN 4 y% -= size%
ENDCASE
REM check disk hasn't walked off the screen
IF x%<0 THEN x% += (size%*2)
IF x%>1440 THEN x% -= (size%*2)
IF y%<0 THEN y% += (size%*2)
IF y%>1152 THEN y% -= (size%*2)
REM wait a mo'
WAIT 1
UNTIL FALSE
Red marks the current position of the 'walker' |
REM random walk 4
REM T Street (superdecade Games)
MODE 10 : OFF
REPEAT
INPUT "Enter a string ( more than 2 characters ) : " astring$
UNTIL LEN(astring$) > 2
REM greyish background
COLOUR 1, 220, 220, 220
COLOUR 129 : CLS
REM black outline
COLOUR 2, 0,0,0
size% = 36
REM start position
x% = 720
y% = 576
n% = 1 : REM poition in string
REM main loop
REPEAT
*refresh off
REM get a new random colour
COLOUR 1, 0, RND(255), RND(255)
REM draw black border
GCOL 0,2
REM draw a circle
CIRCLE FILL x%, y%, size% DIV 2
REM draw coloured center
GCOL 0,1
CIRCLE FILL x%, y%, size% DIV 2 - 4
*refresh on
REM make a random walk
a% = ASC(MID$(astring$, n%, 1)) MOD 4 + 1
n% += 1
IF n% > LEN(astring$) n% = 1
CASE a% OF
WHEN 1 x% += size%
WHEN 2 x% -= size%
WHEN 3 y% += size%
WHEN 4 y% -= size%
ENDCASE
REM wait a mo'
WAIT 5
UNTIL FALSE