code_junkie

Simulation Problem with mouse in Pygame

Nov 13th, 2011
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. import math
  2. import pygame
  3. from pygame.locals import *
  4.  
  5. # Initialize PyGame
  6. pygame.init()
  7. pygame.display.set_mode((800,600))
  8.  
  9. quit = False
  10.  
  11. roundtime = 20 # ms
  12. nextupdate = pygame.time.get_ticks() + roundtime
  13. framenum = 0
  14.  
  15. # Watering radius
  16. r = 25
  17. # Time step
  18. dt = 1 # min
  19.  
  20. field = [0.0]*80*60
  21.  
  22. while not quit:
  23.  
  24. # Handle events
  25. while True:
  26. event = pygame.event.poll()
  27. if event.type == pygame.QUIT:
  28. quit = True
  29. break
  30. else:
  31. break
  32.  
  33. while pygame.time.get_ticks() >= nextupdate:
  34. nextupdate += roundtime
  35. # Physics
  36.  
  37. # Mouse position
  38. mpos = pygame.mouse.get_pos()
  39. # Keyboard
  40. keys = pygame.key.get_pressed()
  41. # Mouse buttons
  42. mbut = pygame.mouse.get_pressed()
Add Comment
Please, Sign In to add comment