-
Notifications
You must be signed in to change notification settings - Fork 36
Expand file tree
/
Copy pathhelpers.py
More file actions
38 lines (33 loc) · 989 Bytes
/
helpers.py
File metadata and controls
38 lines (33 loc) · 989 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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
"""
@ilya-besancon
helper functions for PyMan
"""
import os, sys
import pygame
from pygame.locals import*
def load_image(name, colorkey=None):
fullname = os.path.join('data', name)
try:
# image = pygame.image.load(fullname)
image = pygame.image.load(os.path.join("images", name)).convert()
except pygame.error as message:
print('Cannot load image:', name)
raise SystemExit(message)
image = image.convert()
if colorkey is not None:
if colorkey is -1:
colorkey = image.get_at((0, 0))
image.set_colorkey(colorkey, RLEACCEL)
return image, image.get_rect()
def load_sound(name):
class NoneSound:
def play(self): pass
if not pygame.mixer:
return NoneSound()
fullname = os.path.join('data', name)
try:
sound = pygame.mixer.Sound(fullname)
except pygame.error as message:
print('Cannot load sound:', wav)
raise SystemExit(message)
return sound