From 0ff2f9df9a7963d204a07d8d6623d309de8a2ae5 Mon Sep 17 00:00:00 2001 From: Sakse Dalum Date: Thu, 9 Aug 2012 15:22:42 +0200 Subject: [PATCH] Boulder now ignores player and vice versa. --- robotgame/boulder.py | 3 +++ robotgame/player.py | 3 +++ robotgame/worldobject.py | 5 ++++- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/robotgame/boulder.py b/robotgame/boulder.py index 80b4e9d..6cff2d3 100644 --- a/robotgame/boulder.py +++ b/robotgame/boulder.py @@ -28,6 +28,7 @@ import pygame import worldobject import block +import player class Boulder(worldobject.WorldObject): def __init__(self, level, x, y, direction=(1, 0), @@ -40,6 +41,8 @@ class Boulder(worldobject.WorldObject): self.frame = 0 self.anim_speed = 60 + self.ignore_list.append(player.Player) + def activate(self, setting): self.rolling = True diff --git a/robotgame/player.py b/robotgame/player.py index bd97c5d..a0e9271 100644 --- a/robotgame/player.py +++ b/robotgame/player.py @@ -29,6 +29,7 @@ import re import os import worldobject +import boulder class Player(worldobject.WorldObject): def __init__(self, level, x, y, z=1, movable=True): @@ -41,6 +42,8 @@ class Player(worldobject.WorldObject): self.frame = 0 self.anim_speed = 15 + self.ignore_list.append(boulder.Boulder) + self.load() def load(self): diff --git a/robotgame/worldobject.py b/robotgame/worldobject.py index d9e3cc2..cc178ff 100644 --- a/robotgame/worldobject.py +++ b/robotgame/worldobject.py @@ -41,6 +41,8 @@ class WorldObject(object): self.holding = None self.holder = None + self.ignore_list = [] + self.is_currently_opaque = True if hasattr(self, 'img'): @@ -73,7 +75,8 @@ class WorldObject(object): if (obj.x == self.x + move_x * self.tile_x 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.holding and obj.blocking): + and obj is not self.holding and obj.blocking + and type(obj) not in self.ignore_list): return False return True return False