0

Why isn't my game working????

Here is my code in pygame. Idk why it doesn't work help import pygame pygame.init() w = 800 h = 700 screen = pygame.display.set_mode((w, h)) pygame.display.set_caption('Life run') icon = pygame.image.load(r'/Users/lanik2009/Downloads/icon.PNG') pygame.display.set_icon(icon) player_img = pygame.image.load(r'/Users/lanik2009/Downloads/sprite.PNG') player_img = pygame.transform.scale(player_img, (70, 100)) bg = pygame.image.load(r'/Users/lanik2009/Downloads/bg.PNG') x = 370 y = 480 screen.blit(bg, (0,0)) screen.blit(player_img, (60, 470)) running = True while running: for event in pygame.event.get(): if event.type == pygame.QUIT: running = False def update(self): vel = 0 keys = pygame.key.get_pressed() if keys[pygame.K_LEFT]: vel -= 8 if keys[pygame.K_RIGHT]: vel = 8 if keys[pygame.K_UP]: vel = 8 x += vel pygame.display.update() pygame.quit()

2nd May 2021, 7:17 PM
Ailana
Ailana - avatar
1 Resposta
0
First question, what does the game do? I see only several wrong code lines. Try to edit them. def update(x, y): vel = 0 keys = pygame.key.get_pressed() if keys[pygame.K_LEFT]: vel -= 8 if keys[pygame.K_RIGHT]: vel = 8 if keys[pygame.K_UP]: vel = 8 x += vel screen.blit(bg, (0, 0)) screen.blit(player_img, (x, y)) update(x, y) pygame.display.update() pygame.quit()
3rd May 2021, 6:37 AM
Maksat Ramazanov
Maksat Ramazanov - avatar