-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.py
More file actions
24 lines (21 loc) · 737 Bytes
/
utils.py
File metadata and controls
24 lines (21 loc) · 737 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import os
import pygame
from settings import PASTA_ASSETS
def carregar_imagem(nome_arquivo,tamanho=None):
caminho = os.path.join(PASTA_ASSETS,'sprites', nome_arquivo)
try:
imagem = pygame.image.load(caminho).convert_alpha()
if tamanho:
imagem = pygame.transform.scale(imagem, tamanho)
return imagem
except pygame.error as e:
print(f"Erro ao carregar imagem {nome_arquivo}: {e}")
return None
def carregar_som(nome_arquivo):
caminho = os.path.join(PASTA_ASSETS, 'sounds', nome_arquivo)
try:
som = pygame.mixer.Sound(caminho)
return som
except pygame.error as e:
print(f"Erro ao carregar som {nome_arquivo}: {e}")
return None