home *** CD-ROM | disk | FTP | other *** search
/ Compute! Gazette 1987 July / 1987-07.d64 / cube.data (.txt) < prev    next >
Commodore BASIC  |  2022-09-20  |  2KB  |  45 lines

  1. 10 poke55,255:poke56,99:rem cube data file maker
  2. 20 dim v(8,3),sv(8,2),s(6,5),n(6,3),e(12,3)
  3. 30 fori=1to8:forj=1to3:readv(i,j):nextj,i
  4. 40 fori=1to6:forj=1to5:reads(i,j):nextj,i
  5. 50 data 40,40,-40,40,40,40,40,-40,40,40,-40,-40
  6. 60 data -40,-40,-40,-40,-40,40,-40,40,40,-40,40,-40
  7. 70 data 1,2,3,4,1,1,8,7,2,1,8,5,6,7,8
  8. 80 data 5,4,3,6,5,2,7,6,3,2,4,5,8,1,4
  9. 90 cx=160:cy=100:th=.2:ph=.8:pd=2000:dt=20000
  10. 100 ns=95
  11. 400 printchr$(147);:input"filename";f$:pa=25600
  12. 410 print"computing screen number: ";
  13. 420 forsc=1tons:print sc;
  14. 430 gosub 1000
  15. 440 ifsc<>nsthenpokepa-1,254:nextsc
  16. 450 pokepa-1,255
  17. 460 sys57812 f$,8
  18. 470 poke193,0:poke194,100
  19. 480 poke174,int(pa)and255:poke175,int(pa/256):sys62954
  20. 490 print:print"animation data file ";chr$(34);f$;chr$(34);" is complete":end
  21. 500 pokepa,int(y1):pa=pa+1
  22. 510 pokepa,int(x1)and255:pa=pa+1:pokepa,int(x1/256):pa=pa+1
  23. 520 pokepa,int(y2):pa=pa+1
  24. 530 pokepa,int(x2)and255:pa=pa+1:pokepa,int(x2/256):pa=pa+1
  25. 540 pokepa,0:pa=pa+1:pokepa,0:pa=pa+1
  26. 550 return
  27. 1000 s1=sin(th):c1=cos(th):s2=sin(ph):c2=cos(ph)
  28. 1010 fori=1to8:x=v(i,1):y=v(i,2):z=v(i,3):sx=-x*s1+y*c1
  29. 1020 sy=-x*c1*c2-y*s1*c2+z*s2:sz=-x*s2*c1-y*s2*s1-z*c2+dt
  30. 1030 sv(i,1)=pd*(1.4*sx/sz)+cx:sv(i,2)=-pd*(sy/sz)+cy:next
  31. 1040 fori=1to6:f=s(i,1):g=s(i,2):h=s(i,3):u1=v(g,1)-v(f,1):u2=v(g,2)-v(f,2)
  32. 1050 u3=v(g,3)-v(f,3):v1=v(h,1)-v(f,1):v2=v(h,2)-v(f,2):v3=v(h,3)-v(f,3)
  33. 1060 n(i,1)=u2*v3-v2*u3:n(i,2)=u3*v1-v3*u1:n(i,3)=u1*v2-v1*u2:next
  34. 1070 xe=dt*s2*c1:ye=dt*s2*s1:ze=dt*c2:m=1
  35. 1080 fori=1to6:e2=s(i,1):wx=xe-v(e2,1):wy=ye-v(e2,2):wz=ze-v(e2,3)
  36. 1090 if(n(i,1)*wx+n(i,2)*wy+n(i,3)*wz)<=0then1140
  37. 1100 e1=s(i,1):forj=2to5:e2=s(i,j):fork=1tom
  38. 1110 ife(k,1)=e2ande(k,2)=e1thene(k,3)=2:goto 1130
  39. 1120 nextk:e(m,1)=e1:e(m,2)=e2:e(m,3)=1:m=m+1
  40. 1130 e1=e2:nextj
  41. 1140 nexti:fori=1to12:ife(i,3)=0then1160
  42. 1150 j=e(i,1):k=e(i,2):x1=sv(j,1):y1=sv(j,2):x2=sv(k,1):y2=sv(k,2):gosub500
  43. 1160 next:th=th+.06544985:ph=ph+.06544985:if sc<48 then pd=pd+583.3:return
  44. 1170 pd=pd-583.3:return
  45.