Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class enemy():
- def __init__(self, x, y, color, radius, end):
- self.x = x
- self.y = y
- self.color = color
- self.radius = radius
- self.end = end
- self.path = [self.x, self.end]
- self.walkCount = 0
- self.vel = 3
- #Remember to change and fix the draw function once I've got the sprites
- def draw(self, gameWindow):
- self.move()
- if self.walkCount + 1 <= 33:
- self.walkCount = 0
- if self.vel > 0:
- pygame.draw.circle(gameWindow, self.color, (self.x, self.y), self.radius, 0)
- self.walkCount += 1
- else:
- pygame.draw.circle(gameWindow, self.color, (self.x, self.y), self.radius, 0)
- self.walkCount += 1
- #The function is supposed to move the enemy by comparing their coordinates with the limits passed to the variable "self.path"
- def move(self):
- if self.vel > 0:
- if self.x + self.vel < self.path[1]:
- self.x += self.vel
- else:
- self.vel = self.vel * -1
- self.walkCount = 0
- else:
- if self.x - self.vel > self.path[0]:
- self.x += self.vel
- else:
- self.vel = self.vel * -1
- self.walkCount = 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement