Made boulder fall into holes.
This commit is contained in:
parent
9c86aa3dfb
commit
58cfb15c21
|
@ -37,35 +37,51 @@ class Boulder(worldobject.WorldObject):
|
|||
worldobject.WorldObject.__init__(self, level, x, y, direction=direction,
|
||||
movable=movable, speed=4)
|
||||
|
||||
self.falling = False
|
||||
|
||||
self.anim = 'boulder_right'
|
||||
self.frame = 0
|
||||
self.anim_speed = 60
|
||||
|
||||
self.ignore_list.append(player.Player)
|
||||
|
||||
def fall(self, setting):
|
||||
if setting:
|
||||
self.frame = 0
|
||||
self.falling = True
|
||||
|
||||
def activate(self, setting):
|
||||
self.rolling = True
|
||||
|
||||
def reset_pos(self):
|
||||
worldobject.WorldObject.reset_pos(self)
|
||||
self.frame = 0
|
||||
self.rolling = False
|
||||
self.falling = False
|
||||
|
||||
def update(self, e, t, dt):
|
||||
# Update the animation
|
||||
if self.rolling:
|
||||
self.frame = ((self.frame + self.anim_speed * dt) %
|
||||
len(self.level.imgs[self.anim]))
|
||||
if self.falling:
|
||||
self.frame = min(self.frame + self.anim_speed * dt,
|
||||
len(self.level.imgs[self.anim]) - 1)
|
||||
|
||||
if self.direction == (1, 0):
|
||||
if self.falling:
|
||||
self.anim = 'boulder_falling'
|
||||
if self.frame == len(self.level.imgs[self.anim]) - 1:
|
||||
self.reset_pos()
|
||||
elif self.direction == (1, 0):
|
||||
self.anim = 'boulder_right'
|
||||
if self.direction == (0, 1):
|
||||
elif self.direction == (0, 1):
|
||||
self.anim = 'boulder_down'
|
||||
if self.direction == (-1, 0):
|
||||
elif self.direction == (-1, 0):
|
||||
self.anim = 'boulder_left'
|
||||
if self.direction == (0, -1):
|
||||
elif self.direction == (0, -1):
|
||||
self.anim = 'boulder_up'
|
||||
|
||||
if self.rolling:
|
||||
if self.rolling and not self.falling:
|
||||
if not self.is_moving:
|
||||
tile_sharer = self.share_tile(block.ArrowBlock)
|
||||
if tile_sharer:
|
||||
|
|
|
@ -185,7 +185,7 @@ class Level1(level.Level):
|
|||
self.objects.append(
|
||||
trigger.Trigger(self, task2_pos[0] + 64 * (task2_size[0]),
|
||||
task2_pos[1] + 48 * (task2_size[1] - 1),
|
||||
[self.complete_task],
|
||||
[self.complete_task, b.fall],
|
||||
self.imgs['hole'], [b],
|
||||
signal=[0, 2]))
|
||||
|
||||
|
@ -243,7 +243,7 @@ class Level1(level.Level):
|
|||
|
||||
self.objects.append(trigger.Trigger(self, task4_pos[0] + 64 * 8,
|
||||
task4_pos[1] - 48 * 3,
|
||||
[self.complete_task],
|
||||
[self.complete_task, b.fall],
|
||||
self.imgs['hole'], [b],
|
||||
signal=[0, 4]))
|
||||
|
||||
|
@ -312,6 +312,7 @@ class Level1(level.Level):
|
|||
('boulder_down', os.path.join('boulder', 'down')),
|
||||
('boulder_right', os.path.join('boulder', 'right')),
|
||||
('boulder_left', os.path.join('boulder', 'right')),
|
||||
('boulder_falling', os.path.join('boulder_fall')),
|
||||
|
||||
('lever_updown', os.path.join('lever', 'down-up')),
|
||||
('lever_leftright', os.path.join('lever', 'left-right')),
|
||||
|
|
Loading…
Reference in New Issue