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

    Greetings / Vertical Stars moving across the Screen.

    Out Bush
    Out Bush

    Posts : 11
    Join date : 2019-12-02

    Greetings / Vertical Stars moving across the Screen. Empty Greetings / Vertical Stars moving across the Screen.

    Post  Out Bush Mon Dec 02, 2019 10:13 pm


    I too was trying my hand at coding in CPC BASIC 3 when it was initially released, though fell into the trap of thinking along the lines of Locomotive BASIC when CPC BASIC 3 is a little bit different.

    Recently I have created some CPC BASIC stuff which I'll post in the coming week. Back in 2016 I started creating a game which I ended up finishing with Hisoft Pascal called Get The Cash, however I've gone back to that early version, unfortunately I can't remember what the problem was with it when I originally switched languages, I have a feeling it was to do with the Graphics moving down the screen, but I'll get to in due course.

    What I have now is some Vertical Stars I started in Locomotive BASIC, though a few years ago I tried converting to CPC BASIC for performance, though there were problems. A few days ago I had a look and realised that Stars were being Plotted Any old spot on the Graphics screen, so when they would move by being subtracted by 4 on line 250, it would reach a point many of those would go below 0. The solution was to make sure each Star pixel would be placed into a spot divisible by 4, which I did in the following code below by forcing a WHILE loop in 150 to 170 to only exit when a number divisible by 4 is selected.

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

      Current date/time is Thu Aug 18, 2022 7:25 pm