Advertisement
jdriselvato

gravity

Sep 28th, 2011
1,525
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.69 KB | None | 0 0
  1. import pygame, sys, os
  2. from pygame.locals import *
  3. #init
  4. pygame.init()
  5. height = 200;
  6. width = 200;
  7.  
  8. screen = pygame.display.set_mode((height, width))
  9. pygame.display.set_caption("Gravity port")
  10.  
  11. #variables
  12. plx = 90;
  13. ply = 0;
  14. speed = 0;
  15. gravity = 0.1;
  16.  
  17.  
  18. player = pygame.image.load(os.path.join("player.png"))
  19. player.convert()
  20. clock = pygame.time.Clock()
  21.  
  22. while True:
  23.     for event in pygame.event.get():
  24.         if event.type == pygame.QUIT:
  25.             sys.exit()
  26.     if plx < 0:
  27.         plx = 0
  28.     screen.fill((4, 6, 3))
  29.     screen.blit(player, (plx, ply))
  30.     ply = ply + speed;
  31.     speed = speed + gravity;
  32.     if (ply > height):
  33.         speed = speed * -0.95;
  34.     pygame.display.flip()
  35.     clock.tick(50)
  36. pygame.quit()
  37.  
  38.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement