Advertisement
linesguy

Circle collision detector

Aug 30th, 2017
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. 0 rem To be used in a later raytracing program
  2.  
  3. 0 rem Circle collision detector
  4. 0 rem Click run, wait for circle to draw, then hover mouse over circle.
  5. 10 hgr : hcolor = 3 : r = 50 : cx = 140 : cy = 96
  6. 20 for x = 0 to 6.282 step 1/r : hplot sin(x)*r+cx,cos(x)*r+cy : next
  7.  
  8.  
  9. 100 px=int(pdl(0)*1.094):py=int(pdl(1)*.749)
  10. 110 distance = sqr((cx-px)^2+(cy-py)^2)
  11. 120 if distance < r then print "Collision detected" : goto 140
  12. 130 print "No collision detected"
  13. 140 goto 100
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement