Implemented all robot lever pull/push animations.
This commit is contained in:
parent
3c8d203606
commit
b76b0924f1
|
@ -64,27 +64,41 @@ class Player(worldobject.WorldObject):
|
|||
|
||||
# Lever
|
||||
|
||||
('lever_down_right', os.path.join('robot_lever', 'down_left')),
|
||||
('lever_down_left', os.path.join('robot_lever', 'down_left')),
|
||||
('lever_down_up', os.path.join('robot_lever', 'vertical_down')),
|
||||
('lever_down_down', os.path.join('robot_lever', 'vertical_down')),
|
||||
('lever_down_right', os.path.join('robot_lever', 'horizontal',
|
||||
'down_left')),
|
||||
('lever_down_left', os.path.join('robot_lever', 'horizontal',
|
||||
'down_left')),
|
||||
('lever_down_up', os.path.join('robot_lever', 'vertical',
|
||||
'down_down')),
|
||||
('lever_down_down', os.path.join('robot_lever', 'vertical',
|
||||
'down_down')),
|
||||
|
||||
('lever_right_right', os.path.join('robot_lever',
|
||||
'right_horizontal')),
|
||||
('lever_right_left', os.path.join('robot_lever',
|
||||
'right_horizontal')),
|
||||
('lever_right_up', os.path.join('robot_lever', 'right_down')),
|
||||
('lever_right_down', os.path.join('robot_lever', 'right_down')),
|
||||
('lever_up_right', os.path.join('robot_lever', 'horizontal',
|
||||
'up_right')),
|
||||
('lever_up_left', os.path.join('robot_lever', 'horizontal',
|
||||
'up_right')),
|
||||
('lever_up_up', os.path.join('robot_lever', 'vertical',
|
||||
'up_up')),
|
||||
('lever_up_down', os.path.join('robot_lever', 'vertical',
|
||||
'up_up')),
|
||||
|
||||
('lever_up_right', os.path.join('robot_lever', 'up_right')),
|
||||
('lever_up_left', os.path.join('robot_lever', 'up_right')),
|
||||
('lever_up_up', os.path.join('robot_lever', 'vertical_up')),
|
||||
('lever_up_down', os.path.join('robot_lever', 'vertical_up')),
|
||||
('lever_right_right', os.path.join('robot_lever', 'horizontal',
|
||||
'right_right')),
|
||||
('lever_right_left', os.path.join('robot_lever', 'horizontal',
|
||||
'right_right')),
|
||||
('lever_right_up', os.path.join('robot_lever', 'vertical',
|
||||
'left_up')),
|
||||
('lever_right_down', os.path.join('robot_lever', 'vertical',
|
||||
'right_down')),
|
||||
|
||||
('lever_left_right', os.path.join('robot_lever', 'right_down')),
|
||||
('lever_left_left', os.path.join('robot_lever', 'right_down')),
|
||||
('lever_left_up', os.path.join('robot_lever', 'right_down')),
|
||||
('lever_left_down', os.path.join('robot_lever', 'right_down'))
|
||||
('lever_left_right', os.path.join('robot_lever', 'horizontal',
|
||||
'right_right')),
|
||||
('lever_left_left', os.path.join('robot_lever', 'horizontal',
|
||||
'left_left')),
|
||||
('lever_left_up', os.path.join('robot_lever', 'vertical',
|
||||
'left_up')),
|
||||
('lever_left_down', os.path.join('robot_lever', 'vertical',
|
||||
'right_down'))
|
||||
]
|
||||
):
|
||||
|
||||
|
@ -104,11 +118,16 @@ class Player(worldobject.WorldObject):
|
|||
|
||||
# Special treatment:
|
||||
if anim in ['idle_left', 'carry_left',
|
||||
|
||||
'lever_down_right', 'lever_left_down',
|
||||
'lever_up_left']:
|
||||
'lever_up_left', 'lever_right_up']:
|
||||
img = pygame.transform.flip(img, 1, 0)
|
||||
|
||||
self.imgs[anim].append(img)
|
||||
if anim in ['lever_right_left', 'lever_left_right',
|
||||
'lever_down_up', 'lever_up_down']:
|
||||
self.imgs[anim].insert(0, img)
|
||||
else:
|
||||
self.imgs[anim].append(img)
|
||||
|
||||
self.img = self.imgs[self.anim_root + '_' + self.anim][int(self.frame)]
|
||||
|
||||
|
@ -135,11 +154,12 @@ class Player(worldobject.WorldObject):
|
|||
|
||||
# List all possible combinations ...
|
||||
lever_direction = (
|
||||
'up' if obj.anim == 'lever_updown' and obj.setting
|
||||
'up' if obj.anim == 'lever_updown' and not obj.setting
|
||||
else
|
||||
'right' if obj.anim == 'lever_leftright' and obj.setting
|
||||
'right' if obj.anim == 'lever_leftright'
|
||||
and not obj.setting
|
||||
else
|
||||
'down' if obj.anim == 'lever_updown' and not obj.setting
|
||||
'down' if obj.anim == 'lever_updown' and obj.setting
|
||||
else
|
||||
'left')
|
||||
|
||||
|
@ -152,11 +172,6 @@ class Player(worldobject.WorldObject):
|
|||
if not self.working:
|
||||
self.anim_root = 'carry' if self.holding else 'idle'
|
||||
|
||||
for event in e:
|
||||
if event.type == pygame.KEYDOWN:
|
||||
if event.key == pygame.K_SPACE:
|
||||
self.touch(*self.direction)
|
||||
|
||||
keys = pygame.key.get_pressed()
|
||||
if keys[pygame.K_UP]:
|
||||
if not self.holding and not self.is_moving:
|
||||
|
@ -179,6 +194,11 @@ class Player(worldobject.WorldObject):
|
|||
self.anim = self.direction_as_string()
|
||||
self.move(-1, 0)
|
||||
|
||||
for event in e:
|
||||
if event.type == pygame.KEYDOWN:
|
||||
if event.key == pygame.K_SPACE:
|
||||
self.touch(*self.direction)
|
||||
|
||||
else:
|
||||
self.working = not (self.frame == len(
|
||||
self.imgs[self.anim_root + '_' + self.anim]) - 1)
|
||||
|
@ -201,7 +221,11 @@ class Player(worldobject.WorldObject):
|
|||
def draw(self, window):
|
||||
self.img = self.imgs[self.anim_root + '_' + self.anim][int(self.frame)]
|
||||
self.img.set_alpha(128)
|
||||
window.blit(self.img, (self.x - 32 - self.level.camera_x,
|
||||
offset_x = (96 if self.anim_root == 'lever' and self.anim in
|
||||
['left_up', 'left_left', 'left_down', 'left_right',
|
||||
'down_right', 'up_left']
|
||||
else 32)
|
||||
window.blit(self.img, (self.x - offset_x - self.level.camera_x,
|
||||
self.y - self.img.get_size()[1] + 24
|
||||
- self.level.camera_y))
|
||||
|
||||
|
|
Loading…
Reference in New Issue