Advertisement
noTformaT

pygame_anim_temp.py

Mar 6th, 2011
754
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.89 KB | None | 0 0
  1. import math
  2. import pygame, sys
  3. from pygame.locals import *
  4. pygame.init()
  5. (windows_width, windows_height, windows_title) = (600, 400, "Simple Anim")
  6. screen = pygame.display.set_mode((windows_width,windows_height),0,32)
  7. pygame.display.set_caption(windows_title)
  8. windows_bgcolor = (255,255,255)
  9. mainLoop = True
  10. clock = pygame.time.Clock()
  11. milli = seconds = 0.0
  12. #initial data here
  13. rect = Rect(0,0,100,100)
  14. rect_color = (0,0,255)
  15. speed_by_second = 250
  16. while mainLoop:
  17.     for event in pygame.event.get():
  18.         if event.type == QUIT:
  19.             mainLoop = False
  20.     screen.fill(windows_bgcolor)
  21.     milli = clock.tick(40)
  22.     seconds = milli / 1000.0
  23.     dm = speed_by_second * seconds
  24.     rect.x += dm
  25.     if rect.x > 600:
  26.         rect.x = - rect.width
  27.     pygame.draw.rect(screen,rect_color,rect)
  28.     #create frame here
  29.     pygame.display.update()
  30. pygame.quit()
  31. #destroy data here
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement