ciao recentemente mi sto appasionando al mondo python e stavo seguendo una guida su come creare un gioco con pygame
questo è il codice che ho scritto fino ad ora
mi da questo errore
pygame 2.0.0 (SDL 2.0.12, python 3.9.0)
Hello from the pygame community. https://www.pygame.org/contribute.html
Traceback (most recent call last):
File "C:\Users\lugge\Desktop\PYGAME\new 1.py", line 36, in <module>
bird_vely += 1
NameError: name 'bird_vely' is not defined
questo è il codice che ho scritto fino ad ora
Python:
import pygame
import random
pygame.init()
background = pygame.image.load('immagini/sfondo.png')
bird = pygame.image.load('immagini/uccello.png')
grass = pygame.image.load('immagini/base.png')
gameover = pygame.image.load('immagini/gameover.png')
pipe_down = pygame.image.load('immagini/tubo.png')
pipe_up = pygame.transform.flip(pipe_down, False, True)
display = pygame.display.set_mode((288, 512))
FPS = 50
def create_obj():
display.blit(background, (0,0))
display.blit(bird, (birdx,birdy))
def refresh ():
pygame.display.update()
pygame.time.Clock().tick(FPS)
def initialize():
global birdx, birdy, bird_vely
birdx, birdy = 60, 150
ucello_vely = 0
initialize()
while True:
bird_vely += 1
birdy += bird_vely
create_obj();
refresh()
pygame 2.0.0 (SDL 2.0.12, python 3.9.0)
Hello from the pygame community. https://www.pygame.org/contribute.html
Traceback (most recent call last):
File "C:\Users\lugge\Desktop\PYGAME\new 1.py", line 36, in <module>
bird_vely += 1
NameError: name 'bird_vely' is not defined