Merge branch 'master' of https://git.wmi.amu.edu.pl/s473564/Gra-SI
This commit is contained in:
commit
bf66823c64
Binary file not shown.
BIN
__pycache__/archer_ork.cpython-39.pyc
Normal file
BIN
__pycache__/archer_ork.cpython-39.pyc
Normal file
Binary file not shown.
Binary file not shown.
BIN
__pycache__/infantry_ork.cpython-39.pyc
Normal file
BIN
__pycache__/infantry_ork.cpython-39.pyc
Normal file
Binary file not shown.
BIN
__pycache__/infantry_ork2.cpython-39.pyc
Normal file
BIN
__pycache__/infantry_ork2.cpython-39.pyc
Normal file
Binary file not shown.
Binary file not shown.
BIN
__pycache__/sauron.cpython-39.pyc
Normal file
BIN
__pycache__/sauron.cpython-39.pyc
Normal file
Binary file not shown.
70
agent.py
70
agent.py
@ -29,11 +29,19 @@ class Agent(pygame.sprite.Sprite):
|
||||
self.rect.y = self.y
|
||||
|
||||
self.level = 1
|
||||
self.health = 10000*self.level
|
||||
|
||||
self.current_health = 500
|
||||
self.max_health = 1000
|
||||
self.health_bar_length = 300
|
||||
self.health_ratio = self.max_health/self.health_bar_length
|
||||
|
||||
|
||||
|
||||
def update(self):
|
||||
self.health_bar()
|
||||
self.movement()
|
||||
self.collide_mob()
|
||||
self.disp_level()
|
||||
|
||||
self.rect.x += self.x_change
|
||||
self.collide_blocks('x')
|
||||
@ -46,13 +54,13 @@ class Agent(pygame.sprite.Sprite):
|
||||
def movement(self):
|
||||
keys = pygame.key.get_pressed()
|
||||
if keys[pygame.K_LEFT] and self.rect.x > 0:
|
||||
self.x_change -= TILE_SIZE/2
|
||||
self.x_change -= TILE_SIZE
|
||||
if keys[pygame.K_RIGHT] and self.rect.x < 832 - 64:
|
||||
self.x_change += TILE_SIZE/2
|
||||
self.x_change += TILE_SIZE
|
||||
if keys[pygame.K_UP] and self.rect.y > 0:
|
||||
self.y_change -= TILE_SIZE/2
|
||||
if keys[pygame.K_DOWN] and self.rect.y < 832 - 64:
|
||||
self.y_change += TILE_SIZE/2
|
||||
self.y_change -= TILE_SIZE
|
||||
if keys[pygame.K_DOWN] and self.rect.y < 768 - 64:
|
||||
self.y_change += TILE_SIZE
|
||||
|
||||
def collide_blocks(self, direction):
|
||||
if direction == "x":
|
||||
@ -77,38 +85,47 @@ class Agent(pygame.sprite.Sprite):
|
||||
hits_infantry_ork = pygame.sprite.spritecollide(self, self.game.infantry_orks, False)
|
||||
hits_infantry_ork2 = pygame.sprite.spritecollide(self, self.game.infantry_orks2, False)
|
||||
hits_sauron = pygame.sprite.spritecollide(self, self.game.sauronL, False)
|
||||
#hits_unknown_mob = pygame.sprite.spritecollide(self, self.game.unknown_mobs, False) #unknown mob
|
||||
#if hits_unknown_mob:
|
||||
# self.game.unknown_mob.kill()
|
||||
# self.game.archer_orks = pygame.sprite.LayeredUpdates()
|
||||
# self.game.archer_ork = Archer_ork(self,3,2)
|
||||
|
||||
|
||||
|
||||
|
||||
if hits_archer_ork:
|
||||
if self.game.archer_ork.level > self.level or self.game.archer_ork.damage > self.health:
|
||||
if self.game.archer_ork.level > self.level or self.game.archer_ork.damage > self.current_health:
|
||||
self.kill()
|
||||
self.game.new()
|
||||
else:
|
||||
self.game.archer_ork.kill()
|
||||
self.health=self.health-self.game.archer_ork.damage
|
||||
self.get_damage(self.game.archer_ork.damage)
|
||||
self.level+=self.level
|
||||
#zmniejszenie życia o damage moba
|
||||
#level up
|
||||
if hits_infantry_ork:
|
||||
if self.game.infantry_ork.level > self.level or self.game.infantry_ork.damage > self.health:
|
||||
if self.game.infantry_ork.level > self.level or self.game.infantry_ork.damage > self.current_health:
|
||||
self.kill()
|
||||
self.game.new()
|
||||
else:
|
||||
self.game.infantry_ork.kill()
|
||||
self.health=self.health-self.game.infantry_ork.damage
|
||||
self.get_damage(self.game.infantry_ork.damage)
|
||||
self.level+=self.level
|
||||
#zmniejszenie życia o damage moba
|
||||
#level up
|
||||
if hits_infantry_ork2:
|
||||
if self.game.infantry_ork2.level > self.level or self.game.infantry_ork2.damage > self.health:
|
||||
if self.game.infantry_ork2.level > self.level or self.game.infantry_ork2.damage > self.current_health:
|
||||
self.kill()
|
||||
self.game.new()
|
||||
else:
|
||||
self.game.infantry_ork2.kill()
|
||||
self.health=self.health-self.game.infantry_ork2.damage
|
||||
self.get_damage(self.game.infantry_ork2.damage)
|
||||
self.level+=self.level
|
||||
#zmniejszenie życia o damage moba
|
||||
#level up
|
||||
if hits_sauron:
|
||||
if self.game.sauron.level > self.level or self.game.sauron.damage > self.health:
|
||||
if self.game.sauron.level > self.level or self.game.sauron.damage > self.current_health:
|
||||
self.kill()
|
||||
self.game.new()
|
||||
else:
|
||||
@ -118,6 +135,33 @@ class Agent(pygame.sprite.Sprite):
|
||||
#zmniejszenie życia o damage moba
|
||||
#level up
|
||||
|
||||
|
||||
def get_damage(self,amount):
|
||||
if self.current_health > 0:
|
||||
self.current_health -= amount
|
||||
if self.current_health <= 0:
|
||||
self.current_health = 0
|
||||
|
||||
#zmienic potem na smierc oraz później trzeba będzie tutaj ująć wszystkie statystyki
|
||||
#i ze statystyk obliczyć ile dmg dostanie agent
|
||||
|
||||
def get_health(self, amount):
|
||||
if self.current_health < self.max_health:
|
||||
self.current_health += amount
|
||||
if self.current_health >= self.max_health:
|
||||
self.current_health = self.max_health
|
||||
|
||||
def health_bar(self):
|
||||
pygame.draw.rect(self.game.SCREEN, (255,0,0), (10,780,self.health_bar_length,25))
|
||||
pygame.draw.rect(self.game.SCREEN, (0,255,0), (10,780,self.current_health/self.health_ratio,25))
|
||||
pygame.draw.rect(self.game.SCREEN, (255,255,255), (10,780,self.health_bar_length, 25),2)
|
||||
|
||||
def disp_level(self):
|
||||
font = pygame.font.SysFont(None, 40)
|
||||
lvlDisplay = font.render(str(self.level), 1, WHITE)
|
||||
pygame.draw.rect(self.game.SCREEN, BLACK, (370, 780, 40, 40))
|
||||
self.game.SCREEN.blit(lvlDisplay, (370,780))
|
||||
|
||||
# brakuje levelowania postaci gdy zabije moba, jest zrobione tylko, że jeśli za wysoki poziom, lub brak życia to ginie i od nowa zaczyna
|
||||
# brakuje dodania miejsca w którym agent się leczy
|
||||
|
||||
|
10
main.py
10
main.py
@ -6,6 +6,7 @@ from archer_ork import *
|
||||
from infantry_ork import *
|
||||
from infantry_ork2 import *
|
||||
from sauron import *
|
||||
#from unknown_mob import * #unknown mob
|
||||
|
||||
class Game:
|
||||
|
||||
@ -18,6 +19,9 @@ class Game:
|
||||
self.BACKGROUND_IMG= pygame.image.load("./zdjecia/podloze.jpg")
|
||||
self.BACKGROUND = pygame.transform.scale(self.BACKGROUND_IMG,(64,64))
|
||||
|
||||
self.LVL_ICON_PNG = pygame.image.load("./zdjecia/lvl_icon.png")
|
||||
self.LVL_ICON = pygame.transform.scale(self.LVL_ICON_PNG,(24,24))
|
||||
|
||||
#self.ORK_LIST = [self.ARCHER_ORK,self.INFANTRY_ORK2, self.INFATRY_ORK]
|
||||
|
||||
pygame.display.set_caption('Gra-SI')
|
||||
@ -29,14 +33,17 @@ class Game:
|
||||
self.infantry_orks = pygame.sprite.LayeredUpdates()
|
||||
self.infantry_orks2 = pygame.sprite.LayeredUpdates()
|
||||
self.sauronL = pygame.sprite.LayeredUpdates()
|
||||
#self.unknown_mobs = pygame.sprite.LayeredUpdates() #unknown mob
|
||||
self.agent = Agent(self,1,1)
|
||||
self.archer_ork = Archer_ork(self,10,10)
|
||||
self.infantry_ork = Infantry_ork(self,10,4)
|
||||
self.infantry_ork2 = Infantry_ork2(self,6,3)
|
||||
self.sauron = Sauron(self, 1, 10)
|
||||
#self.unknown_mob = Unknown_mob(self,8,8) #unknown mob
|
||||
for y in range(5):
|
||||
self.rock = Rocks(self,3,y)
|
||||
|
||||
|
||||
def update(self):
|
||||
self.all_sprites.update()
|
||||
|
||||
@ -50,12 +57,13 @@ class Game:
|
||||
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):
|
||||
for y in range(0, 768, 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)
|
||||
self.SCREEN.blit(self.LVL_ICON, (340 ,780))
|
||||
pygame.display.update()
|
||||
|
||||
def main(self):
|
||||
|
29
unknown_mob.py
Normal file
29
unknown_mob.py
Normal file
@ -0,0 +1,29 @@
|
||||
import pygame
|
||||
from config import *
|
||||
|
||||
class Unknown_mob(pygame.sprite.Sprite):
|
||||
|
||||
|
||||
def __init__(self, game, x, y):
|
||||
self.game = game
|
||||
self.groups = self.game.all_sprites, self.game.unknown_mobs
|
||||
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.UNKNOWN_MOB_IMG = pygame.image.load("./zdjecia/dragon.jpg")
|
||||
self.UKNOWN_MOB = pygame.transform.scale(self.UNKNOWN_MOB_IMG,(64,64))
|
||||
|
||||
self.image = pygame.Surface([self.width, self.height])
|
||||
self.image.blit(self.UKNOWN_MOB, (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
|
||||
self.damage = 50*self.level
|
BIN
zdjecia/dragon.jpg
Normal file
BIN
zdjecia/dragon.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 12 KiB |
BIN
zdjecia/lvl_icon.png
Normal file
BIN
zdjecia/lvl_icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 16 KiB |
Loading…
Reference in New Issue
Block a user