feat: spawning teams
This commit is contained in:
parent
84b17269e3
commit
352f5ecee9
@ -9,6 +9,10 @@ COLUMNS = 24
|
||||
BORDER_WIDTH = 10
|
||||
BORDER_RADIUS = 5
|
||||
FPS_COUNT = 60
|
||||
KNIGHTS_SPAWN_WIDTH = 4
|
||||
KNIGHTS_SPAWN_HEIGHT = 5
|
||||
KNIGHTS_SPAWN_FIRST_ROW = 8
|
||||
KNIGHTS_SPAWN_FIRST_COL = 0
|
||||
TILES = [
|
||||
'grass1.png',
|
||||
'grass2.png',
|
||||
|
@ -3,12 +3,13 @@ import sys
|
||||
import pygame
|
||||
|
||||
from common.colors import FONT_DARK, WHITE
|
||||
from common.constants import GAME_TITLE, WINDOW_WIDTH, WINDOW_HEIGHT, FPS_COUNT, TILES
|
||||
from common.constants import GAME_TITLE, WINDOW_WIDTH, WINDOW_HEIGHT, FPS_COUNT, TILES, COLUMNS, KNIGHTS_SPAWN_WIDTH, \
|
||||
KNIGHTS_SPAWN_FIRST_ROW, KNIGHTS_SPAWN_HEIGHT, KNIGHTS_SPAWN_FIRST_COL
|
||||
from common.helpers import draw_text
|
||||
from models.knight import Knight
|
||||
from models.monster import Monster
|
||||
from ui.screens.credits import Credits
|
||||
from ui.logs import Logs
|
||||
from ui.screens.credits import Credits
|
||||
from ui.screens.options import Options
|
||||
from ui.stats import Stats
|
||||
from .grid import Grid
|
||||
@ -85,17 +86,20 @@ class Game:
|
||||
grid = Grid(self.tiles)
|
||||
stats = Stats()
|
||||
logs = Logs()
|
||||
knight1 = Knight("./resources/textures/knight.png")
|
||||
knight2 = Knight("./resources/textures/knight.png")
|
||||
knight3 = Knight("./resources/textures/knight.png")
|
||||
knight4 = Knight("./resources/textures/knight.png")
|
||||
spawn = Spawner(grid, [knight1, knight2, knight3, knight4], 4, 5, 8, 0)
|
||||
spawn.spawn()
|
||||
knights_list = pygame.sprite.Group()
|
||||
knights_list.add(knight1)
|
||||
knights_list.add(knight2)
|
||||
knights_list.add(knight3)
|
||||
knights_list.add(knight4)
|
||||
|
||||
knights_sprite_group = pygame.sprite.Group()
|
||||
|
||||
knights_left = self.generate_knights_team(knights_sprite_group)
|
||||
knights_right = self.generate_knights_team(knights_sprite_group)
|
||||
|
||||
spawn_left_team = Spawner(grid, knights_left, width=KNIGHTS_SPAWN_WIDTH, height=KNIGHTS_SPAWN_HEIGHT,
|
||||
pos_row=KNIGHTS_SPAWN_FIRST_ROW, pos_column=KNIGHTS_SPAWN_FIRST_COL)
|
||||
spawn_right_team = Spawner(grid, knights_right, width=KNIGHTS_SPAWN_WIDTH, height=KNIGHTS_SPAWN_HEIGHT,
|
||||
pos_row=KNIGHTS_SPAWN_FIRST_ROW,
|
||||
pos_column=COLUMNS - KNIGHTS_SPAWN_WIDTH - 1) # - 1 to avoid list index out of range
|
||||
|
||||
spawn_left_team.spawn()
|
||||
spawn_right_team.spawn()
|
||||
|
||||
while running:
|
||||
self.screen.blit(self.bg, (0, 0))
|
||||
@ -112,9 +116,18 @@ class Game:
|
||||
stats.draw(self.screen)
|
||||
logs.draw(self.screen)
|
||||
|
||||
knights_list.draw(self.screen)
|
||||
knights_sprite_group.draw(self.screen)
|
||||
monster1 = Monster(self.screen, "./resources/textures/dragon.png")
|
||||
monster_list = pygame.sprite.Group()
|
||||
monster_list.add(monster1)
|
||||
pygame.display.update()
|
||||
self.clock.tick(FPS_COUNT)
|
||||
|
||||
@staticmethod
|
||||
def generate_knights_team(knights_sprite_group):
|
||||
knights = []
|
||||
for i in range(4):
|
||||
knight = Knight("./resources/textures/knight.png")
|
||||
knights.append(knight)
|
||||
knights_sprite_group.add(knight)
|
||||
return knights
|
||||
|
Loading…
Reference in New Issue
Block a user