From ef798b02e7a80c2cec1422c4ea7fcc37e1c68950 Mon Sep 17 00:00:00 2001 From: jonspacz Date: Thu, 2 Apr 2020 13:38:14 +0200 Subject: [PATCH] Added method to collidable to check if a collision occurred. Added = None to each attribute in Entity to stop errors from showing --- src/entities/Collidable.py | 10 ++++++++-- src/entities/Entity.py | 7 ++++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/entities/Collidable.py b/src/entities/Collidable.py index ebe0f2f..6f391df 100644 --- a/src/entities/Collidable.py +++ b/src/entities/Collidable.py @@ -1,5 +1,11 @@ -import src.entities.Entity as Entity +from src.entities.Entity import Entity class Collidable(Entity): - pass + + def check_for_collision(self, x_pos, y_pos): + if self.pos[0] == x_pos: + if self.pos[1] == y_pos: + return True + + return False diff --git a/src/entities/Entity.py b/src/entities/Entity.py index b9d4d43..cc2ee36 100644 --- a/src/entities/Entity.py +++ b/src/entities/Entity.py @@ -1,5 +1,6 @@ class Entity: + def __init__(self): - self.texture - self.pos - self.id + self.texture = None + self.pos = None + self.id = None