Skip to content

Instantly share code, notes, and snippets.

@lucas404x
Created March 30, 2019 18:40
Show Gist options
  • Save lucas404x/00bb0cedb0d20ecd11bd56566b6cb859 to your computer and use it in GitHub Desktop.
Save lucas404x/00bb0cedb0d20ecd11bd56566b6cb859 to your computer and use it in GitHub Desktop.
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))
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