Advertisement
linesguy

semi-stable physics engine

Mar 24th, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. 0 rem I started writing this program on march 24, And tried to fix collision detection for 2 months, And failed.
  2. 0 rem So i present to you - 2 months late - A broken physics engine
  3.  
  4. 10 hgr2
  5. 20 R = 10 : rem Radius of ball.
  6. 30 X = 30 : Y = 10 : rem Ball starting positions
  7. 40 G = 0.2 : rem Gravity
  8. 50 T = 4 : rem Terminal velocity
  9.  
  10.  
  11. 60 C = 1.5
  12.  
  13. 210 Poke 230,32 : gosub 300 : Poke 49236,0 : poke 230,64 : gosub 300 : poke 49237,0 : goto 210
  14. 300 hcolor = 0 : hplot 0,0 : call -3082
  15.  
  16. 310 Hcolor = 3 : hplot 0,0 to 80,191 : hplot 279,0 to 200,191 : hplot 0,100 to 279,191 : hplot 279,100 to 0,191
  17.  
  18. 320 hcolor = 6 : for ch = 0 to 6.28 step 0.1
  19. 325 if hscrn(sin(ch)*r+x,cos(ch)*r+y) = 3 then vx = vx - sin(ch)*c : vy = vy - cos(ch)*c
  20. 330 next
  21. 340 for ch = 0 to 6.28 step 0.1 : hplot sin(ch)*r+x,cos(ch)*r+y : next : x = x + vx : vy = vy + g : y = y + vy
  22. 350 if vx > t then vx = t
  23. 360 if vy > t then vy = t
  24. 370 if vx < -t then vx = -t
  25. 380 if vy < -t then vy = -t
  26. 390 return
  27.  
  28. 400 return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement