summaryrefslogtreecommitdiff
path: root/src/sliceitoff/enemies/ball.py
blob: b8c846712acc35d597ffa25b35c0254bb1af94dc (plain)
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
""" enemies.ball - Enemy type that goes straight line hitting walls """
from random import randrange, choice

from text import get_letter_surface
from .enemy import Enemy

BALL_SPAWN_AREA = (0, 0, 300_000, 200_000)
BALL_MOVEMENT = (100, 100)
BALL_SYMBOLS = (0x1,0x2)
BALL_SIZE = 8_000

class EnemyBall(Enemy):
    """ Basic type of enemy. """
    def __init__(self):
        super().__init__()
        self.position = (
                randrange(BALL_SPAWN_AREA[0], BALL_SPAWN_AREA[2]),
                randrange(BALL_SPAWN_AREA[1], BALL_SPAWN_AREA[3]))
        self.movement = (
                randrange(0, BALL_MOVEMENT[0]*2) - BALL_MOVEMENT[0],
                randrange(0, BALL_MOVEMENT[1]*2) - BALL_MOVEMENT[1])
        font_key = ('8x8', BALL_SIZE, 0)
        surface = get_letter_surface(font_key, choice(BALL_SYMBOLS))
        self.image = surface.subsurface(
                (0, 0, surface.get_rect().w, surface.get_rect().w))
        self.update()
        self.rect = None