-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathportal_file.py
24 lines (20 loc) · 969 Bytes
/
portal_file.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import pygame
def get_partals(board, all_sprite, portal_sprite, portal_image, cell_cize):
portals = []
for y in range(len(board.field)):
for x in range(len(board.field[0])):
if board.field[y][x] == '1':
board.field[y][x] = 'П'
portal = Portal(all_sprite, portal_sprite, portal_image, cell_cize * 2.3)
portal.rect.x = x * cell_cize + board.left_start - 10
portal.rect.y = y * cell_cize + board.top_start - 12
portals.append(portal)
elif board.field[y][x] in '234':
board.field[y][x] = 'П'
return portals
class Portal(pygame.sprite.Sprite):
def __init__(self, all_sprite, portal_sprite, portal_image, cell_cize):
super().__init__(all_sprite, portal_sprite)
self.image = portal_image
self.image = pygame.transform.scale(self.image, (cell_cize, cell_cize))
self.rect = self.image.get_rect()