dodanie agenta
This commit is contained in:
parent
216b8c5e77
commit
69e54b2c31
67
board
Normal file
67
board
Normal file
@ -0,0 +1,67 @@
|
||||
import sys
|
||||
import pygame
|
||||
|
||||
screen = []
|
||||
objectArray = []
|
||||
|
||||
class Agent:
|
||||
def __init__(self, name, xPos, yPos):
|
||||
self.name = name
|
||||
self.xPos = xPos
|
||||
self.yPos = yPos
|
||||
|
||||
def draw(square_num, objectArr):
|
||||
#następne dwie linijki do odkomentowania, jak będzie wgrane zdjęcie do tła
|
||||
#background = pygame.image.load("ścieżka do pliku").convert() #tu ścieżka do zdjęcia w tle
|
||||
#screen.blit(background, (0, 0))
|
||||
grid_color = (0, 0, 0) #kolor czarny
|
||||
|
||||
grid_size = 500 #rozmiar kraty
|
||||
square = grid_size/square_num #rozmiar pojedyńczego kwadracika
|
||||
|
||||
a = 50
|
||||
b = 10 #odległości kraty od krawędzi okna
|
||||
|
||||
for i in range(square_num):
|
||||
pygame.draw.line(screen, grid_color, (a + i*square, b), (a + i*square, b + grid_size), 2)
|
||||
|
||||
pygame.draw.line(screen, grid_color, (a, b + i*square), (a + grid_size, b + i*square), 2)
|
||||
|
||||
pygame.draw.line(screen, grid_color, (a, b + grid_size), (a + grid_size,
|
||||
b + grid_size), 2)
|
||||
pygame.draw.line(screen, grid_color, (a + grid_size, b),
|
||||
(a + grid_size, b + grid_size), 2)
|
||||
|
||||
## tutaj rysujemy agenta i inne obiekty juz na gotowej mapie
|
||||
|
||||
## RYSUJEMY AGENTA
|
||||
agent_color = (255, 0, 0)
|
||||
circleX = objectArr[0].xPos * square + square / 2
|
||||
circleY = objectArr[0].yPos * square - square / 2
|
||||
radius = 10
|
||||
pygame.draw.circle(screen, agent_color, (a + circleX, b + circleY), radius)
|
||||
|
||||
|
||||
def close(): #by móc zamnkąć okno iksem
|
||||
for event in pygame.event.get():
|
||||
if event.type == pygame.QUIT:
|
||||
sys.exit()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
pygame.init() #inicjalizacja modułów, na razie niepotrzebna
|
||||
|
||||
#Tworzymy nowego playera, czy tam agenta
|
||||
agent = Agent("smieciarka", 5, 7)
|
||||
objectArray.append(agent)
|
||||
|
||||
width = 600
|
||||
height = 530
|
||||
screen = pygame.display.set_mode((width, height)) #ustalanie rozmiarów okna
|
||||
|
||||
c = (255, 255, 255) #tymczasowy kolor tła - do usunięcia, jak już będzie zdjęcie
|
||||
screen.fill(c)
|
||||
while 1:
|
||||
draw(10, objectArray)
|
||||
close()
|
||||
pygame.display.update() #by krata pojawiła się w okienku - update powierzchni
|
Loading…
Reference in New Issue
Block a user