2022-03-04 20:10:55 +01:00
|
|
|
import pygame
|
2022-03-04 20:57:34 +01:00
|
|
|
from glob import glob
|
|
|
|
|
|
|
|
from grid import Grid
|
2022-03-04 21:01:05 +01:00
|
|
|
from constants import GAME_TITLE, WINDOW_WIDTH, WINDOW_HEIGHT, FPS_COUNT
|
2022-03-04 20:10:55 +01:00
|
|
|
|
|
|
|
|
|
|
|
class Game:
|
|
|
|
def __init__(self):
|
|
|
|
pygame.init()
|
|
|
|
pygame.display.set_caption(GAME_TITLE)
|
|
|
|
pygame.display.set_icon(pygame.image.load('resources/icons/sword.png'))
|
2022-03-04 20:57:34 +01:00
|
|
|
|
2022-03-04 20:10:55 +01:00
|
|
|
self.screen = pygame.display.set_mode((WINDOW_HEIGHT, WINDOW_WIDTH))
|
|
|
|
self.clock = pygame.time.Clock()
|
|
|
|
|
2022-03-04 20:57:34 +01:00
|
|
|
self.textures = []
|
|
|
|
for texture_path in glob('resources/textures/*.jpg'):
|
|
|
|
converted_texture = pygame.image.load(texture_path).convert_alpha()
|
|
|
|
self.textures.append((texture_path, converted_texture))
|
|
|
|
|
2022-03-04 20:10:55 +01:00
|
|
|
def start(self):
|
|
|
|
running = True
|
2022-03-04 20:57:34 +01:00
|
|
|
grid = Grid(self.textures)
|
2022-03-04 20:10:55 +01:00
|
|
|
while running:
|
|
|
|
for event in pygame.event.get():
|
|
|
|
if event.type == pygame.QUIT:
|
|
|
|
running = False
|
2022-03-04 20:57:34 +01:00
|
|
|
grid.draw(self.screen)
|
2022-03-04 20:10:55 +01:00
|
|
|
pygame.display.update()
|
|
|
|
self.clock.tick(FPS_COUNT)
|
|
|
|
pygame.quit()
|