while run:
for p in [(x, y) for x in range(0, 1000, width) for y in range(0, 100, height)]:
#draw map
if inRange:
for car in cars:
<code>
class figure(pygame.sprite.Sprite):
def __init__(self,x,y):
pygame.sprite.Sprite.__init__(self)
self.image = pygame.image.load(os.path.join(IMG, "figure.png")).convert()
self.rect = self.image.get_rect()
self.rect.x = x
self.rect.y = y
self.image.set_colorkey(BLACK) # made bg transparent
self.image = pygame.transform.scale(self.image, (70, 70))
figure = figure (25,75)
figure1= figure1(75,75)
all_sprites.add(figure)
all_sprites.add(figure1)
class repeat(pygame.sprite.Sprite):
def __init__(self):
pygame.sprite.Sprite.__init__(self)
self.image = pygame.image.load(os.path.join(IMG,"pawnBlue.png")).convert()
self.image.set_colorkey(black) # made bg transparent
self.rect = self.image.get_rect()
self.rect.center = (225,225)
self.image = pygame.transform.scale(self.image, (70, 70))
3 1
3 2
3 3
3 4
3 5
3 6
3 7
3 8
CELL_WIDTH = CELL_HEIGHT = 75
for p in [(x, y) for x in range(CELL_WIDTH, 610, CELL_WIDTH) for y in range(CELL_HEIGHT, 610, CELL_HEIGHT)]:
if (p[0] + p[1]) % 2 == 0:
pygame.draw.rect(DISPLAY, WHITE_CELL, [p[0], p[1], CELL_WIDTH, CELL_HEIGHT])
else:
pygame.draw.rect(DISPLAY, BLACK_CELL, [p[0], p[1], CELL_WIDTH, CELL_HEIGHT])
if event.type == pygame.MOUSEBUTTONDOWN:
if event.button == 1:
if (p[0]+75, p[1]) > event.pos > (p[0],p[1]):
print(p[0]//75, p[1]//75)<code>