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
|
|
|
|
2023-05-17 13:05:04 +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:
|
2023-05-17 13:05:04 +00:00
|
|
|
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 13:05:04 +00:00
|
|
|
|
2023-05-17 11:52:05 +00:00
|
|
|
|
2023-05-17 12:42:21 +00:00
|
|
|
def die(self):
|
2023-05-17 13:05:04 +00:00
|
|
|
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
|
2023-05-17 13:05:04 +00:00
|
|
|
if wallCrush or isinstance(gameMap[self.x + x][self.y + y], Block):
|
2023-05-17 12:42:21 +00:00
|
|
|
self.die()
|
|
|
|
return
|
2023-05-17 13:05:04 +00:00
|
|
|
raise Exception("Not crushing enemy!")
|
|
|
|
|
|
|
|
def move(self, x, y):
|
|
|
|
pass
|