File: enemy.py

package info (click to toggle)
funnyboat 1.5-11
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 4,368 kB
  • sloc: python: 2,153; makefile: 5; sh: 3
file content (43 lines) | stat: -rw-r--r-- 813 bytes parent folder | download | duplicates (5)
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
39
40
41
42
43
import pygame
import math

from water import Water

import util

from locals import *

class Enemy(pygame.sprite.Sprite):
    def __init__(self, pos = [0.0, 0.0], health = 1):
        pygame.sprite.Sprite.__init__(self)

        self.pos = pos
        self.velocity [0.0, 0.0]

        self.health = health

        #self.hitmask = pygame.surfarray.array_alpha(self.image)

        self.angle = 0
        self.targetangle = 0
        self.dying = False
        self.dead = False

        self.t = 0

    def damage(self):
        self.health -= 1

        if self.health == 0:
            self.die()

    def update(self):
        self.t += 1

        self.velocity[1] += 1.0 # Gravity

        self.pos[0] += self.velocity[0]
        self.pos[1] += self.velocity[1]

    def die(self):
        self.dying = True