CMM2 demo programs
Author | Message | ||||
TassyJim![]() Guru ![]() Joined: 07/08/2011 Location: AustraliaPosts: 6206 |
During the testing of the CMM2, I needed a few short programs designed to demonstrate some of the features. This rotating cube program started life in a QuickBasic forum. To change it to MMBasic the only changes needed were PSET changed to PIXEL and BOX used to erase the frames. I then used PAGE to remove the ficker and a timer so you can compare the different graphic MODEs A couple of tweaks to the formula shaved about 10mS of each frame. ![]() ' cube rotator ' From a 19 liner by Entropy, shrinked by Antoni Gual ' for Rel's 9 LINER contest at QBASICNEWS.COM 1/2003 ' translated to MMBasic for the CMM2 by TassyJim May 2020 DIM INTEGER x,y,z DIM FLOAT r,x1,y1 DIM FLOAT COSr,SINr,denom,xyz DIM INTEGER cx = MM.HRES/2 'scale things for different display resolution DIM INTEGER cy = MM.VRES/2 DIM INTEGER b = cx/2 DIM INTEGER s = cx*3/4 CLS DO TIMER = 0 PAGE WRITE 1 'cls BOX b,cy-b,cx,cx,1,0,0 ' 1mS quicker than CLS r = (r + .01745) + 6.283185 * (r >= 6.283185) COSr = COS(r) SINr = SIN(r) FOR x = -30 TO 30 STEP 10 FOR y = -30 TO 30 STEP 10 FOR z = -30 TO 30 STEP 10 denom = x*SINr+(z*COSr-y*SINr)*COSr+100 ' saves about 4.5mS xyz = x*COSr-(z*COSr-y*SINr)*SINr ' this one saves 3mS x1 =(xyz*COSr+(y*COSr+z*SINr)*SINr)/denom y1 =((y*COSr+z*SINr)*COSr-xyz*SINr)/denom PIXEL (s * x1 + cx), (s * y1 + cy), RGB(WHITE) NEXT z NEXT y NEXT x PAGE WRITE 0 BLIT b,cy-b, b,cy-b,cx,cx ,1 TEXT cx,cy+b,STR$(TIMER)+"mS",cm LOOP UNTIL INKEY$ <>"" ' formula before speed refinements ' x1 =((x*COS(r)-(z*COS(r)-y*SIN(r))*SIN(r))*COS(r)+(y*COS(r)+z*SIN(r))*SIN(r))/(x*SIN(r)+(z*COS(r)-y*SIN(r))*COS(r)+100) ' y1 =((y*COS(r)+z*SIN(r))*COS(r)-(x*COS(r)-(z*COS(r)-y*SIN(r))*SIN(r))*SIN(r))/(x*SIN(r)+(z*COS(r)-y*SIN(r))*COS(r)+100) Jim VK7JH MMedit |
||||