Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pygame as pg
- pg.init()
- SCREEN_WIDTH = 256
- SCREEN_HEIGHT = 640
- clock = pg.time.Clock()
- FPS = 60
- screen = pg.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT))
- pg.display.set_caption('Flappy Bird', 'Assets/yellowbird-downflap.png')
- bg = pg.image.load('Assets/background-day.png')
- ground_img = pg.image.load('Assets/base.png')
- class Bird(pg.sprite.Sprite):
- def __init__(self, x, y):
- pg.sprite.Sprite.__init__(self)
- self.image = pg.image.load('Assets/redbird-downflap.png')
- self.rect = self.image.get_rect()
- self.rect.center = [x, y]
- bird_group = pg.sprite.Group()
- player = Bird(SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2)
- bird_group.add(player)
- ground_scroll = 0
- scroll_speed = 4
- is_active = True
- while is_active:
- clock.tick(FPS)
- screen.blit(bg, (0, 0))
- bird_group.draw(screen)
- screen.blit(ground_img, (ground_scroll, 512))
- ground_scroll -= scroll_speed
- if abs(ground_scroll) > 35:
- ground_scroll = 0
- for event in pg.event.get():
- if event.type == pg.QUIT:
- is_active = False
- pg.display.update()
- pg.quit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement