66 lines
2.2 KiB
Python
66 lines
2.2 KiB
Python
import pygame
|
|
from config import *
|
|
from agent import *
|
|
from map_add_ons import *
|
|
from archer_ork import *
|
|
from infantry_ork import *
|
|
from infantry_ork2 import *
|
|
from sauron import *
|
|
|
|
class Game:
|
|
|
|
def __init__(self):
|
|
pygame.init()
|
|
self.SCREEN = pygame.display.set_mode((WIDTH, HEIGHT))
|
|
self.running = True
|
|
self.clock = pygame.time.Clock()
|
|
|
|
self.BACKGROUND_IMG= pygame.image.load("./zdjecia/podloze.jpg")
|
|
self.BACKGROUND = pygame.transform.scale(self.BACKGROUND_IMG,(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.rock_sprites = pygame.sprite.Group()
|
|
self.agent = Agent(self,1,1)
|
|
self.archer_ork = Archer_ork(self,10,10)
|
|
self.infantry_ork = Infantry_ork(self,5,10)
|
|
self.infantry_ork2 = Infantry_ork2(self,6,9)
|
|
self.sauron = Sauron(self, 1, 10)
|
|
for y in range(5):
|
|
self.rock = Rocks(self,3,y)
|
|
|
|
def update(self): # update postaci na mapie, związane z poruszaniem się
|
|
self.all_sprites.update()
|
|
pygame.sprite.spritecollide(self.agent, self.rock_sprites, True)
|
|
#ograniczyć ruch agenta gdy jest kolizja ze skałami
|
|
|
|
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.clock.tick(FRAMERATE)
|
|
for x in range(0, WIDTH, TILE_SIZE):
|
|
for y in range(0, HEIGHT, TILE_SIZE):
|
|
self.SCREEN.blit(self.BACKGROUND,(x,y))
|
|
self.rect = pygame.Rect(x, y, TILE_SIZE, TILE_SIZE)
|
|
pygame.draw.rect(self.SCREEN, BLACK, self.rect, 1)
|
|
self.all_sprites.draw(self.SCREEN)
|
|
self.rock_sprites.draw(self.SCREEN)
|
|
pygame.display.update()
|
|
|
|
def main(self):
|
|
self.events()
|
|
self.update()
|
|
self.map()
|
|
|
|
g = Game()
|
|
g.new()
|
|
while g.running:
|
|
g.main() |