Boulder now ignores player and vice versa.

This commit is contained in:
Sakse Dalum 2012-08-09 15:22:42 +02:00
parent a69281f5e1
commit 0ff2f9df9a
3 changed files with 10 additions and 1 deletions

View File

@ -28,6 +28,7 @@ import pygame
import worldobject import worldobject
import block import block
import player
class Boulder(worldobject.WorldObject): class Boulder(worldobject.WorldObject):
def __init__(self, level, x, y, direction=(1, 0), def __init__(self, level, x, y, direction=(1, 0),
@ -40,6 +41,8 @@ class Boulder(worldobject.WorldObject):
self.frame = 0 self.frame = 0
self.anim_speed = 60 self.anim_speed = 60
self.ignore_list.append(player.Player)
def activate(self, setting): def activate(self, setting):
self.rolling = True self.rolling = True

View File

@ -29,6 +29,7 @@ import re
import os import os
import worldobject import worldobject
import boulder
class Player(worldobject.WorldObject): class Player(worldobject.WorldObject):
def __init__(self, level, x, y, z=1, movable=True): def __init__(self, level, x, y, z=1, movable=True):
@ -41,6 +42,8 @@ class Player(worldobject.WorldObject):
self.frame = 0 self.frame = 0
self.anim_speed = 15 self.anim_speed = 15
self.ignore_list.append(boulder.Boulder)
self.load() self.load()
def load(self): def load(self):

View File

@ -41,6 +41,8 @@ class WorldObject(object):
self.holding = None self.holding = None
self.holder = None self.holder = None
self.ignore_list = []
self.is_currently_opaque = True self.is_currently_opaque = True
if hasattr(self, 'img'): if hasattr(self, 'img'):
@ -73,7 +75,8 @@ class WorldObject(object):
if (obj.x == self.x + move_x * self.tile_x if (obj.x == self.x + move_x * self.tile_x
and obj.y == self.y + move_y * self.tile_y and obj.y == self.y + move_y * self.tile_y
and obj is not self and obj is not self.holder and obj is not self and obj is not self.holder
and obj is not self.holding and obj.blocking): and obj is not self.holding and obj.blocking
and type(obj) not in self.ignore_list):
return False return False
return True return True
return False return False