62 lines
2.1 KiB
Python
62 lines
2.1 KiB
Python
import pygame
|
|
import random
|
|
from config import *
|
|
from agent import *
|
|
|
|
class Game:
|
|
|
|
def __init__(self):
|
|
pygame.init()
|
|
self.SCREEN = pygame.display.set_mode((WIDTH, HEIGHT))
|
|
self.running = True
|
|
self.clock = pygame.time.Clock()
|
|
|
|
|
|
# te wszystkie obrazki trzeba dać w oddzielnej klasie dla potworków jak coś później
|
|
self.ARCHER_ORK_IMG = pygame.image.load("./zdjecia/ork_lucznik.jpg")
|
|
self.INFATRY_ORK_IMG = pygame.image.load("./zdjecia/ork-piechota.jpg")
|
|
self.INFANTRY_ORK2_IMG = pygame.image.load("./zdjecia/ork-piechota2.jpg")
|
|
self.SAURON_JPG = pygame.image.load("./zdjecia/sauron.jpg")
|
|
|
|
|
|
self.ARCHER_ORK = pygame.transform.scale(self.ARCHER_ORK_IMG,(64,64))
|
|
self.INFATRY_ORK = pygame.transform.scale(self.INFATRY_ORK_IMG,(64,64))
|
|
self.INFANTRY_ORK2 = pygame.transform.scale(self.INFANTRY_ORK2_IMG,(64,64))
|
|
self.SAURON = pygame.transform.scale(self.SAURON_JPG,(64,64))
|
|
|
|
self.ORK_LIST = [self.ARCHER_ORK,self.INFANTRY_ORK2, self.INFATRY_ORK]
|
|
|
|
pygame.display.set_caption('Do_Nazwania')
|
|
|
|
def new(self): # tworzy się nowa sesja grania
|
|
self.all_sprites = pygame.sprite.LayeredUpdates()
|
|
self.agent = Agent(self,1,1)
|
|
|
|
def update(self): # update postaci na mapie, związane z poruszaniem się
|
|
self.all_sprites.update()
|
|
|
|
def events(self):
|
|
for event in pygame.event.get():
|
|
if event.type == pygame.QUIT:
|
|
self.running = False
|
|
pygame.quit()
|
|
|
|
def map(self): # tworzenie mapy
|
|
self.SCREEN.fill(BLACK)
|
|
self.all_sprites.draw(self.SCREEN)
|
|
self.clock.tick(FRAMERATE)
|
|
for x in range(0, WIDTH, TILE_SIZE):
|
|
for y in range(0, HEIGHT, TILE_SIZE):
|
|
self.rect = pygame.Rect(x, y, TILE_SIZE, TILE_SIZE)
|
|
pygame.draw.rect(self.SCREEN, WHITE, self.rect, 1)
|
|
pygame.display.update()
|
|
|
|
def main(self):
|
|
self.events()
|
|
self.update()
|
|
self.map()
|
|
|
|
g = Game()
|
|
g.new()
|
|
while g.running:
|
|
g.main() |