get resource in path; no frame sprite
This commit is contained in:
parent
6340c4c009
commit
c9f60047c1
|
@ -47,9 +47,11 @@ class GameChild:
|
|||
def get_delegate(self):
|
||||
return self.game.delegate
|
||||
|
||||
def get_resource(self, section, option):
|
||||
def get_resource(self, path_or_section, option=None):
|
||||
config = self.get_configuration()
|
||||
rel_path = config.get(section, option)
|
||||
rel_path = path_or_section
|
||||
if option is not None:
|
||||
rel_path = config.get(path_or_section, option)
|
||||
if rel_path:
|
||||
for root in config.get("setup", "resource-search-path"):
|
||||
if self.is_shared_mode() and not self.is_absolute_path(root):
|
||||
|
@ -57,8 +59,8 @@ class GameChild:
|
|||
path = join(root, rel_path)
|
||||
if exists(path):
|
||||
return path
|
||||
self.print_debug("Couldn't find resource: {0}, {1}".\
|
||||
format(section, option))
|
||||
self.print_debug("Couldn't find resource: {0} {1}".\
|
||||
format(path_or_section, option))
|
||||
|
||||
def is_shared_mode(self):
|
||||
return self.check_command_line("s")
|
||||
|
|
|
@ -99,7 +99,7 @@ class Input(GameChild):
|
|||
return True
|
||||
joystick = self.joystick
|
||||
joy_map = self.joy_button_map
|
||||
if command in joy_map and joystick.js.get_button(joy_map[command]):
|
||||
if command in joy_map and joystick.get_button(joy_map[command]):
|
||||
return True
|
||||
if command == "up":
|
||||
return joystick.is_direction_pressed(Joystick.up)
|
||||
|
@ -160,3 +160,7 @@ class Joystick:
|
|||
return js.get_axis(1) > 0
|
||||
elif direction == 3:
|
||||
return js.get_axis(0) < 0
|
||||
|
||||
def get_button(self, id):
|
||||
if self.js:
|
||||
return self.js.get_button(id)
|
||||
|
|
|
@ -34,14 +34,14 @@ class Sprite(Animation):
|
|||
if ppa:
|
||||
frame = img.convert_alpha()
|
||||
else:
|
||||
if not key:
|
||||
key = (255, 0, 255)
|
||||
frame = self.fill_colorkey(img, key)
|
||||
else:
|
||||
frame = img.convert()
|
||||
self.add_frame(frame)
|
||||
|
||||
def fill_colorkey(self, img, key):
|
||||
def fill_colorkey(self, img, key=None):
|
||||
if not key:
|
||||
key = (255, 0, 255)
|
||||
img = img.convert_alpha()
|
||||
frame = Surface(img.get_size())
|
||||
frame.fill(key)
|
||||
|
@ -68,7 +68,8 @@ class Sprite(Animation):
|
|||
self.increment_frame_index()
|
||||
|
||||
def get_current_frame(self):
|
||||
return self.frames[self.frame_index]
|
||||
if self.frames:
|
||||
return self.frames[self.frame_index]
|
||||
|
||||
def increment_frame_index(self):
|
||||
index = self.frame_index + 1
|
||||
|
@ -111,8 +112,9 @@ class Sprite(Animation):
|
|||
self.frames = []
|
||||
|
||||
def update(self):
|
||||
Animation.update(self)
|
||||
self.draw()
|
||||
if self.frames:
|
||||
Animation.update(self)
|
||||
self.draw()
|
||||
|
||||
def draw(self):
|
||||
self.display_surface.blit(self.get_current_frame(), self.rect)
|
||||
|
|
Loading…
Reference in New Issue