예제 #1
0
def init_car(dimension, img_path):
    car_sprite = pygf.makeSprite(img_path)
    position = (dimension / 2, dimension / 2)
    pygf.moveSprite(car_sprite, position[0], position[1], True)
    pygf.transformSprite(car_sprite, -90, 0.5)
    pygf.showSprite(car_sprite)

    return position
예제 #2
0
def punktSetzen():
    global time_since_last_point
    while True:
        placeOn = rng.randrange(len(spielraster))
        if spielraster[placeOn] == 0:
            punkt = Punkt(i2xy(placeOn))
            spielraster[placeOn] = 1
            pgf.showSprite(punkt.sprite)
            time_since_last_point = pgf.clock()
            return punkt
예제 #3
0
def display_segmentation(position, img_path, old_sprite=None):
    seg_sprite = pygf.makeSprite(img_path)
    pygf.moveSprite(seg_sprite, position[0], position[1] - 170, True)
    pygf.transformSprite(seg_sprite, 0, 0.9)

    if old_sprite:
        pygf.hideSprite(old_sprite)

    pygf.showSprite(seg_sprite)
    return seg_sprite
예제 #4
0
def make_choice(chosen_card):
    """
    Show the chosen card and return its details details.
    :param chosen_card: The card object that was chosen. (Card)
    :return: The stats of the card
    """

    pygame_functions.hideAll()
    pygame_functions.moveSprite(chosen_card.card_sprite, SCREEN_SIZE_X // 2,
                                SCREEN_SIZE_Y // 2)
    pygame_functions.showSprite(chosen_card.card_sprite)

    return chosen_card.card_type, chosen_card.card_factor
예제 #5
0
def pointSet(dlt):

    if dlt:  # 새 게임 시작시 맵구조를 복원
        point_d = {}
        for i, number in enumerate(gamegrid):
            gamegrid[i] = gamegrid_restart[i]

    else:
        point_d = {}
        for i, number in enumerate(gamegrid_restart):
            if number not in (1, 2): continue
            point_d[i] = Point(
                i2xy(i),
                'Resource\Teil_17_Punkt.png') if number == 1 else Point(
                    i2xy(i), 'Resource\Teil_17_Punkt_gross.png')
            pgf.showSprite(point_d[i].sprite)

    return point_d
예제 #6
0
def show_cards(current_luck, cards):
    """
    Show the option cards according to the dice roll.
    :param current_luck: The current roll outcome. (int)
    :param cards: The tuple containing the card objects. (tuple)

    :return: a tuple containing the sprites of the option cards.
    """

    OPTION_CARD_Y = SCREEN_SIZE_Y - 100
    OPTION_CARD_MIDDLE_X = SCREEN_SIZE_X // 2
    OPTIONS_CARD_SPACING = SCREEN_SIZE_X // 3

    rock_card = cards[TYPES_ENUM['rock']][current_luck - 1]
    paper_card = cards[TYPES_ENUM['paper']][current_luck - 1]
    scissor_card = cards[TYPES_ENUM['scissor']][current_luck - 1]

    pygame_functions.moveSprite(rock_card.card_sprite,
                                OPTION_CARD_MIDDLE_X - OPTIONS_CARD_SPACING,
                                OPTION_CARD_Y)
    pygame_functions.moveSprite(paper_card.card_sprite, OPTION_CARD_MIDDLE_X,
                                OPTION_CARD_Y)
    pygame_functions.moveSprite(scissor_card.card_sprite,
                                OPTION_CARD_MIDDLE_X + OPTIONS_CARD_SPACING,
                                OPTION_CARD_Y)

    pygame_functions.showSprite(rock_card.card_sprite)
    pygame_functions.showSprite(paper_card.card_sprite)
    pygame_functions.showSprite(scissor_card.card_sprite)

    return rock_card, paper_card, scissor_card
예제 #7
0
def main_UI():
    #global Game
    global trikey
    pgf.hideAll()
    pgf.updateDisplay()

    while True:
        #pgf.tick(50)
        pgf.screen.blit(main1, (183, 200))
        pgf.screen.blit(main2, (180, 310))
        pgf.updateDisplay()

        font = pygame.font.Font('Resource\\NanumGothic.ttf', 35)

        gamestart = font.render('G a m e   S t a r t', True, (255, 255, 255))
        pgf.screen.blit(gamestart, (180, 500))
        if trikey == 0:
            tri = Point((120, 520), 'Resource\Triangle.png')
            pgf.showSprite(tri.sprite)

        simulation = font.render('S i m u l a t i o n', True, (255, 255, 255))
        pgf.screen.blit(simulation, (180, 570))
        if trikey == 1:
            tri = Point((120, 590), 'Resource\Triangle.png')
            pgf.showSprite(tri.sprite)

        exit = font.render('E X I T', True, (255, 255, 255))
        pgf.screen.blit(exit, (180, 640))
        if trikey == 2:
            tri = Point((120, 660), 'Resource\Triangle.png')
            pgf.showSprite(tri.sprite)

        for event in pygame.event.get():
            if event.type == pygame.KEYDOWN:
                if event.key == pygame.K_DOWN:
                    if (trikey < 2):
                        trikey += 1

                elif event.key == pygame.K_UP:
                    if (trikey > 0):
                        trikey -= 1

                pgf.hideAll()

        if pgf.keyPressed('enter'):
            if (trikey == 2):  # 종료
                pygame.quit()
                sys.exit()
                break
            else:
                break
 def show(self):
     pgf.showSprite(self.sprites[self.modus][0])
        pacman.changeAnimationFrame()

    fps = pgf.tick(120)

    if game_status == "run":
        if pgf.keyPressed("right"):
            pacman.dir_buffer = 0
        elif pgf.keyPressed("left"):
            pacman.dir_buffer = 1
        elif pgf.keyPressed("up"):
            pacman.dir_buffer = 2
        elif pgf.keyPressed("down"):
            pacman.dir_buffer = 3

        for dot in dots.values():
            pgf.showSprite(dot.sprite)

        pacman.eatDot()
        pacman.update()

        for ghost in ghosts:
            ghost.update()
            gh_sprite = ghost.sprites[ghost.modus][0]
            if pgf.touching(gh_sprite, pacman.sprites[pacman.modus][0]):
                if ghost.modus == "jagd" and pacman.modus == 'run':
                    pacman.changeMode('die')
                    changeGameStatus('dead')
                    timer2 = threading.Timer(1.2, nextPacman)
                    timer2.start()

                if ghost.modus in ("flucht", "blink"):
예제 #10
0
 def anzeigen(self):
     pgf.moveSprite(self.sprite, self.x, self.y, centre=True)
     pgf.showSprite(self.sprite)
예제 #11
0
 def anzeigen(self):
     pgf.moveSprite(self.sprite, self.x, self.y, centre=True)
     pgf.showSprite(self.sprite)
     for b in range(0, len(self.body)):
         self.body[b].anzeigen()
예제 #12
0
 def display(self):  # 스프라이트를 맵에 배치, 표기하는 함수
     pgf.moveSprite(self.sprite, self.x, self.y,
                    centre=True)  # 좌표위치에 스프라이트를 배치
     pgf.showSprite(self.sprite)  # 배치된 스프라이트 표기
예제 #13
0
 def dibujar(self):
     moveSprite(self.sprite, self.posicionX, self.posicionY)
     showSprite(self.sprite)
     self._al_dibujar()
     self.dibujado = True
예제 #14
0
파일: main.py 프로젝트: pHgon/8Puzzle-FIA
    def __init__(self, nmax, filename):
        # Variaveis de Controle
        self.nmax = nmax
        self.mouse_state_plus = False
        self.mouse_state_minus = False
        #self.alg
        self.sprite_list = []
        self.shuffler = shuffle.Shuffle(self.nmax)
        self.imagesize = c.IMAGE_SIZE
        self.time_elapsed = 0

        # Inicializacao Pygame
        pyf.screenSize(c.SCREEN_WIDTH, c.SCREEN_HEIGHT)
        pyf.setBackgroundColour(c.GRAY)

        # Instancia lista de sprites
        for i in range(0, nmax * nmax):
            self.sprite_list.append(
                pyf.makeSprite("images/" + filename + str(i) + ".png"))

        # Carrega sprites padroes
        self.plus = pyf.makeSprite("images/plus.png")
        self.minus = pyf.makeSprite("images/minus.png")
        self.shuffle_button = pyf.makeSprite("images/shuffle.png")
        self.BFS_button = pyf.makeSprite("images/BFS.png")
        self.DFS_button = pyf.makeSprite("images/DFS.png")
        self.DFS_IT_button = pyf.makeSprite("images/BFS_IT.png")
        self.A1_button = pyf.makeSprite("images/A_H1.png")
        self.A2_button = pyf.makeSprite("images/A_H2.png")
        self.text_shuffler_label = pyf.makeLabel(u"Número de iterações: ", 30,
                                                 50, 690, "black", "Arial",
                                                 "clear")
        self.text_time = pyf.makeLabel(u"Tempo de execução: ", 30, 700, 400,
                                       "black", "Arial", "clear")
        self.text_time2 = pyf.makeLabel("segundos", 30, 980, 400, "black",
                                        "Arial", "gray")
        self.text_memory = pyf.makeLabel(u"Memória utilizada: ", 30, 735, 450,
                                         "black", "Arial", "clear")
        #self.text_moves = pyf.makeLabel("Movimentos Realizados: ", 30, 735, 500, "black", "Arial", "clear")
        #self.text_moves2 = pyf.makeLabel("", 30, 735, 500, "black", "Arial", "gray")
        self.text_memory2 = pyf.makeLabel("bytes", 30, 980, 450, "black",
                                          "Arial", "gray")
        self.number_shuffler_label = pyf.makeLabel(str(c.IT), 30, 332, 692,
                                                   "black", "Arial", "clear")

        # Transforma sprites para tamanhos maiores que 3x3
        if self.nmax > 3:
            self.initial_transformation()

        # Posiciona Sprites
        self.initial_position()
        pyf.moveSprite(self.shuffle_button, 570, 710, True)
        pyf.moveSprite(self.plus, 515, 710, True)
        pyf.moveSprite(self.minus, 460, 710, True)
        pyf.moveSprite(self.BFS_button, 800, 100, True)
        pyf.moveSprite(self.DFS_button, 1010, 100, True)
        pyf.moveSprite(self.DFS_IT_button, 900, 210, True)
        pyf.moveSprite(self.A1_button, 800, 320, True)
        pyf.moveSprite(self.A2_button, 1010, 320, True)

        # Mostra sprites na tela
        for i in range(0, nmax * nmax):
            pyf.showSprite(self.sprite_list[i])
            # print(i)
        pyf.showSprite(self.shuffle_button)
        pyf.showSprite(self.plus)
        pyf.showSprite(self.minus)
        pyf.showLabel(self.text_shuffler_label)
        pyf.showLabel(self.number_shuffler_label)
        pyf.showLabel(self.BFS_button)
        pyf.showLabel(self.DFS_button)
        pyf.showLabel(self.DFS_IT_button)
        pyf.showLabel(self.A1_button)
        pyf.showLabel(self.A2_button)
        pyf.showLabel(self.text_time)
        pyf.showLabel(self.text_time2)
        pyf.showLabel(self.text_memory)
        pyf.showLabel(self.text_memory2)
        #pyf.showLabel(self.text_moves)
        #pyf.showLabel(self.text_moves2)
        pyf.transformSprite(self.shuffle_button, 0, 0.25)
        pyf.transformSprite(self.plus, 0, 0.25)
        pyf.transformSprite(self.minus, 0, 0.1)