forked from makazis/Placeholdeer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
enemy.py
38 lines (33 loc) · 1.07 KB
/
enemy.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
from entity import *
from enemy import *
import random
import pygame
class EnemyController:
def __init__(self, x, y, width, height, color):
self.entity=Entity("Pis Dirst")
self.entity.active=True
self.speed=10
self.entity.health_level=100
self.x=self.entity.x
self.z=self.entity.z
self.state={}
self.heightmap=None
self.direction = 'right'
self.width=width
self.height=height
self.color=color
self.rect = pygame.Rect(x, y, width, height)
self.color = color
def enemyMove(self):
if self.direction == 'right':
self.x += self.speed
elif self.direction == 'left':
self.x -= self.speed
elif self.direction == 'up':
self.z -= self.speed
elif self.direction == 'down':
self.z += self.speed
if random.randint(0, 100) < 10:
self.direction = random.choice(['up', 'down', 'left', 'right'])
def draw(self, screen):
pygame.draw.rect(screen, self.color, self.rect)