CPC Basic

Would you like to react to this message? Create an account in a few clicks or log in to continue.
CPC Basic

Basic cross-compiler for Amstad CPC


    Moving Pixels Down the Screen

    Out Bush
    Out Bush


    Posts : 11
    Join date : 2019-12-02

    Moving Pixels Down the Screen Empty Moving Pixels Down the Screen

    Post  Out Bush Sat Dec 07, 2019 8:11 pm

    Like my Vertical Stars earlier, this deals with the problem of when Pixels reach the bottom of the screen, so numbers need to be able to divide into 2 and when 2 is reached move back to the top and a new random position along the x coordinate assigned.

    Code:

    100 DEFWORD a-z:DIM a(30)
    110 FOR n=1 TO 30 STEP 3
    120  x=n+1
    130  y=n+2
    140  a(x)=RND MOD 640
    150  o=RND MOD 398
    160  WHILE o MOD 2 <> 0
    170    o=RND MOD 398
    180  WEND
    190  a(y)=o
    200 NEXT n
    210 MODE 0:INK 0,0:INK 1,26
    220 WHILE 1
    230  FOR n=1 TO 30 STEP 3
    240  x=n+1:y=n+2
    250  IF a(y)>2 THEN PLOT a(x),a(y),0:a(y)=a(y)-2:PLOT a(x),a(y),1
    260  IF a(y)=2 THEN PLOT a(x),a(y),0:GOSUB 290:PLOT a(x),a(y),1
    270  NEXT n
    280 WEND
    290 a(x)=RND MOD 640
    300 a(y)=398
    310 RETURN

      Current date/time is Thu Nov 21, 2024 9:31 pm