def render(self): import pygame pygame.init() window = pygame.set_mode(self.width, self.height) done = False while not done: for event in pygame.get_event(): if event.type == pygame.KEYDOWN: if event.key == pygame.K_UP: pass if event.type == pygame.QUIT: done = True
def test_animacao(): #DINHEIRO NA TELA screen = pygame.set_mode(screenDimension) objeto = Dinheiro() objDinheiro = screen.blit(objeto) assert objDinheiro == True
def test_animacao2(): #GALO ANDANDO ATÉ FECHAR A TELA DE ANIMAÇÃO AUTOMATICA screen = pygame.set_mode(screenDimension) x = 600 galorun = GaloAnimacao.update(x) assert galorun == False
def __init__(self,width,height): self.width = width self.height = height self.screen = pygame.set_mode((width,height)) self.canvases = [] self.data_lenght = len(Backbone.data)
score_announce_rect = score_announce.get_rect( center=(int(display_width / 2), int(display_height / 2))) display.blit(score_announce, score_announce_rect) pygame.display.flip() while (end_game): for event in pygame.event.get(): if event.type == pygame.QUIT: pygame.quit() if event.type == pygame.KEYDOWN: if event.key == pygame.K_q: exit() if event.key == pygame.K_r: end_game = False display = pygame.set_mode((display_width, display_height)) pygame.display.set_caption("Let's Pong!") display.fill((0, 0, 0)) welcome_screen = pygame.font.Font(None, 30) welcome = welcome_screen.render("Let's Play Pong!", True, (255, 255, 255)) welcome_rect = welcome.get_rect(center=(int(display_width / 2), int(display_height / 3))) startmsg = welcome_screen.render( "Hit 'y' to start, or autostart in 10 seconds", True, (255, 255, 255)) startmsg_rect = startmsg.get_rect(center=(int(display_width / 2), int(display_height / 4))) display.blit(welcome, welcome_rect) display.blit(startmsg, startmsg_rect) pygame.display.flip()
import pygame XSIZE = 320 YSIZE = 240 SCALE = 2 running = True pygame.init() screen = pygame.set_mode( (XSIZE*SCALE, YSIZE*SCALE) ) back = pygame.Surface(XSIZE * YSIZE) def update(): global running running = False def render(): pass while running: update() render()
# Basic pygstage test using the squirrel graphics. # # Use arrow keys to move the squirrel around the world. import pygame from pygame.locals import * import pygstage pygame.init() FPSCLOCK = pygame.time.Clock() DISPLAYSURFACE = pygame.set_mode((640, 480)) GRASSCOLOR = (24, 255, 0) world = pygstage.Stage(1000, 1000, bgcolor=GRASSCOLOR) camera = pygstage.Camera(world, 640, 480) squirrel = pygstage.Actor('squirrel.png') world['squirrel'] = squirrel camera.follow(squirrel) camera.wander = 100 grassImages = [] for i in range(1, 5): grassImages.append(pygame.image.load('grass%s.png' % i)) world['grasses'] = [] # a sequence or mapping of Actors can be assigned to a world for i in range(50): world['grasses'].append(pygstage.Actor(grassImages[random.randint(0, len(grassImages) - 1)], random.randint(0, 1000), random.randint(0, 1000)))