Advertisement
programcreator

FlappyBirdPhysicsEngine

Feb 26th, 2015
318
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.58 KB | None | 0 0
  1. local G = 1
  2. local speed = 1
  3. local position = 3
  4. local w,h = term.getSize()
  5. local timeS = os.clock()  
  6. function draw()
  7. term.setCursorPos(1,1)
  8. print(diff)
  9. print(speed)
  10. print(timeS)
  11. print(position)
  12. sleep(1)   
  13. term.setBackgroundColor(colors.black)  
  14. term.clear()    
  15. term.setBackgroundColor(colors.red)    
  16. term.setCursorPos(math.floor(w/4),position)    
  17. term.write(" ")
  18. end  
  19. function phy()  
  20. diff = os.clock()- timeS    
  21. position = position + (speed*diff) + (G*diff*diff)/2    
  22. timeS = os.clock()
  23. speed = speed + G*diff
  24. end  
  25. while true do  
  26. sleep(.5)  
  27. phy()  
  28. draw()
  29. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement