def display(self, board):
     # render text
     for i in range(9):
         for j in range(9):
             if self._board[i][j]:
                 c = (255, 0, 0)
             else:
                 c = (0, 128, 0)
             text = font.render(str(board[i][j]), True, c)
             h = text.get_height() - 5
             textpos = text.get_rect()
             textpos.centerx = screen.get_rect().centerx + j * h - 200
             textpos.centery = 50 + i * h
             screen.fill((255, 255, 255), textpos)
             screen.blit(text, textpos)
     pygame.display.flip()
Esempio n. 2
0
        # check for closing window
        if event.type == pygame.QUIT:
            running = False
        elif event.type == pygame.MOUSEBUTTONUP:
            pos = pygame.mouse.get_pos()
            #TODO: block placing
        elif event.type == pygame.KEYDOWN:
            xadd = 0
            yadd = 0
            print('keydown ' + str(event.key))
            if (event.key == pygame.K_w):
                yadd = -10
            if (event.key == pygame.K_s):
                yadd = 10
            if (event.key == pygame.K_d):
                xadd = 10
            if (event.key == pygame.K_a):
                xadd = -10
            player.move(player.x + xadd, player.y + yadd)

    # Обновление
    # Рендеринг
    screen.fill(BLACK)
    print(sprites)

    for key, value in sprites.items():
        screen.blit(value.image, (value.rect.x, value.rect.y))
    pygame.display.update()

pygame.quit()
Esempio n. 3
0
            else:
                c = (0, 128, 0)
            text = font.render(str(board[i][j]), True, c)
            h = text.get_height() - 5
            textpos = text.get_rect()
            textpos.centerx = screen.get_rect().centerx + j * h - 200
            textpos.centery = 50 + i * h

            screen.fill((255, 255, 255), textpos)
            screen.blit(text, textpos)
    pygame.display.flip()


pygame.init()
screen = pygame.display.set_mode((640, 480))
screen.fill((255, 255, 255))
font = pygame.font.SysFont("serif", 30)


def increase_influence(x, y):
    for i in range(9):
        if i == x:
            continue

        if (board[x][y] not in CELLS[(i, y)][2]):
            CELLS[(i, y)][2].append(board[x][y])
            CELLS[(i, y)][0] = len(CELLS[(i, y)][2])
            if CELLS[(i, y)] not in H:
                heapq.heappush(H, CELLS[(i, y)])

        if (board[x][y] not in CELLS[(x, i)][2]):
Esempio n. 4
0
i = 0


def goldencut(base):
    return base * 0.382


def middle(base):
    return round(base * 0.5, 0)


while True:
    events = pygame.event.get()
    mouse_pos = pygame.mouse.get_pos()

    screen.fill((246, 198, 0))  # fill screen with an rgb color

    screen.blit(img, (middle(480) - 20, goldencut(800) - 20))

    for event in events:
        print event
        if event.type == pygame.MOUSEBUTTONDOWN:
            if pygame.Rect((middle(480) - 20, goldencut(800) - 20),
                           (40, 40)).collidepoint(
                               mouse_pos
                           ):  #funktioniert noch nicht, muss verschoben werden
                print "Hey you tickled the shit!"

    pygame.display.flip()
Esempio n. 5
0
File: game.py Progetto: flipdot/shit
screen = screen.get_screen()

i=0

def goldencut (base):
    return base * 0.382

def middle (base):
    return round (base * 0.5, 0)

while True:
    events = pygame.event.get()
    mouse_pos = pygame.mouse.get_pos()

    screen.fill( (246, 198, 0) ) # fill screen with an rgb color

    screen.blit(
        img,
        (middle(480)-20, goldencut(800)-20)
    )

    for event in events:
        print event
        if event.type == pygame.MOUSEBUTTONDOWN:
            if pygame.Rect(
                (middle(480)-20, goldencut(800)-20),
                (40, 40)
            ).collidepoint(mouse_pos): #funktioniert noch nicht, muss verschoben werden
                print "Hey you tickled the shit!"