Example #1
0
 def createEnemy(self, z, x, y):
     temp = Enemy(z, x, y, self.p)
     temp.blocks = self.blocks
     temp.hazards = self.p.hazards
     self.p.enemies.add(temp)
     self.e.drawables.add(temp)
     self.e.objects.append(temp)
Example #2
0
    def __init__(self, left, top, width=VIRUS_WIDTH, height=VIRUS_HEIGHT):
        Enemy.__init__(self, left, top, width, height)
        self.sprite = pygame.transform.scale(self.VIRUS_SPRITE_IMAGE,
                                             (width, height))
        self.direction = self.generate_random_direction()

        self.hitbox = pygame.Rect(left, top, width, height)
        self.health = 10
        self.damage = 5
        self.damaged_sound = pygame.mixer.Sound(
            os.path.join("assets", "sounds", "Enemy_Damage.wav"))
        self.damaged_sound.set_volume(0.5)
        self.dies_sound = pygame.mixer.Sound(
            os.path.join("assets", "sounds", "Enemy_Dies.wav"))
        self.dies_sound.set_volume(0.5)
        self.i_frame = None
        self.invincible = False
Example #3
0
    def create_fleet(self):
        for enemy_number in range(self.number_enemies_x):
            for number_row in range(self.number_of_rows):
                # Create an alien and place it in the row
                random_number = random.randint(0, 2)
                if random_number is 0:
                    new_enemy = Enemy(self.hub)
                elif random_number is 1:
                    new_enemy = EnemyTwo(self.hub)
                elif random_number is 2:
                    new_enemy = EnemyThree(self.hub)
                else:
                    new_enemy = Enemy(self.hub)

                new_enemy.rect.x = self.enemy.rect.width + 2 * self.enemy.rect.width * enemy_number
                new_enemy.rect.y = self.enemy.rect.height + 2 * self.enemy.rect.height * number_row
                self.enemies.add(new_enemy)
Example #4
0
    def spawn_randomly(self):
        enemy = Enemy(random.randint(10, self.size[0] - 10),
                      random.randint(1, self.size[1] - 10))
        enemy.add_listener('remove', self.remove)
        enemy.add_listener('pointed', self.playerPoints.increment)

        self.enemies.append(enemy)
Example #5
0
    def __init__(self, hub):
        """ Initializing default values """
        self.hub = hub
        self.screen = self.hub.main_screen
        # Initialize player ship: This will be remove as we will loading in levels soon
        self.player_ship = Ship(self.hub)

        # Create a group for bullets
        self.bullets = Group()

        # Create a group for enemies
        self.enemies = Group()

        # Create a group for player destruction
        self.destructions = Group()

        # Create a group for enemy destruction
        self.enemy_destructions = Group()

        # Create a group for random ufos
        self.ufos = Group()

        # Create a group for walls
        self.walls = Group()
        # Wall is only initialize onced during the entire game.
        self.create_walls()

        # Create enemy bullets when spawned
        self.enemy_bullets = Group()

        # Get a test enemy to get size and width
        self.enemy = Enemy(self.hub)

        self.available_space_x = self.hub.WINDOW_WIDTH - 2 * self.enemy.rect.width
        self.number_enemies_x = int(self.available_space_x / (2 * self.enemy.rect.width))
        self.number_of_rows = 3

        # Create score board
        self.sb = ScoreBoard(self.hub)

        # Background Image
        self.bg_image = pygame.image.load('imgs/Backgrounds/black.png')
        self.bg_image = pygame.transform.scale(self.bg_image, (self.hub.WINDOW_WIDTH, self.hub.WINDOW_HEIGHT))
        self.bg_rect = self.bg_image.get_rect()
Example #6
0
BG_COLOR = (255, 153, 123)

# 1. Init pygame
pygame.init()

# 2. Game window & canvas
SIZE = (600, 800)
canvas = pygame.display.set_mode(SIZE)

# 3. Clock
clock = pygame.time.Clock()

input_manager = InputManager()
player = Player(10, 300, input_manager)
enemy = Enemy(200, 80)

add(player)
add(enemy)

# 3. Game loop
loop = True
right_pressed = False
left_pressed = False

# 1: Describe input
# 2: Give it player

while loop:
    # Game Loop 1: Events
    events = pygame.event.get()
Example #7
0
from enemies.enemy import Enemy

BG_COLOR = (255, 0, 0)

# 1. Init pygame
pygame.init()

# 2. Game window & canvas
SIZE = (600, 800)
canvas = pygame.display.set_mode(SIZE)

# 3. Clock
clock = pygame.time.Clock()

player = Player(10, 300)
enemy = Enemy(200, 80)

# 3. Game loop
loop = True
right_pressed = False
left_pressed = False
while loop:
    # Game Loop 1: Events
    events = pygame.event.get()
    for event in events:
        if event.type == pygame.QUIT:
            loop = False
        elif event.type == pygame.KEYDOWN:
            if event.key == pygame.K_RIGHT:
                right_pressed = True
            elif event.key == pygame.K_LEFT:
Example #8
0
from enemies.enemy import Enemy
from inputs.inputs_manager import InputManager
import game_object

pygame.init()

# setup game window
size = (600, 800)  # pixels
canvas = pygame.display.set_mode(size)
input_manager = InputManager()
# Clock
clock = pygame.time.Clock()
loop = True

player = Player(30, 30, input_manager)
enemy = Enemy(60, 60)

game_object.add(player)
game_object.add(enemy)

while loop:
    # events

    # quit
    # mouse
    # key
    events = pygame.event.get()
    for event in events:
        if event.type == pygame.QUIT:
            loop = False
        else: