Advertisement
linesguy

Calculating PI with collisions

Aug 27th, 2019
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. 10 hgr : hcolor = 3 : for i = 1 to 20 : print : next i
  2. 20 height = 159 : width = 280
  3. 30 wall = 10
  4. 35 digits = 3
  5. 40 ts = 10^(digits-2)
  6.  
  7. 50 x1 = 100 : s1 = 10 : m1 = 1 : v1 = 0
  8. 60 x2 = 200 : s2 = 30 : m2 = 100^(digits-1) : v2 = -3/ts
  9.  
  10.  
  11. 199Poke230,32:gosub 200:Poke49236,0:poke 230,64:gosub200:poke49237,0:goto199
  12. 200call-3086:print col
  13. 205 hplot wall,0 to wall,height
  14.  
  15. 209 for i = 1 to ts
  16. 210 x1 = x1 + v1 : x2 = x2 + v2
  17. 213 if x1+s1 > x2 then sum = m1+m2 : n1 = (m1-m2)/(sum)*v1+(2*m2)/(sum)*v2 : n2 = (2*m1)/(sum)*v1-(m1-m2)/(sum)*v2 : v1 = n1 : v2 = n2 : col = col + 1
  18. 215 if x1<wall then v1=-v1 : col = col + 1
  19. 216 next i
  20.  
  21. 218 d1 = x1 : d2 = x2 : if d1<wall then d1=wall
  22. 219 if d2 < d1+s1 then d2 = d1+s1
  23. 220 hplot d1,height to d1+s1,height to d1+s1,height-s1 to d1,height-s1 to d1,height
  24. 230 if d2+s2 < width then hplot d2,height to d2+s2,height to d2+s2,height-s2 to d2,height-s2 to d2,height
  25.  
  26. 999 return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement