Traceback (most recent call last):
File "/storage/emulated/0/pygame_template.py", line 7, in <module>
player_img = pygame.image.load(os.path.join(img_folder, "p1_jump.png")).convert()
FileNotFoundError: No such file or directory.
Вот и сама ошибка
А вот код:
import pygame
import random
import os
game_folder = os.path.dirname(__file__)
img_folder = os.path.join(game_folder, 'img')
player_img = pygame.image.load(os.path.join(img_folder, 'p1_jump.png')).convert()
WIDHT = 400
HEIGHT = 450
FPS = 30
WHITE = (255, 255, 255)
BLACK = (0, 0, 0)
RED = (255, 0, 0)
GREEN = (0, 255, 0)
BLUE = (0, 0, 255)
class Player(pygame.sprite.Sprite):
def __init__(self):
pygame.sprite.Sprite.__init__(self)
self.image = player_img
self.rect = self.image.get_rect()
self.rect.center = (WIDHT / 2, HEIGHT / 2)
def update(self):
self.rect.y += 5
if self.rect.top > HEIGHT:
self.rect.bottom = 0
pygame.init()
pygame.mixer.init()
screen = pygame.display.set_mode((WIDHT, HEIGHT))
pygame.display.set_caption("My game")
clock = pygame.time.Clock()
all_sprites = pygame.sprite.Group()
player = Player()
all_sprites.add(player)
running = True
while running:
clock.tick(FPS)
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
#Обновления
all_sprites.update()
screen.fill(BLACK)
all_sprites.draw(screen)
pygame.display.flip()
pygame.quit()