Advertisement
Enrro

juegoFinal 111427

Nov 14th, 2014
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.30 KB | None | 0 0
  1. '''
  2. Created on 11/11/2014
  3. pygame
  4. Proven and tested on python 2.7
  5. @author: A01221672
  6. '''
  7. import pygame
  8. import random
  9.  
  10. def principal():
  11. gameloop = True
  12. ancho = 640
  13. alto = 480
  14. Rx,Ry = 640,random.randrange(0,alto)
  15. circmov = 250
  16.  
  17.  
  18. colorSugar = [[254,67,101],[252,157,154],[249,205,173],[200,200,169],[131,175,155]] #paleta de colores calidos
  19. colorDreamMagnet = [[52,56,56],[0,95,107],[0,140,158],[0,180,204],[0,223,252]]
  20.  
  21. clock = pygame.time.Clock()
  22. pygame.init()
  23. lienzo=pygame.display.set_mode((ancho,alto)) #Aqui es el tamano de la pantalla
  24. pygame.display.set_caption("Circle Runner")
  25.  
  26. pygame.mixer.music.load("music.mp3")
  27. pygame.mixer.music.set_volume(.4)
  28. pygame.mixer.music.play(-1)
  29.  
  30.  
  31. FONT = pygame.font.SysFont('monospace!!!',20) #SysFont creates a font object from available pygame fonts
  32. SURFACEFONT = FONT.render('BEST GAME EVER',True,(0,0,0)) #True is for anti-aliasing, looks better when true
  33. SURFACER=SURFACEFONT.get_rect() #meaning SURFACER will gain rectangular values
  34. SURFACER.center=(ancho/2,20)
  35.  
  36. while gameloop:
  37.  
  38. event = pygame.event.poll()
  39.  
  40. if event.type == pygame.QUIT:
  41.  
  42. gameloop = False
  43.  
  44. elif event.type == pygame.MOUSEBUTTONDOWN:
  45.  
  46. print("Mouse")
  47.  
  48. elif event.type == pygame.KEYDOWN:
  49.  
  50. print(event.key) #show the number acording to the key pressed
  51.  
  52. #if event.key == pygame.K_w:
  53.  
  54. #circmov -= 5
  55.  
  56. #if event.key == pygame.K_s:
  57.  
  58. #circmov += 5
  59. keysPress = pygame.key.get_pressed()
  60.  
  61. if keysPress[pygame.K_w]:
  62.  
  63. circmov -= 5
  64.  
  65. if keysPress[pygame.K_s]:
  66.  
  67. circmov += 5
  68.  
  69. pygame.draw.rect(lienzo,(colorSugar[4]),(0, 0, ancho, alto))#fondo
  70. pygame.draw.rect(lienzo,(colorSugar[3]),(0,270,ancho,alto))#Piso
  71.  
  72. if Rx>= -40:
  73.  
  74. pygame.draw.rect(lienzo,(colorSugar[2]),(Rx,Ry,50,30))#enemigo
  75.  
  76. else:
  77. Rx = 640
  78. Ry = random.randrange(0,alto)
  79. pygame.draw.circle(lienzo,(colorSugar[1]),(50,circmov),20)#pelota
  80.  
  81. lienzo.blit(SURFACEFONT,SURFACER)
  82. clock.tick(60)
  83.  
  84. Rx = Rx - 5
  85.  
  86. pygame.display.update()
  87.  
  88. pygame.quit()
  89.  
  90. principal()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement