REM *** Näyttötilan asettaminen *** screen_width% = 640 screen_height% = 480 MODE screen_width%, screen_height%, 32 REM *** Muuttujien alkuasetukset *** twister_height% = screen_height% twister_width% = 200 twister_radius% = twister_width% DIV 2 twister_xoffset% = screen_width% - twister_width% rotation% = 0 twistratiophase = 0 framecount% = 0 starttime% = TIME REM *** Pääsilmukka toistuu, kunnes käyttäjä painaa näppäintä *** WHILE INKEY(0) = -1 twist = 0 twistratio = SIN(twistratiophase) * 2 REM Odotetaan kuvaruudun päivitystä eli "vsync" WAIT FOR Y% = 0 TO twister_height% - 1 PROCtwister_slice(Y%*2, twister_xoffset%*2, rotation%+twist) twist = twist + twistratio NEXT Y% rotation% = rotation% + 40 twistratiophase = twistratiophase + 0.03 framecount% = framecount% + 1 ENDWHILE endtime% = TIME PRINT (framecount%*100)/(endtime%-starttime%) " frames per second" END REM *** Aliohjelma, joka piirtää yhden suikaleen *** DEF PROCtwister_slice(row%, xoffset%, angle%) LOCAL leftx%, midx%, rightx% LOCAL light1%, light2% LOCAL modangle REM Välillä 3/4 PI .. 5/4 PI oleva piste on aina vasemmanpuoleisin modangle = (angle% MOD 512 + 768) * PI / 1024.0 leftx% = COS(modangle) * twister_radius% midx% = COS(modangle + PI / 2) * twister_radius% rightx% = COS(modangle + PI) * twister_radius% REM Näkyvissä olevien kahden sivun kirkkaus light1% = -SIN(modangle + PI / 4) * 220 + 35 light2% = -SIN(modangle + 3 * PI / 4) * 220 + 35 REM Piirretään sivut näkyviin GCOL 0, 0, 0 PLOT 100, xoffset%, row% PLOT 97, twister_radius%+leftx%, 0 GCOL light1%, light1%, light1% PLOT 97, midx%-leftx%, 0 GCOL light2%, light2%, light2% PLOT 97, rightx%-midx%, 0 GCOL 0, 0, 0 PLOT 97, twister_radius%-rightx%, 0 ENDPROC