arctic-masher/enemies.py

24 lines
687 B
Python
Raw Normal View History

2023-05-17 11:52:05 +00:00
import pygame
2023-05-17 12:42:21 +00:00
import uuid
2023-05-17 11:52:05 +00:00
from constants import *
2023-05-17 12:42:21 +00:00
from player import *
from blocks import *
2023-05-17 11:52:05 +00:00
class Enemy:
2023-05-17 12:42:21 +00:00
def __init__(self, id, x, y, gameMap):
self.id = id
2023-05-17 11:52:05 +00:00
self.x = x
self.y = y
self.gameMap = gameMap
2023-05-17 12:42:21 +00:00
def die(self):
pass
2023-05-17 11:52:05 +00:00
def pushed(self, x, y, caller, pusher):
2023-05-17 12:42:21 +00:00
if isinstance(pusher, Player) and isinstance(caller, Block):
wallCrush = self.x + x > tileCountx - 1 or self.y + y > tileCounty - 1 or self.x + x < 0 or self.y + y < 0
if wallCrush or isinstance(self.gameMap[self.x + x][self.y + y], Block):
self.die()
return
raise Exception("Not crushing enemy!")