import pygame class Wall: def __init__(self, x, y, height, width): self.x = x self.y = y self.height = height self.width = width self.halfH = height / 2 self.halfW = width / 2 def isPointOnWall(self, x, y): xIsInBetween = self.x - self.halfW <= x and x <= self.x + self.halfW yIsInBetween = self.y - self.halfH <= y and y <= self.y + self.halfH return xIsInBetween and yIsInBetween def draw(self, screen): pygame.draw.rect( screen, (0, 0, 0), (self.x - self.halfW, self.y - self.halfH, self.width, self.height) )