Hey everyone. This is my first post here.
I'm trying to recreate a "3D starfield" program I downloaded for QBASIC a long time ago to SmileBASIC and am having some issues with doing so. I would greatly appreciate some help if anyone is able to lend some advice.
DIM STARAMT, X, DEPTH, ZOOM PRINT "SIMPLE STARFIELD SIMULATOR" PRINT "--------------------------" PRINT PRINT "By the RAZE, Feb 2000" PRINT "Converted to SmileBASIC by Michael Wood 5/6/2019" PRINT PRINT "Press any button to continue." REPEAT UNTIL BUTTON(3) CLS INPUT " Amount of stars (default: 30): ", STARAMT INPUT " Depth (default: 40): ", DEPTH INPUT " Zoom (default: 200): ", ZOOM IF STARAMT==0 THEN STARAMT = 30 IF DEPTH==0 THEN DEPTH = 40 IF ZOOM==0 THEN ZOOM = 200 DIM STARPOS[STARAMT] DIM STARX[STARAMT], STARY[STARAMT], STARZ[STARAMT] FOR X = 0 TO STARAMT - 1 GOSUB @DEFPOS NEXT COL = 0 @LOOP FOR X = 0 TO STARAMT-1 X3D = STARX[X] Y3D = STARY[X] Z3D = STARZ[X] COL = 255 GOSUB @XYZLOC NEXT VSYNC 1 FOR X = 0 TO STARAMT-1 GCLS STARZ[X] = STARZ[X] - 1 IF STARPOS[X]==1 THEN GOSOUB @DEFPOS: STARPOS[X] = 0 NEXT GOTO @LOOP @DEFPOS STARX[X] = RND(30) STARY[X] = RND(30) IF STARX[X] == 0 THEN STARX[X] = 1 IF STARY[X] == 0 THEN STARY[X] = 1 'OTHERWISE STAR COMES STRAIGHT AHEAD AND CAUSES AN ERROR IF STARPOS[X] <= 0 THEN STARZ[X] = RND(50)+1 ELSEIF STARPOS[X] != 0 THEN STARZ[X] = 50 ENDIF RETURN @XYZLOC 'BELOW ARE THE TWO ESSENTIAL 3D PLOTTING LINES 'FINDS THE X LOCATION ON SCREEN X2D = ZOOM * (X3D / (Z3D + DEPTH)) + 200 Y2D = ZOOM * (Y3D / (Z3D + DEPTH)) + 120 IF X2D < 0 OR X2D > 399 OR Y2D < 0 OR Y2D > 239 THEN STARPOS[X] = 1 RETURN ENDIF IF COL == 0 THEN GPSET X2D, Y2D, RGB(COL,COL,COL) RETURN ENDIF C = 255 * Z3D COL = SQR(C) 'PROBLEM LINE IF Z3D > 0 THEN GPSET X2D,Y2D,RGB(COL,COL,COL) RETURN ENDIF GPSET X2D,Y2D,RGB(COL,COL,COL) RETURN