felixnardella

Poligonirotanti1.bas

Jul 4th, 2021 (edited)
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.87 KB | None | 0 0
  1. 5poke53280,15:s=8192
  2. 10poke53272,peek(53272)or8:poke53265,peek(53265)or32
  3. 15gosub395
  4. 20rem clear color ram
  5. 25cb$="pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp"
  6. 30cb$=cb$+cb$:cb$=cb$+left$(cb$,121)
  7. 35print"ppp"cb$;cb$;cb$;cb$;
  8. 40fori=0to7:tw%(i)=2^i:next
  9. 45goto315
  10. 50rem plot x,y
  11. 55ify<0ory>199thengoto75
  12. 60ifx<0orx>319thengoto75
  13. 65p=s+320*int(y/8)+8*int(x/8)+(yand7)
  14. 70pokep,peek(p)ortw%(7-(xand7))
  15. 75return
  16. 80rem calc lines pixels
  17. 85dx=x1-x2:dy=y1-y2
  18. 90ifdx=0goto135
  19. 95m=dy/dx
  20. 100ab=1:ifm>1orm<-1goto160
  21. 105ifdx>0thenab=-1
  22. 110forx=x1tox2stepab
  23. 115y=m*(x-x1)+y1
  24. 120gosub55
  25. 125next:return
  26. 130rem if dx=0
  27. 135x=x1:ab=1:ifdy>0thenab=-1
  28. 140fory=y1toy2stepab
  29. 145gosub55
  30. 150next:return
  31. 155rem if m>1orm<-1
  32. 160ab=1:ifdy>0thenab=-1
  33. 165fory=y1toy2stepab
  34. 170x=(y-y1)/m+x1
  35. 175gosub55
  36. 180next:return
  37. 185rem plot polygon
  38. 190fi=2*pi/n:s1=sin(fi):c1=cos(fi)
  39. 195y1=0:x1=r:kk=0
  40. 200fork=0ton-1
  41. 205x2=xc+x1*c1-y1*s1:a(kk,0)=x2
  42. 210y2=yc+x1*s1+y1*c1:a(kk,1)=y2
  43. 215kk=kk+1
  44. 220x1=xc+x1:a(kk,0)=x1
  45. 225y1=yc+y1:a(kk,1)=y1:kk=kk+1
  46. 230gosub85
  47. 235x1=x2-xc:y1=y2-yc
  48. 240next:return
  49. 245rem rotate polygon
  50. 250fi=pi/w:s1=sin(fi):c1=cos(fi):kk=0
  51. 255fork=0ton-1
  52. 260x2=a(kk,0)*c1-a(kk,1)*s1
  53. 265y2=a(kk,0)*s1+a(kk,1)*c1
  54. 270a(kk,0)=x2:a(kk,1)=y2
  55. 275kk=kk+1
  56. 280x1=a(kk,0)*c1-a(kk,1)*s1
  57. 285y1=a(kk,0)*s1+a(kk,1)*c1
  58. 290a(kk,0)=x1:a(kk,1)=y1
  59. 295gosub85
  60. 300kk=kk+1
  61. 305next:return
  62. 310rem main
  63. 315xc=50:yc=10:r=10:w=18:dima(20,1)
  64. 320forn=3to10
  65. 325gosub190
  66. 330fori=0ton+3
  67. 335gosub245
  68. 340next
  69. 345co=2+int(13*rnd(0))
  70. 350forj=1024to2023:pokej,16*co:next
  71. 360xc=xc+37:next
  72. 364poke198,0:wait198,1
  73. 365printchr$(147)
  74. 370rem turn graphics off
  75. 375poke53265,peek(53265)and(223)
  76. 380poke53272,21:poke53280,14
  77. 385end
  78. 390rem clear graphic ram
  79. 395cb$=""
  80. 400p1=peek(51):p2=peek(52)
  81. 405poke51,64:poke52,63
  82. 410forcn=1to125:cb$=cb$+chr$(0):next
  83. 415poke51,p1:poke52,p2
  84. 420return
Add Comment
Please, Sign In to add comment