Mikola M.
Rating
Language proficiency level
Skills and abilities
Portfolio
-
5 USD The bird
PythonImports of Pygame
The random import
Initialization of Pygame
… by pygame.init()
Setup of window
win_width = 400
win_height = 600
win = pygame.display.set_mode((win_width, win_height))
pygame.display.set_caption(”Flappy Bird”)
#Download images
bird_img = pygame.image.load("bird.png")
pipe_img = pygame.image.load("pipe.png")
Setting the size of the image
Bird_size = 50
pipe_width = 60
pipe_gap = 200
Set up the bird’s starting position
bird_x = win_width // 2 - bird_size // 2
bird_y = win_height // 2 - bird_size // 2
The speed of the bird
Bird_speed = 5
List of tubes
Pipes = [ ]
Function that generates a new tube
by def generate_pipe():
pipe_x = win_width
pipe_height = random.randint(50, win_height - pipe_gap - 50)
return {"x": pipe_x, "height": pipe_height}
Addition of the first tube
pipes.append(generate_pipe( )
# variable, which is responsible for whether the bird is in the air
is_jumping = false
Function that negates the game world
by def draw_world():
The Bird's Negation
win.blit(bird_img, (bird_x, bird_y))
The TUBS
for pipe in pipes:
Top_pipe_y = 0
bottom_pipe_y = pipe["height"] + pipe_gap
win.blit(pipe_img, (pipe["x"], top_pipe_y))
win.blit(pygame.transform.flip(pipe_img, False, True), (pipe["x"], bottom_pipe_y))
Updated screen
by pygame.display.update()
The main game cycle
Run = True
while run:
Processing of Events
for event in pygame.event.get():
if event.type = pygame.QUIT:
Run = False
elif event.type = pygame.KEYDOWN:
if event.key = pygame.k_space:
is_jumping = true
Moving the bird
if is_jumping:
Bird_y -= Bird_speed * 2
is_jumping = false
Other is:
Bird_y + = Bird_speed
Moving the tubes
for pipe in pipes:
pipe["x"] -= bird_speed
If the tube reaches the left border of the screen
if pipe["x"] < -pipe_width:
pipes.remove (pipe)
If the bird crosses with a tube
if (bird_x < pipe["x"] + pipe_width and
bird_x + bird_size > pipe["x"] and
bird_y < pipe["height"] or
Bird_y + Bird_size
bird_y + bird_size > pipe["height"] + pipe_gap):
Run = False
Addition of a new tube
if pipes[-1]["x"] < win_width - win_width // 2:
pipes.append(generate_pipe( )
The Game of the World
win.fill(0, 0 and 0 )
by draw_world()
The end of the game
by pygame.quit()
Activity
| Latest proposals 6 | Budget | Added | Deadlines | Proposal | |
|---|---|---|---|---|---|
|
Text for article on the news site
7 USD
|
|||||
|
Writing a program that performs the action algorithm in Python
11 USD
|
|||||
|
Text for the site
5 USD
|
|||||
|
Scenario for entertainment content!
11 USD
|
|||||
|
“What is the difference between awakening and awakening?”
5 USD
|
|||||
|
Improve the quality of the photo
5 USD
|