dodanie mobów na mapie

This commit is contained in:
Weranda 2023-03-30 19:54:48 +02:00
parent 4a335218c0
commit ea957fac37
13 changed files with 122 additions and 13 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -28,7 +28,7 @@ class Agent(pygame.sprite.Sprite):
self.rect.x = self.x
self.rect.y = self.y
self.health = 100
self.level = 1
def update(self):
self.movement()

28
archer_ork.py Normal file
View File

@ -0,0 +1,28 @@
import pygame
from config import *
class Archer_ork(pygame.sprite.Sprite):
def __init__(self, game, x, y):
self.game = game
self.groups = self.game.all_sprites
pygame.sprite.Sprite.__init__(self, self.groups)
self.x = x * TILE_SIZE
self.y = y * TILE_SIZE
self.width = TILE_SIZE
self.height = TILE_SIZE
self.ARCHER_ORK_IMG = pygame.image.load("./zdjecia/ork_lucznik.png")
self.ARCHER_ORK = pygame.transform.scale(self.ARCHER_ORK_IMG,(64,64))
self.image = pygame.Surface([self.width, self.height])
self.image.blit(self.ARCHER_ORK, (0,0))
self.image.set_colorkey((0, 0, 0))
self.rect = self.image.get_rect()
self.rect.x = self.x
self.rect.y = self.y
self.level = 1

28
infantry_ork.py Normal file
View File

@ -0,0 +1,28 @@
import pygame
from config import *
class Infantry_ork(pygame.sprite.Sprite):
def __init__(self, game, x, y):
self.game = game
self.groups = self.game.all_sprites
pygame.sprite.Sprite.__init__(self, self.groups)
self.x = x * TILE_SIZE
self.y = y * TILE_SIZE
self.width = TILE_SIZE
self.height = TILE_SIZE
self.INFANTRY_ORK_IMG = pygame.image.load("./zdjecia/ork-piechota.png")
self.INFANTRY_ORK = pygame.transform.scale(self.INFANTRY_ORK_IMG,(64,64))
self.image = pygame.Surface([self.width, self.height])
self.image.blit(self.INFANTRY_ORK, (0,0))
self.image.set_colorkey((0, 0, 0))
self.rect = self.image.get_rect()
self.rect.x = self.x
self.rect.y = self.y
self.level = 2

28
infantry_ork2.py Normal file
View File

@ -0,0 +1,28 @@
import pygame
from config import *
class Infantry_ork2(pygame.sprite.Sprite):
def __init__(self, game, x, y):
self.game = game
self.groups = self.game.all_sprites
pygame.sprite.Sprite.__init__(self, self.groups)
self.x = x * TILE_SIZE
self.y = y * TILE_SIZE
self.width = TILE_SIZE
self.height = TILE_SIZE
self.INFANTRY_ORK2_IMG = pygame.image.load("./zdjecia/ork-piechota2.png")
self.INFANTRY_ORK2 = pygame.transform.scale(self.INFANTRY_ORK2_IMG,(64,64))
self.image = pygame.Surface([self.width, self.height])
self.image.blit(self.INFANTRY_ORK2, (0,0))
self.image.set_colorkey((0, 0, 0))
self.rect = self.image.get_rect()
self.rect.x = self.x
self.rect.y = self.y
self.level = 3

21
main.py
View File

@ -2,6 +2,10 @@ 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:
@ -10,19 +14,8 @@ class Game:
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.png")
#self.INFATRY_ORK_IMG = pygame.image.load("./zdjecia/ork-piechota.png")
#self.INFANTRY_ORK2_IMG = pygame.image.load("./zdjecia/ork-piechota2.png")
#self.SAURON_IMG = pygame.image.load("./zdjecia/sauron.png")
self.BACKGROUND_IMG= pygame.image.load("./zdjecia/podloze.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_png,(64,64))
self.BACKGROUND = pygame.transform.scale(self.BACKGROUND_IMG,(64,64))
#self.ORK_LIST = [self.ARCHER_ORK,self.INFANTRY_ORK2, self.INFATRY_ORK]
@ -33,6 +26,10 @@ class Game:
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)

28
sauron.py Normal file
View File

@ -0,0 +1,28 @@
import pygame
from config import *
class Sauron(pygame.sprite.Sprite):
def __init__(self, game, x, y):
self.game = game
self.groups = self.game.all_sprites
pygame.sprite.Sprite.__init__(self, self.groups)
self.x = x * TILE_SIZE
self.y = y * TILE_SIZE
self.width = TILE_SIZE
self.height = TILE_SIZE
self.SAURON_IMG = pygame.image.load("./zdjecia/sauron.png")
self.SAURON = pygame.transform.scale(self.SAURON_IMG,(64,64))
self.image = pygame.Surface([self.width, self.height])
self.image.blit(self.SAURON, (0,0))
self.image.set_colorkey((0, 0, 0))
self.rect = self.image.get_rect()
self.rect.x = self.x
self.rect.y = self.y
self.level = 4