arctic-masher/enemies.py

27 lines
709 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 globals 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:
def __init__(self, id, x, y):
2023-05-17 12:42:21 +00:00
self.id = id
2023-05-17 11:52:05 +00:00
self.x = x
self.y = y
2023-05-17 11:52:05 +00:00
2023-05-17 12:42:21 +00:00
def die(self):
del enemies[self.id]
2023-05-17 12:42:21 +00:00
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(gameMap[self.x + x][self.y + y], Block):
2023-05-17 12:42:21 +00:00
self.die()
return
raise Exception("Not crushing enemy!")
def move(self, x, y):
pass