Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- '''
- Created on 11/11/2014
- pygame
- Proven and tested on python 2.7
- @author: A01221672
- '''
- import pygame
- import random
- def principal():
- gameloop = True
- ancho = 640
- alto = 480
- Rx,Ry = 640,random.randrange(0,alto)
- circmov = 250
- colorSugar = [[254,67,101],[252,157,154],[249,205,173],[200,200,169],[131,175,155]] #paleta de colores calidos
- colorDreamMagnet = [[52,56,56],[0,95,107],[0,140,158],[0,180,204],[0,223,252]]
- clock = pygame.time.Clock()
- pygame.init()
- lienzo=pygame.display.set_mode((ancho,alto)) #Aqui es el tamano de la pantalla
- pygame.display.set_caption("Circle Runner")
- pygame.mixer.music.load("music.mp3")
- pygame.mixer.music.set_volume(.4)
- pygame.mixer.music.play(-1)
- FONT = pygame.font.SysFont('monospace!!!',20) #SysFont creates a font object from available pygame fonts
- SURFACEFONT = FONT.render('BEST GAME EVER',True,(0,0,0)) #True is for anti-aliasing, looks better when true
- SURFACER=SURFACEFONT.get_rect() #meaning SURFACER will gain rectangular values
- SURFACER.center=(ancho/2,20)
- while gameloop:
- event = pygame.event.poll()
- if event.type == pygame.QUIT:
- gameloop = False
- elif event.type == pygame.MOUSEBUTTONDOWN:
- print("Mouse")
- elif event.type == pygame.KEYDOWN:
- print(event.key) #show the number acording to the key pressed
- #if event.key == pygame.K_w:
- #circmov -= 5
- #if event.key == pygame.K_s:
- #circmov += 5
- keysPress = pygame.key.get_pressed()
- if keysPress[pygame.K_w]:
- circmov -= 5
- if keysPress[pygame.K_s]:
- circmov += 5
- pygame.draw.rect(lienzo,(colorSugar[4]),(0, 0, ancho, alto))#fondo
- pygame.draw.rect(lienzo,(colorSugar[3]),(0,270,ancho,alto))#Piso
- if Rx>= -40:
- pygame.draw.rect(lienzo,(colorSugar[2]),(Rx,Ry,50,30))#enemigo
- else:
- Rx = 640
- Ry = random.randrange(0,alto)
- pygame.draw.circle(lienzo,(colorSugar[1]),(50,circmov),20)#pelota
- lienzo.blit(SURFACEFONT,SURFACER)
- clock.tick(60)
- Rx = Rx - 5
- pygame.display.update()
- pygame.quit()
- principal()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement