Compare commits

..

No commits in common. "2a1c9bedf29671cea0ebaac5bc16d6ba74047b58" and "d61d507bf4e26b5aad8b0d9f08296a46da10b749" have entirely different histories.

4 changed files with 13 additions and 16 deletions

27
main.py
View File

@ -19,26 +19,23 @@ class Lines:
for i in range(1, 10):
pygame.draw.line(self.parent_scr, (228, 253, 227), (conf.cell_size * i, 0), (conf.cell_size * i, conf.screen_size), 1)
pygame.draw.line(self.parent_scr, (228, 253, 227), (0, conf.cell_size * i), (conf.screen_size, conf.cell_size * i), 1)
#pygame.display.flip()
pygame.display.flip()
class Tractor:
def __init__(self, parent_screen):
conf = Configurations()
self.parent_screen = parent_screen
self.image = pygame.image.load(r'resources/tractor.png').convert_alpha()
self.image = pygame.transform.scale(self.image, (conf.cell_size, conf.cell_size+5))
#self.block = pygame.Rect(int(conf.cell_size), int(conf.cell_size), conf.cell_size, conf.cell_size)
self.x = conf.cell_size*2
self.y = conf.cell_size*2
self.block = pygame.image.load(r'resources/arrow.png').convert()
self.x = 100
self.y = 100
self.angle = 0
self.direction = 'up'
def draw(self):
#self.parent_screen.fill((120, 120, 0)) # background color
#self.parent_screen.blit(self.block, (self.x, self.y))
self.parent_screen.blit(pygame.transform.rotate(self.image, self.angle), (self.x, self.y)) # rotate tractor
#pygame.display.flip() # updating screen
self.parent_screen.blit(self.block, (self.x, self.y))
self.parent_screen.blit(pygame.transform.rotate(self.block, self.angle), (self.x, self.y)) # rotate tractor
pygame.display.flip() # updating screen
def move(self, direction):
conf = Configurations()
@ -84,7 +81,7 @@ class Field:
if field_matrix[m][n] == 1:
self.parent_screen.blit(self.block, (n * conf.cell_size, m * conf.cell_size))
#pygame.display.flip()
pygame.display.flip()
class Game:
@ -126,6 +123,7 @@ class Game:
time_now = datetime.now()
for event in pygame.event.get():
if event.type == KEYDOWN:
if pygame.key.get_pressed()[K_ESCAPE]:
@ -142,15 +140,14 @@ class Game:
elif event.type == QUIT:
running = False
self.surface.fill((140, 203, 97)) # background color
self.surface.fill((120, 120, 0)) # background color
self.field.place_field(self.field_matrix)
self.lines.draw_lines()
self.tractor.draw()
pygame.display.update()
# if (time_now - last_time).total_seconds() > 1: # tractor moves every 1 sec
# last_time = datetime.now()
if (time_now - last_time).total_seconds() > 1: # tractor moves every 1 sec
last_time = datetime.now()
#self.tractor.walk()
#print(f'x, y = ({int(self.tractor.x / 50)}, {int(self.tractor.y / 50)})')

BIN
resources/.DS_Store vendored

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 139 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 47 KiB