grid fix, changed the robot to chicken, changed the side-movements of the chick

This commit is contained in:
Aliaksei Brown 2023-03-22 17:57:33 +01:00
parent 9813875062
commit 772c9a5357
14 changed files with 22 additions and 3 deletions

1
.gitignore vendored
View File

@ -1,2 +1,3 @@
.DS_Store .DS_Store
.idea .idea
__pycache__

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 313 B

BIN
resources/down.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 577 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.7 KiB

BIN
resources/left.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

BIN
resources/right.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 139 KiB

BIN
resources/up.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.3 KiB

View File

@ -4,30 +4,48 @@ from pygame.math import Vector2
class Tractor: class Tractor:
def __init__(self, parent_screen, cell_size): def __init__(self, parent_screen, cell_size):
self.up = pygame.image.load(r'resources/up.png').convert_alpha()
self.down = pygame.image.load(r'resources/down.png').convert_alpha()
self.left = pygame.image.load(r'resources/left.png').convert_alpha()
self.right = pygame.image.load(r'resources/right.png').convert_alpha()
self.parent_screen = parent_screen self.parent_screen = parent_screen
self.image = pygame.image.load(r'resources/robot2.png').convert_alpha() #self.image = pygame.image.load(r'resources/robot3.png').convert_alpha()
self.image = pygame.transform.scale(self.image, (cell_size, cell_size+5))
self.up = pygame.transform.scale(self.up, (cell_size, cell_size))
self.down = pygame.transform.scale(self.down, (cell_size, cell_size+2))
self.left = pygame.transform.scale(self.left, (cell_size+2, cell_size+2))
self.right = pygame.transform.scale(self.right, (cell_size+3, cell_size+1))
self.x = cell_size*2 self.x = cell_size*2
self.y = cell_size*2 self.y = cell_size*2
self.pos = Vector2(self.x, self.y) self.pos = Vector2(self.x, self.y)
self.angle = 0 self.angle = 0
self.direction = 'up' self.direction = 'up'
self.image = self.down
def draw(self): def draw(self):
self.parent_screen.blit(pygame.transform.rotate(self.image, self.angle), (self.x, self.y)) # rotate tractor self.parent_screen.blit(self.image, (self.x, self.y)) # rotate tractor
def move(self, direction, cell_size): def move(self, direction, cell_size):
if direction == 'up': if direction == 'up':
self.y -= cell_size self.y -= cell_size
self.image = self.up
#self.angle = 0 #self.angle = 0
if direction == 'down': if direction == 'down':
self.y += cell_size self.y += cell_size
self.image = self.down
#self.angle = 180 #self.angle = 180
if direction == 'left': if direction == 'left':
self.x -= cell_size self.x -= cell_size
self.image = self.left
#self.angle = 90 #self.angle = 90
if direction == 'right': if direction == 'right':
self.x += cell_size self.x += cell_size
self.image = self.right
#self.angle = 270 #self.angle = 270
def walk(self): def walk(self):