Created
March 30, 2019 18:40
-
-
Save lucas404x/00bb0cedb0d20ecd11bd56566b6cb859 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pygame | |
class Flappy: | |
def __init__(self): | |
self.flappy = pygame.image.load('imagens/flappybird1.png') | |
class Janela: | |
def __init__(self): | |
self.altura = 600 | |
self.largura = 400 | |
self.janela = pygame.display.set_mode((self.altura, self.largura)) | |
self.fundo = fundo = pygame.transform.scale(pygame.image.load('imagens/flappy_background.png'), (self.altura, self.largura)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pygame | |
import objects | |
pygame.init() | |
class Game: | |
def __init__(self): | |
self.flappy = objects.Flappy() | |
janela = objects.Janela() | |
window = janela.janela | |
pygame.display.set_caption('Flappy Bird') | |
run = True | |
posx = janela.altura/2 | |
posy = janela.largura/2 | |
while run: | |
for event in pygame.event.get(): | |
if event.type == pygame.QUIT: | |
run = False | |
key = pygame.key.get_pressed() | |
if key[pygame.K_SPACE]: | |
objects.Flappy().getFlappy() | |
if key[pygame.K_RIGHT]: | |
posx += 10 | |
if key[pygame.K_DOWN]: | |
posy += 10 | |
if key[pygame.K_UP]: | |
posy -= 10 | |
if key[pygame.K_LEFT]: | |
posx -= 10 | |
window.blit(janela.fundo, (0, 0)) | |
window.blit(self.flappy.flappy, (posx, posy)) | |
pygame.display.update() | |
Game() | |
pygame.quit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment