コード例 #1
0
 def sfx_hit(self):
     """Play sound for when ball hits paddle."""
     pyxel.play(ch=0, snd=2)
コード例 #2
0
    def death_event(self):
        """Kill the game (bring up end screen)."""
        self.death = True  # Check having run into self

        pyxel.stop()
        pyxel.play(0, 1)
コード例 #3
0
ファイル: bucketgame.py プロジェクト: tuimon/resourcis
 def doom(self):
     for i in range(self.amount_of_blocks):
         if self.block_array[i] != None and self.block_array[i].doomed:
             self.score += 1
             self.block_array[i] = None
             pyxel.play(1, 1)
コード例 #4
0
def death():
    pyxel.stop()
    pyxel.play(2, 3)
コード例 #5
0
 def collision_detect(self, obj, index, x, y):
     if abs(self.dinasour_pos[0] - obj[index]) < x and abs(
             self.dinasour_pos[1] - obj[index + 1]) < y:
         self.game_state = 'game over'
         pyxel.play(ch=0, snd=1)
コード例 #6
0
def start_shoot():
    pyxel.play(0, 0, loop=True)
コード例 #7
0
def spawn():
    pyxel.play(2, 1)
コード例 #8
0
    def update_lemmings_movement_and_tools(self):
        """THIS IS ALL THE CODE TO LEMMING MOVEMENT AND INTERACTION BETWEEN OBJECTS.
        THIS IS BASICALLY THE CORE CODE OF THE GAME."""

        for i in self.list_of_appeared_lemmings:

            # First we have to define some variables called cellclass checkers. They allow
            # the lemmings to "watch" some positions around them.

            # CELCLASS CHECKERS OF THE INTRINSIC POSITION OF THE LEMMING

            self.cellclass_of_cell = self.boardmatrix[int(i.lemx // 16)][int(
                i.lemy // 16)].cellclass

            ##CELLCLASS CHECKERS: RIGHT, LEFT AND BELOW THE LEMMINGS

            self.cellclass_of_cell_right = self.boardmatrix[int(i.lemx // 16) +
                                                            1][int(
                                                                i.lemy //
                                                                16)].cellclass
            self.cellclass_of_cell_below_right = self.boardmatrix[int(
                i.lemx // 16)][int((i.lemy // 16) + 1)].cellclass
            self.cellclass_of_cell_left = self.boardmatrix[int(
                i.lemx // 16)][int(i.lemy // 16)].cellclass
            self.cellclass_of_cell_below_left = self.boardmatrix[int(
                i.lemx // 16)][int(i.lemy // 16) + 1].cellclass

            ## SPECIAL CELLCLASS CHECKERS FOR DETECTING THE BLOCKERS

            self.cellclass_of_cell_right_blocker = self.boardmatrix[
                int(i.lemx // 16) + 1][int(i.lemy // 16)].cellclass
            self.cellclass_of_cell_left_blocker = self.boardmatrix[
                int(i.lemx // 16) - 1][int(i.lemy // 16)].cellclass

            ##### MOVEMENT AND INTERACTION WITH ALL OBJECTS #####

            if self.zawarudo == False:  ## we check that time is not stopped

                if i.appeared == True:  ## check if lemmings have appeared

                    if i.checker_appeared == True:
                        if i.sprite != str("walking_L") and i.sprite != str(
                                "Blocker"
                        ):  ## just to establish the initial sprite
                            i.change_sprite("walking_R")  ## of the lemmings
                        i.checker_appeared = False

                    if i.died == False or i.saved == False:  ## check that they aren't saved, neither died

                        ## COLLISION WITH SIDE PLATFORMS AND BLOCKER LEMMINGS

                        if ((isinstance(self.cellclass_of_cell_right, Platform)
                             == True or isinstance(self.cellclass_of_cell_left,
                                                   Platform) == True) or
                            (isinstance(self.cellclass_of_cell_right_blocker,
                                        Blocker_lemming) == True
                             or isinstance(self.cellclass_of_cell_left_blocker,
                                           Blocker_lemming) == True)):

                            if i.direction == "R":
                                i.change_sprite("walking_L")
                                i.changeDirection(
                                )  ### changing directions of lemming
                            else:
                                i.change_sprite("walking_R")
                                i.changeDirection()

                        #COLLISION WITH SHOVEL AND DESTROYING THE PLATFORM BELOW:

                        elif isinstance(self.cellclass_of_cell_right,
                                        Shovel) == True:
                            self.cellclass_of_cell_below_right = Destroyed_platform(
                                int(i.lemx // 16),
                                int(i.lemx // 16) + 1)
                            self.cellclass_of_cell_right.used = True
                        elif isinstance(self.cellclass_of_cell_left,
                                        Shovel) == True:
                            self.cellclass_of_cell_below_right = Destroyed_platform(
                                int(i.lemx // 16),
                                int(i.lemx // 16) + 1)
                            self.cellclass_of_cell_left.used = True

                        # IF NOTHING OF ABOVE HAPPENS, LET THE LEMMING MOVE:
                        else:
                            if i.being_blocker == False:  ### checking that they don't move if they are a blocker
                                i.move()

                    ## COLLISION WITH BLOCKER OBJECT TO TRANSFORM THE LEMMING

                    if isinstance(self.cellclass_of_cell_right,
                                  Blocker) == True:
                        if i.falling == False and i.falling_with_umbrella == False:
                            if i.checker_blocker == False:  ### just a checker to play the sound effect correctly
                                pyxel.play(2, 13)
                            i.converting_to_blocker(
                            )  ### transforming the lemming
                            self.cellclass_of_cell_right.used = True  ### making the blocker tool used

                            ### creating a Lemming blocker on the stablished position
                            self.boardmatrix[int(i.lemx / 16)][int(
                                i.lemy / 16)].cellclass = Blocker_lemming(
                                    i.lemx, i.lemy)

                    if isinstance(self.cellclass_of_cell_left,
                                  Blocker) == True:
                        if i.falling == False and i.falling_with_umbrella == False:
                            if i.checker_blocker == False:
                                pyxel.play(2, 13)
                            i.converting_to_blocker()
                            self.cellclass_of_cell_left.used = True

                            self.boardmatrix[int(
                                i.lemx / 16
                            )][int(i.lemy / 16)].cellclass = Blocker_lemming(
                                i.lemx, i.lemy
                            )  ### creating a Lemming blocker on the stablished position

                    ## COLLISION WITH EXIT GATE: SAVING THE LEMMINGS AND ENDING THE GAME

                    if (isinstance(self.cellclass_of_cell_right, Exitgate)
                            == True or isinstance(self.cellclass_of_cell_left,
                                                  Exitgate) == True):

                        i.save()  ###saving lemming
                        i.dissapear()  ###making it dissapear
                        if i.deactivate == False:  ###checker for sound effect
                            i.deactivate = True
                            pyxel.play(3, 11)
                            self.myscore.dellemming_saved()  ###adding to score

                ## FALLING LEMMING

                    if i.died == False or i.saved == False:

                        if (isinstance(self.cellclass_of_cell_below_right,
                                       Platform) == False or
                            (isinstance(self.cellclass_of_cell_below_left,
                                        Platform) == False
                             and i.direction == "L")):

                            i.falling = True
                            i.fall()
                            i.change_sprite("falling")
                            if i.falling_with_umbrella == True:
                                i.change_sprite("Umbrella falling")

                ## COLLISION WITH UMBRELLA OBJECT

                    if isinstance(self.cellclass_of_cell_below_right,
                                  Umbrella) == True:
                        pyxel.play(2, 8)  ### sound effect
                        i.umbrella_collision()
                        self.cellclass_of_cell_below_right.used = True  ### making umbrella an used tool

                ## REACHING FLOOR WITH AN UMBRELLA

                    if (i.falling == True
                            and isinstance(self.cellclass_of_cell_below_right,
                                           Platform) == True):
                        if i.falling_with_umbrella == True:
                            #disabling falling attributes
                            i.falling = False
                            i.falling_with_umbrella = False

                            ### making the lemming move again
                            i.move()
                            if i.direction == "R":
                                i.change_sprite("walking_R")
                            else:
                                i.change_sprite("walking_L")

                        else:
                            ## THIS WILL HAPPEN IF LEMMING FALL WITHOUT UMBRELLA. IT WILL DIE
                            ## AND DISSAPEAR
                            i.die()
                            if i.deactivate == False:  ##checker for sound effect
                                i.deactivate = True
                                pyxel.play(3, 14)
                                self.myscore.dellemming_died()

                #### LADDER COLLISIONS ####

                # This part of the program is not fully implemented. Lemmings are allow to climb down
                # ladders correctly and reach lower floors, but not to climb up them to reach upper floors.
                # See bug report for further information.

                ##ENCOUNTER WITH RIGHT LADDER ##

                ### all comments below can be applicable to the left ladder also

                    if (isinstance(self.cellclass_of_cell, Right_Ladder)):
                        if i.direction == "R":
                            i.collision_right_ladder_UP(
                            )  ## climbing lemming method
                            i.falling = False  ## not letting the lemming fall while climbing

                            self.cellclass_of_cell.used = True  ## make the ladder an used tool

                            if (isinstance(self.cellclass_of_cell, Platform)):
                                i.direction == "R"

                        elif i.direction == "L":
                            i.collision_left_ladder_UP()
                            i.falling = False

                            self.cellclass_of_cell.used = True

                            if (isinstance(self.cellclass_of_cell, Platform)):
                                i.direction == "R"

                    # MAKE THE LEMMING CLIMB DOWN THE LADDERS
                    # (self.cellclass_of_cell_below_left is used to check the cell below)

                    if (isinstance(self.cellclass_of_cell_below_left,
                                   Right_Ladder)):
                        if i.direction == "R":
                            i.collision_right_ladder_DOWN()
                            i.falling = False

                            self.cellclass_of_cell_below_left.used = True

                            if (isinstance(self.cellclass_of_cell, Platform)):
                                i.direction == "R"

                        elif i.direction == "L":
                            i.collision_left_ladder_DOWN()
                            i.falling = False

                            self.cellclass_of_cell_below_left.used = True

                            if (isinstance(self.cellclass_of_cell, Platform)):
                                i.direction == "R"

            ##ENCOUNTER WITH LEFT LADDER

                    if (isinstance(self.cellclass_of_cell, Left_Ladder)):
                        i.direction = "L"
                        i.collision_left_ladder_UP()
                        self.cellclass_of_cell.used = True

                        if (isinstance(self.cellclass_of_cell, Platform)):
                            i.direction == "R"

                    if (isinstance(self.cellclass_of_cell_below_left,
                                   Left_Ladder)):
                        if i.direction == "R":
                            i.collision_right_ladder_DOWN()
                            self.cellclass_of_cell_below_left.used = True
                            i.falling = False

                            if (isinstance(self.cellclass_of_cell, Platform)):
                                i.direction == "R"

                        elif i.direction == "L":
                            i.collision_left_ladder_DOWN()
                            i.falling = False

                            if (isinstance(self.cellclass_of_cell, Platform)):
                                i.direction == "R"

                    # LEMMINGS DYING WHEN REACHING LAVA (code not implemented, read info in lava module)
                    """
                    if (i.falling == True and isinstance(self.cellclass_of_cell_below_right, Lava) == True):
                            i.lava = True
                            i.die() 
                            if i.deactivate == False:           ##checker for sound effect
                                i.deactivate = True
                                pyxel.play(3,14)
                                self.myscore.dellemming_died()
                    """

                    # COLLISION OF LEMMINGS WITH EDGES OF THE GAME

                    if i.lemx >= WIDTH - 16 or i.lemx <= 0:
                        i.changeDirection()
                        if i.direction == "R":
                            i.change_sprite("walking_R")
                        else:
                            i.change_sprite("walking_L")
コード例 #9
0
ファイル: main.py プロジェクト: Alnya/RPG_by_pyxel
    def __init__(self):
        pyxel.init(width=WIDTH, height=HEIGHT, caption="Guildna")
        pyxel.load("assets/guildna.pyxres")
        self.text_h = HEIGHT // 16
        self.text_w = WIDTH // 8
        self.player_h = HEIGHT // 2 + 6
        self.player_w = WIDTH // 32
        self.enemy_height = HEIGHT * 3 // 8 - 12
        self.enemy_width = WIDTH // 2 - 16
        self.player_list = [
            Player(name="Aldo",
                   hp=160,
                   mp=80,
                   at=120,
                   df=100,
                   sp=300,
                   place=self.player_w),
            Player(name="Cyrus",
                   hp=130,
                   mp=100,
                   at=150,
                   df=90,
                   sp=330,
                   place=self.player_w + WIDTH // 4),
            Player(name="Riica",
                   hp=150,
                   mp=150,
                   at=100,
                   df=100,
                   sp=320,
                   place=self.player_w + WIDTH // 2),
            Player(name="Anabel",
                   hp=200,
                   mp=120,
                   at=100,
                   df=110,
                   sp=290,
                   place=self.player_w + (WIDTH * 3) // 4),
        ]
        self.enemy = Enemy(name="Guildna",
                           hp=2000,
                           mp="????",
                           at=100,
                           df=10,
                           sp=310)

        self.player_list[0].set_skill(skill_name="X BLADE",
                                      skill_type="attack",
                                      rate=5,
                                      skill_mp=40)
        self.player_list[1].set_skill(skill_name="NIRVANA SLASH",
                                      skill_type="attack",
                                      rate=1.7,
                                      skill_mp=20)
        self.player_list[2].set_skill(skill_name="POWER HEAL",
                                      skill_type="heal",
                                      rate=0.7,
                                      skill_mp=15)
        self.player_list[3].set_skill(skill_name="HOLY SWORD OF PRAYER",
                                      skill_type="attack",
                                      rate=2,
                                      skill_mp=30)

        self.select_list = [
            True,
            True,
            True,
            True,
        ]

        self.action_turn_list = []
        for player in self.player_list:
            self.action_turn_list.append(player)
        self.action_turn_list.append(self.enemy)
        self.alive_list = []

        self.light_ball_list = []
        self.aldo_ball_list = []
        self.fire_ball_list = []
        for _ in range(20):
            self.fire_ball_list.append(FireBall())
        self.title_ball_list = []
        for _ in range(10):
            self.title_ball_list.append(TitleBall())

        self.mode = TITLE
        self.fc = -1
        self.title_fc = -1
        self.dead_count = 0

        self.win_fc = -1
        self.lose_fc = -1

        pyxel.play(ch=0, snd=4, loop=True)

        pyxel.run(self.update, self.draw)
コード例 #10
0
    def update(self):
        if pyxel.btnp(pyxel.KEY_R):
            logger.info("Exit.")
            # pyxel.quit()
            self.reset()
        if pyxel.btnp(pyxel.KEY_B):
            self.boss_dead = True
            logger.debug("BOSS_FIGHT!")
        if pyxel.btnp(pyxel.KEY_Z):
            self.boss_fight = True

        self.flushingEnemies = True
        enemies = self.new_enemies
        self.new_enemies = []
        self.flushingEnemies = False

        for (sid, newEnemy) in enemies:
            self.enemies[sid] = newEnemy
            self.space.add(newEnemy.body, newEnemy.poly)
        """ update game objects """
        objs_to_kill = []
        for player in self.players.values():
            player.update(boss_dead=self.boss_dead)
            if player.dead:
                pyxel.play(2, 2)
                logger.debug(f"{player.id} is dead!")
                objs_to_kill.append(player)
            elif player.death_frames > 0:
                logger.debug(f"{player.id} is dying! {player.death_frames}")
                player.death_frames -= 1
                if player.death_frames <= 0:
                    logger.debug(
                        f"{player.id} TRUE DEATH! {player.death_frames}")
                    player.dead = True
            elif player.health <= 0:
                player.death_frames = settings.death_duration
        for enemy in self.enemies.values():
            enemy.update()
            if enemy.dead and isinstance(enemy, Boss):
                pyxel.play(2, 2)
                logger.debug(f"{enemy.id} is dead!")
                objs_to_kill.append(enemy)
            elif enemy.death_frames > 0:
                logger.debug(f"{enemy.id} is dying! {enemy.death_frames}")
                enemy.death_frames -= 1
                if enemy.death_frames <= 0:
                    logger.debug(
                        f"{enemy.id} TRUE DEATH! {enemy.death_frames}")
                    enemy.dead = True
                    if isinstance(enemy, Boss):
                        self.boss_dead = True
            elif enemy.health <= 0:
                enemy.death_frames = settings.death_duration

        # if self.boss_added:
        #     logger.debug(f"boss has {self.boss.health} health!")
        #     self.boss.update()
        #     if self.boss.dead:
        #         logger.debug(f"{self.boss.id} is dead!")
        #         objs_to_kill.append(self.boss)
        #     elif self.boss.death_frames > 0:
        #         logger.debug(f"{self.boss.id} is dying! {self.boss.death_frames}")
        #         self.boss.death_frames -= 1
        #         if self.boss.death_frames <= 0:
        #             logger.debug(f"{self.boss.id} TRUE DEATH! {self.boss.death_frames}")
        #             self.boss.dead = True
        #             self.boss_dead = True
        #     elif self.boss.health <= 0:
        #         self.boss.death_frames = settings.death_duration

        for obj in objs_to_kill:
            self.kill(obj)

        self.space.step(settings.space_dt)

        if (len(self.enemies) <
                settings.required_enemies) and not self.running:
            pyxel.frame_count = 0
        else:
            self.running = True
コード例 #11
0
    def update_tools_placement(self):
        """ THIS WILL DEFINE THE USER ACTIONS WITH THE LETTERS OF THE KEYBOARD:
        TOOLS PLACEMENT, TOOLS REMOVAL, AND GOD MODE ACTIONS"""

        ## IMPORTANT NOTE: FROM NOW ON WE USED ISINSTANCE() FUNCTION
        ## TO CHECK IF A GIVEN CELL CONTAINS SOME TYPE OF OBJECT (platforms, tools...)
        ## (we didn't see this on the course but it is a very simple function and very useful
        ## for the program, and we were allowed to use it)

        #### RIGHT LADDER ####

        if pyxel.btnp(pyxel.KEY_A):

            ## ALL THE COMMENTS OF THIS TOOL CAN BE APPLICABLE FOR ALL TOOLS.

            ##these variables above are checkers for the program to
            ##analyze the position of the user pointer.

            position_in_row = int(self.cursorY / 16)
            position_in_column = int(self.cursorX / 16)
            cellsee = self.boardmatrix[position_in_column][position_in_row]

            ##First, we make the code for removing the tool

            if (isinstance(cellsee.cellclass, Right_Ladder) == True
                    and cellsee.cellclass.used == False):
                cellsee.cellclass = None
                self.myscore.addLadder()
            else:
                ###placements of all tools
                if cellsee.cellclass == None:  ### no tool in selected cell
                    if self.myscore.ladders != 0:
                        cellsee.cellclass = Right_Ladder(
                            position_in_row, position_in_column)
                        self.myscore.delLadder()
                if isinstance(
                        cellsee.cellclass,
                        Umbrella) == True:  ### checking if umbrella is on cell
                    if self.myscore.ladders != 0:
                        if cellsee.cellclass.used == False:  ### checking if it is a placeholder or if it is used tool
                            self.myscore.addUmbrella()
                        cellsee.cellclass = Right_Ladder(
                            position_in_row,
                            position_in_column)  ### changing the tool
                        self.myscore.delLadder()

                if (isinstance(cellsee.cellclass, Left_Ladder) ==
                        True  ### checking if left ladder is on cell
                        and cellsee.cellclass.used == False):
                    if self.myscore.ladders != 0:  ### we dont make changes to score because right and left ladder are technically the same tool
                        cellsee.cellclass = Right_Ladder(
                            position_in_row, position_in_column)

                if isinstance(
                        cellsee.cellclass,
                        Blocker) == True:  ### checking if blocker is on cell
                    if self.myscore.ladders != 0:
                        if cellsee.cellclass.used == False:  ### checking if it is a placeholder or if it is used tool
                            self.myscore.addBlocker()
                        cellsee.cellclass = Right_Ladder(
                            position_in_row,
                            position_in_column)  ### changing the tool
                        self.myscore.delLadder()

                if isinstance(
                        cellsee.cellclass,
                        Shovel) == True:  ### checking if shovel is on cell
                    if self.myscore.shovels != 0:
                        if cellsee.cellclass.used == False:  ### checking if it is a placeholder or if it is used tool
                            self.myscore.addShovel()
                            cellsee.cellclass = Right_Ladder(
                                position_in_row,
                                position_in_column)  ### changing the tool
                            self.myscore.delLadder()

            ### sound effect

            pyxel.play(3, 9)

        #### LEFT LADDER ####

        if pyxel.btnp(pyxel.KEY_S):

            position_in_row = int(self.cursorY / 16)
            position_in_column = int(self.cursorX / 16)
            cellsee = self.boardmatrix[position_in_column][position_in_row]

            if (isinstance(cellsee.cellclass, Left_Ladder) == True
                    and cellsee.cellclass.used == False):
                cellsee.cellclass = None
                self.myscore.addLadder()
            else:
                if cellsee.cellclass == None:
                    if self.myscore.ladders != 0:
                        cellsee.cellclass = Left_Ladder(
                            position_in_row, position_in_column)
                        self.myscore.delLadder()

                if isinstance(cellsee.cellclass, Umbrella) == True:
                    if self.myscore.ladders != 0:
                        if cellsee.cellclass.used == False:
                            self.myscore.addUmbrella()
                        cellsee.cellclass = Left_Ladder(
                            position_in_row, position_in_column)
                        self.myscore.delLadder()

                if (isinstance(cellsee.cellclass, Right_Ladder) == True
                        and cellsee.cellclass.used == False):
                    if self.myscore.ladders != 0:
                        cellsee.cellclass = Left_Ladder(
                            position_in_row, position_in_column)

                if isinstance(cellsee.cellclass, Blocker) == True:
                    if self.myscore.ladders != 0:
                        if cellsee.cellclass.used == False:
                            self.myscore.addBlocker()
                        cellsee.cellclass = Left_Ladder(
                            position_in_row, position_in_column)
                        self.myscore.delLadder()

                if isinstance(cellsee.cellclass, Shovel) == True:
                    if self.myscore.shovels != 0:
                        if cellsee.cellclass.used == False:
                            self.myscore.addShovel()
                            cellsee.cellclass = Left_Ladder(
                                position_in_row, position_in_column)
                            self.myscore.delLadder()
            pyxel.play(3, 9)

        #### UMBRELLA ####

        if pyxel.btnp(pyxel.KEY_D):
            position_in_row = int(self.cursorY / 16)
            position_in_column = int(self.cursorX / 16)
            cellsee = self.boardmatrix[position_in_column][position_in_row]

            if (isinstance(cellsee.cellclass, Umbrella) == True
                    and cellsee.cellclass.used == False):
                self.myscore.addUmbrella()
                cellsee.cellclass = None

            else:
                if cellsee.cellclass == None:
                    if self.myscore.umbrellas != 0:
                        cellsee.cellclass = Umbrella(position_in_row,
                                                     position_in_column)
                        self.myscore.delUmbrella()

                if isinstance(cellsee.cellclass, Left_Ladder) == True:
                    if self.myscore.umbrellas != 0:
                        if cellsee.cellclass.used == False:
                            self.myscore.addLadder()
                            cellsee.cellclass = Umbrella(
                                position_in_row, position_in_column)
                            self.myscore.delUmbrella()

                if isinstance(cellsee.cellclass, Right_Ladder) == True:
                    if self.myscore.umbrellas != 0:
                        if cellsee.cellclass.used == False:
                            self.myscore.addLadder()
                            cellsee.cellclass = Umbrella(
                                position_in_row, position_in_column)
                            self.myscore.delUmbrella()

                if isinstance(cellsee.cellclass, Blocker) == True:
                    if self.myscore.umbrellas != 0:
                        if cellsee.cellclass.used == False:
                            self.myscore.addBlocker()
                        cellsee.cellclass = Umbrella(position_in_row,
                                                     position_in_column)
                        self.myscore.delUmbrella()

                if isinstance(cellsee.cellclass, Shovel) == True:
                    if self.myscore.shovels != 0:
                        if cellsee.cellclass.used == False:
                            self.myscore.addShovel()
                            cellsee.cellclass = Umbrella(
                                position_in_row, position_in_column)
                            self.myscore.delUmbrella()
            pyxel.play(3, 9)

        #### BLOCKER ####

        if pyxel.btnp(pyxel.KEY_F):
            position_in_row = int(self.cursorY / 16)
            position_in_column = int(self.cursorX / 16)
            cellsee = self.boardmatrix[position_in_column][position_in_row]

            if (isinstance(cellsee.cellclass, Blocker) == True
                    and cellsee.cellclass.used == False):
                self.myscore.addBlocker()
                cellsee.cellclass = None

            else:
                if cellsee.cellclass == None:
                    if self.myscore.blockers != 0:
                        cellsee.cellclass = Blocker(position_in_row,
                                                    position_in_column)
                        self.myscore.delBlocker()

                if isinstance(cellsee.cellclass, Left_Ladder) == True:

                    if self.myscore.blockers != 0:
                        if cellsee.cellclass.used == False:
                            self.myscore.addLadder()
                            cellsee.cellclass = Blocker(
                                position_in_row, position_in_column)
                            self.myscore.delBlocker()

                if isinstance(cellsee.cellclass, Right_Ladder) == True:
                    if self.myscore.blockers != 0:
                        if cellsee.cellclass.used == False:
                            self.myscore.addLadder()
                            cellsee.cellclass = Blocker(
                                position_in_row, position_in_column)
                            self.myscore.delBlocker()

                if isinstance(cellsee.cellclass, Umbrella) == True:
                    if self.myscore.umbrellas != 0:
                        if cellsee.cellclass.used == False:
                            self.myscore.addUmbrella()
                        cellsee.cellclass = Blocker(position_in_row,
                                                    position_in_column)
                        self.myscore.delBlocker()

                if isinstance(cellsee.cellclass, Shovel) == True:
                    if self.myscore.shovels != 0:
                        if cellsee.cellclass.used == False:
                            self.myscore.addShovel()
                            cellsee.cellclass = Blocker(
                                position_in_row, position_in_column)
                            self.myscore.delBlocker()
            pyxel.play(3, 9)

        #just for testing(ignore this):
        # CREATING USED OBJECTS FOR SCORE TESTING:
        # YOU CANNOT REMOVE USED LADDERS, AND IF YOU REMOVE USED TOOLS THEY WONT
        # BE ADDED TO TOOLS SCORE

        if pyxel.btnp(pyxel.KEY_G):
            position_in_row = int(self.cursorY / 16)
            position_in_column = int(self.cursorX / 16)
            cellsee = self.boardmatrix[position_in_column][position_in_row]
            cellsee.cellclass = Right_Ladder(position_in_row,
                                             position_in_column)
            cellsee.cellclass.used = True
        if pyxel.btnp(pyxel.KEY_H):
            position_in_row = int(self.cursorY / 16)
            position_in_column = int(self.cursorX / 16)
            cellsee = self.boardmatrix[position_in_column][position_in_row]
            cellsee.cellclass = Left_Ladder(position_in_row,
                                            position_in_column)
            cellsee.cellclass.used = True
        if pyxel.btnp(pyxel.KEY_J):
            position_in_row = int(self.cursorY / 16)
            position_in_column = int(self.cursorX / 16)
            cellsee = self.boardmatrix[position_in_column][position_in_row]
            cellsee.cellclass = Umbrella(position_in_row, position_in_column)
            cellsee.cellclass.used = True
        if pyxel.btnp(pyxel.KEY_K):
            position_in_row = int(self.cursorY / 16)
            position_in_column = int(self.cursorX / 16)
            cellsee = self.boardmatrix[position_in_column][position_in_row]
            cellsee.cellclass = Blocker(position_in_row, position_in_column)
            cellsee.cellclass.used = True

        #### EXTRA FEATURES ####

        #   SHOVEL:
        #   SPRITE OF DESTROYED PLATFORM IS DRAWN ON PYXEL EDITOR
        #   UT WE DIN'T FIGURE OUT HOW TO DRAW IT ON THE GAME

        if pyxel.btnp(pyxel.KEY_E):

            position_in_row = int(self.cursorY / 16)
            position_in_column = int(self.cursorX / 16)
            cellsee = self.boardmatrix[position_in_column][position_in_row]

            if (isinstance(cellsee.cellclass, Shovel) == True
                    and cellsee.cellclass.used == False):
                self.myscore.addShovel()
                cellsee.cellclass = None
            else:
                if cellsee.cellclass == None:
                    if self.myscore.shovels != 0:
                        cellsee.cellclass = Shovel(position_in_row,
                                                   position_in_column)
                        self.myscore.delShovel()

                if isinstance(cellsee.cellclass, Left_Ladder) == True:

                    if self.myscore.shovels != 0:
                        if cellsee.cellclass.used == False:
                            self.myscore.addLadder()
                            cellsee.cellclass = Shovel(position_in_row,
                                                       position_in_column)
                            self.myscore.delShovel()

                if isinstance(cellsee.cellclass, Right_Ladder) == True:
                    if self.myscore.shovels != 0:
                        if cellsee.cellclass.used == False:
                            self.myscore.addLadder()
                            cellsee.cellclass = Shovel(position_in_row,
                                                       position_in_column)
                            self.myscore.delShovel()

                if isinstance(cellsee.cellclass, Umbrella) == True:
                    if self.myscore.shovels != 0:
                        if cellsee.cellclass.used == False:
                            self.myscore.addUmbrella()
                        cellsee.cellclass = Shovel(position_in_row,
                                                   position_in_column)
                        self.myscore.delShovel()

                if isinstance(cellsee.cellclass, Blocker) == True:
                    if self.myscore.shovels != 0:
                        if cellsee.cellclass.used == False:
                            self.myscore.addBlocker()
                        cellsee.cellclass = Shovel(position_in_row,
                                                   position_in_column)
                        self.myscore.delShovel()

            pyxel.play(3, 9)

        ##### GOD MODE #####
        #   WE CAN CREATE AND REMOVE AS MUCH PLATFORMS AS WE WANT WITH THIS CODE BELOW.
        #   ALSO, THE ZAWARUDO VARIABLE ALLOWS THE PLAYER TO STOP TIME, AND THEREFORE,
        #   THE LEMMINGS MOVEMENT.

        ## ACTIVATE GOD MODE
        if pyxel.btnp(pyxel.KEY_V):
            self.god_mode = True
            pyxel.play(3, 15)
        ## DISABLE GOD MODE
        if pyxel.btnp(pyxel.KEY_B):
            self.god_mode = False
            pyxel.play(3, 15)

        if self.god_mode == True:

            ##CREATING PLATFORMS
            if pyxel.btnp(pyxel.KEY_P):
                position_in_row = int(self.cursorY / 16)
                position_in_column = int(self.cursorX / 16)
                cellsee = self.boardmatrix[position_in_column][position_in_row]
                if isinstance(cellsee.cellclass, Platform) == True:
                    cellsee.cellclass = None
                else:
                    cellsee.cellclass = Platform(position_in_row,
                                                 position_in_column)

            ## STOPPING TIME (ZAWARUDO MODE)
            if pyxel.btnp(pyxel.KEY_Z):
                self.zawarudo = True
                pyxel.play(3, 16)
            ## DISABLING ZAWARUDO MODE
            if pyxel.btnp(pyxel.KEY_X):
                self.zawarudo = False
                pyxel.play(3, 16)
コード例 #12
0
 def voice(self, selection):
     if (self.played is False):
         pyxel.play(2, selection)
         self.start = time.time()
         self.played = True
コード例 #13
0
 def start_music(self):
     """Start all music tracks (channels 1 - 3)."""
     pyxel.play(ch=1, snd=10, loop=True)
     pyxel.play(ch=2, snd=11, loop=True)
コード例 #14
0
 def sfx_pickup(self):
     pyxel.play(ch=0, snd=3)
コード例 #15
0
def playSE():
    pyxel.play(0, 0)
コード例 #16
0
ファイル: main.py プロジェクト: Alnya/RPG_by_pyxel
    def attack(self, player):
        efc = (pyxel.frame_count - self.fc) % SPEED
        self.attacker_status_effect(player)

        if player.is_attack or player.skill_type == "attack" and player.mp_after_skill >= 0:
            if SPEED // 2 <= efc:
                message = f"{player.damage} damage to {self.enemy.name}!"
                ans = self.return_message(message, efc - SPEED // 2)
                pyxel.text(x=self.text_w, y=self.text_h + 8, s=f"{ans}", col=7)

        if player.is_attack:
            if efc == SPEED // 2 - 1:
                player.damage = int(
                    player.at * random.uniform(0.9, 1.1)) - int(
                        self.enemy.df * random.uniform(0.4, 0.6))
                self.enemy.hp -= player.damage
            message = f"{player.name}'s ATTACK!!"
            ans = self.return_message(message, efc)
            pyxel.text(x=self.text_w, y=self.text_h, s=f"{ans}", col=7)
            self.draw_attacked_enemy_hp()
            self.attack_effect(player)
        else:
            if efc == 0:
                player.mp_after_skill = player.mp - player.skill_mp
            if player.mp_after_skill < 0:
                message = f"{player.name}'s SKILL! {player.skill_name}!!"
                ans = self.return_message(message, efc)
                pyxel.text(x=self.text_w, y=self.text_h, s=f"{ans}", col=7)
                if SPEED // 2 <= efc:
                    message = f"BUT {player.name} HAS NOT ENOUGH MP..."
                    ans = self.return_message(message, efc - SPEED // 2)
                    pyxel.text(x=self.text_w,
                               y=self.text_h + 8,
                               s=f"{ans}",
                               col=8)
            else:
                if player.skill_type == "heal":
                    if efc == 0:
                        player.mp = player.mp_after_skill
                        player.damage = int(player.at * player.rate *
                                            random.uniform(0.9, 1.1))
                elif efc == SPEED // 2 - 1:
                    player.mp = player.mp_after_skill
                    player.damage = int(player.at * player.rate *
                                        random.uniform(0.9, 1.1))
                    if player.skill_type == "attack":
                        player.damage -= self.enemy.df
                        self.enemy.hp -= player.damage

                message = f"{player.name}'s SKILL! {player.skill_name}!!"
                ans = self.return_message(message, efc)
                pyxel.text(x=self.text_w, y=self.text_h, s=f"{ans}", col=7)
                if player.skill_type == "attack":
                    self.draw_attacked_enemy_hp()
                    if SPEED // 2 <= efc < SPEED // 2 + 5:
                        self.effect_when_enemy_is_attacked()
                    if player.name == "Aldo":
                        self.x_blade_effect()
                    elif player.name == "Cyrus":
                        self.nirvana_slash_effect()
                    elif player.name == "Anabel":
                        self.holy_sword_of_prayer()
                    else:
                        self.attack_effect(player)
                elif player.skill_type == "heal":
                    if efc == 0:
                        self.alive_list = []
                        for player in self.player_list:
                            if player.is_alive:
                                self.alive_list.append(player)
                    if SPEED // 2 <= efc:
                        message = f"Everyone gets {player.damage} points of heal!!"
                        ans = self.return_message(message, efc - SPEED // 2)
                        pyxel.text(x=self.text_w,
                                   y=self.text_h + 8,
                                   s=f"{ans}",
                                   col=7)
                    for i in range(len(self.alive_list)):
                        p = self.alive_list[i]
                        if SPEED // 4 + i * 9 == efc:
                            p.hp += player.damage
                            pyxel.play(1, 11)
                        if SPEED // 4 + i * 9 <= efc:
                            pyxel.text(x=p.place,
                                       y=self.player_h + 8,
                                       s=f"HP {p.hp}/{p.max_hp}",
                                       col=3)
                    self.heal_effect()
コード例 #17
0
def playGameover():
    pyxel.play(0, 1)
コード例 #18
0
 def playSound(self,sound):
     if sound == "coin":
         pyxel.play(1,0)
     elif sound == "explosion":
         pyxel.stop()
         pyxel.play(2,1)
コード例 #19
0
def start_accelerate():
    pyxel.play(1, 2, loop=True)
コード例 #20
0
ファイル: bgm.py プロジェクト: rui7157/PyPlaneWars
 def bombSound(self):
     px.play(2, 0, loop=False)
コード例 #21
0
def hit():
    pyxel.play(2, 4)
コード例 #22
0
ファイル: bgm.py プロジェクト: rui7157/PyPlaneWars
 def bulletSound(self):
     px.play(2, 6, loop=False)
コード例 #23
0
    def update(self):
        # checking if need to start game over music
        if self.start_music_game_over:
            pyxel.play(0, 6)
            self.start_music_game_over = False

        # checking if need to start game won music
        if self.start_music_game_won:
            pyxel.play(0, 7)
            self.start_music_game_won = False

        if pyxel.btnp(pyxel.MOUSE_LEFT_BUTTON) or pyxel.btn(pyxel.KEY_N) or pyxel.btn(pyxel.KEY_1) \
                or pyxel.btn(pyxel.KEY_2) or pyxel.btn(pyxel.KEY_3):
            x = pyxel.mouse_x
            y = pyxel.mouse_y

            # clicked generate tree button
            if x < 64 and y < 15 or pyxel.btn(pyxel.KEY_N):
                self.reset()
                self.index_to_check = -1
                self.mode_pre_order = False
                self.mode_post_order = False
                self.mode_in_order = False
                self.generate_tree()
                pyxel.play(0, 1)

            # clicked pre-order button
            elif 64 <= x < 128 and y < 15 or pyxel.btn(pyxel.KEY_1):
                self.reset()
                self.mode_pre_order = True
                self.mode_post_order = False
                self.mode_in_order = False
                self.pre_order(self.root)
                pyxel.play(0, 3)

            # clicked in-order button
            elif 128 <= x < 192 and y < 15 or pyxel.btn(pyxel.KEY_2):
                self.reset()
                self.mode_in_order = True
                self.mode_post_order = False
                self.mode_pre_order = False
                self.in_order(self.root)
                pyxel.play(0, 3)

            # clicked post-order button
            elif 192 <= x and y < 15 or pyxel.btn(pyxel.KEY_3):
                self.reset()
                self.mode_post_order = True
                self.mode_pre_order = False
                self.mode_in_order = False
                self.post_order(self.root)
                pyxel.play(0, 3)

            # check if clicked on a node
            for node in self.nodes:
                if node.inside(x, y) and len(self.list_of_orders) != 0 and self.index_to_check < len(self.list_of_orders):

                    # check if correct node
                    if node == self.list_of_orders[self.index_to_check]:
                        node.set_selected(True)
                        self.index_to_check += 1
                        pyxel.play(0, 4)

                        # check if this was the last node needed
                        if self.index_to_check >= len(self.list_of_orders):
                            self.start_music_game_won = True

                    # else wrong node
                    else:
                        pyxel.play(0, 0)
                        self.num_of_lives -= 1

                        # check if this was the last live
                        if self.num_of_lives == 0:
                            self.start_music_game_over = True
コード例 #24
0
ファイル: bgm.py プロジェクト: rui7157/PyPlaneWars
 def gameoverSound(self):
     px.play(2, 7, loop=False)
コード例 #25
0
def play_music(ch0, ch1, ch2):
    if ch0:
        pyxel.play(0, 0, loop=True)
    else:
        pyxel.stop(0)
コード例 #26
0
    def update(self):

        if pyxel.btn(pyxel.KEY_R):
            self.death = False
            self.win = False
            self.field = TABLE.copy()
            self.field = add_random(self.field)
            pyxel.stop()
            pyxel.playm(MUSIC, loop=True)

        # открытие меню настроек
        if pyxel.btn(pyxel.KEY_O):
            self.options = -1

        # обработка выхода из программы
        if pyxel.btn(pyxel.KEY_Q):
            pyxel.quit()

        # смена дизайна на первый или второй
        if pyxel.btn(pyxel.KEY_1):
            self.design = 1
        if pyxel.btn(pyxel.KEY_2):
            self.design = -1
        if pyxel.btn(pyxel.KEY_ENTER):
            pyxel.playm(MUSIC, loop=True)
        if pyxel.btn(pyxel.KEY_SPACE):
            pyxel.stop()
        # выход из меню настроек
        if pyxel.btn(pyxel.KEY_G):
            self.options = 1

        ####################
        # KEYS & MOVEMENTS #
        ####################
        # при нажатии кнопок движения таблица сдвигается в
        # соответствующую сторону

        if pyxel.btnp(pyxel.KEY_UP):  # IF USER PRESSES "UP"
            check = self.field.copy()
            move_up(self.field)
            # не ставлю новое число, если таблица осталась той же
            if not np.equal(self.field, check).all():
                self.field = add_random(self.field)
            else:
                pyxel.play(3, 19)
                if 0 not in self.field:
                    if death_event(self.field) == 0:
                        pyxel.play(3, 29)
                        self.death = True

        if pyxel.btnp(pyxel.KEY_DOWN):  # IF USER PRESSES "DOWN"
            check = self.field.copy()
            move_down(self.field)
            if not np.equal(self.field, check).all():
                self.field = add_random(self.field)
            else:
                pyxel.play(3, 19)
                if 0 not in self.field:
                    if death_event(self.field) == 0:
                        pyxel.play(3, 29)
                        self.death = True

        if pyxel.btnp(pyxel.KEY_RIGHT):  # IF USER PRESSES "RIGHT"
            check = self.field.copy()
            move_right(self.field)
            if not np.equal(self.field, check).all():
                self.field = add_random(self.field)
            else:
                pyxel.play(3, 19)
                if 0 not in self.field:
                    if death_event(self.field) == 0:
                        pyxel.play(3, 29)
                        self.death = True

        if pyxel.btnp(pyxel.KEY_LEFT):  # IF USER PRESSES "LEFT"
            check = self.field.copy()
            move_left(self.field)
            if not np.equal(self.field, check).all():
                self.field = add_random(self.field)
            else:
                pyxel.play(3, 19)
                if 0 not in self.field:
                    if death_event(self.field) == 0:
                        pyxel.play(3, 29)
                        self.death = True
コード例 #27
0
    def handle_playing_events(self):
        if pyxel.btnp(pyxel.MOUSE_RIGHT_BUTTON):
            # If user is clicking
            if pyxel.mouse_x > self._grid_start_x and pyxel.mouse_y > self._grid_start_y:
                row, col = self.get_grid_row_col_from_xy(
                    pyxel.mouse_x, pyxel.mouse_y)

                if row < 0 or row >= self._grid_size or col < 0 or col >= self._grid_size:
                    return

                clicked_tile = self.game_grid[row][col]

                if (row, col) not in self.clicked_tiles:
                    if (row, col) not in self.flagged_tiles:
                        self.flagged_tiles[(row, col)] = True
                    else:
                        self.flagged_tiles[(
                            row, col)] = not self.flagged_tiles[(row, col)]

        if pyxel.btnp(pyxel.MOUSE_LEFT_BUTTON):
            mouse_within = partial(is_within, pyxel.mouse_x, pyxel.mouse_y)

            if mouse_within(self._playing_real_back_button):
                self.game_state = GameState.INTRO
                pyxel.stop(self._playing_bg)
                pyxel.play(self._main_bg, [0, 1], loop=True)

            # If user is clicking
            if pyxel.mouse_x > self._grid_start_x and pyxel.mouse_y > self._grid_start_y:
                row, col = self.get_grid_row_col_from_xy(
                    pyxel.mouse_x, pyxel.mouse_y)

                if row < 0 or row >= self._grid_size or col < 0 or col >= self._grid_size:
                    return

                clicked_tile = self.game_grid[row][col]

                if ((row, col)
                        not in self.clicked_tiles) and not self.is_flagged(
                            (row, col)):
                    self.clicked_tiles[(row, col)] = True

                    if clicked_tile is ql.TileItems.GOLDEN_CAT:
                        self.game_state = GameState.WON
                        pyxel.stop(self._playing_bg)
                        pyxel.play(self._main_bg, [0, 1], loop=True)

                    # Call quantum computer to see if we reveal of nah
                    reveal_state = ql.onclick(clicked_tile)

                    # Move golden cat away from item
                    if reveal_state is ql.TileItems.NEG_EVAL:
                        offset_x = -1 if self.golden_cat_x < col else 1
                        offset_x = 0 if self.golden_cat_x == col else offset_x

                        offset_y = -1 if self.golden_cat_y < row else 1
                        offset_y = 0 if self.golden_cat_y == row else offset_y

                        # Move cat if the destination position is not clicked
                        if not self.swap_golden_cat_with(
                                self.golden_cat_x + offset_x,
                                self.golden_cat_y):
                            self.swap_golden_cat_with(
                                self.golden_cat_x,
                                self.golden_cat_y + offset_y)

                    if reveal_state is ql.TileItems.POS_EVAL or \
                            reveal_state is ql.TileItems.BOMB_DEFUSED \
                            or reveal_state.value in ql.TileItems.TILE_NUMBERS.value:
                        # TODO: Move golden cat towards item
                        offset_x = 1 if self.golden_cat_x < col else -1
                        offset_x = 0 if self.golden_cat_x == col else offset_x

                        offset_y = 1 if self.golden_cat_y < row else -1
                        offset_y = 0 if self.golden_cat_y == row else offset_y

                        # Move cat if the destination position is not clicked
                        if not self.swap_golden_cat_with(
                                self.golden_cat_x + offset_x,
                                self.golden_cat_y):
                            self.swap_golden_cat_with(
                                self.golden_cat_x,
                                self.golden_cat_y + offset_y)

                    # When bomb doesn't explode it turns into blank
                    if reveal_state is ql.TileItems.BOMB_DEFUSED:
                        self.game_grid[row][col] = ql.TileItems.BOMB_DEFUSED

                    if reveal_state is ql.TileItems.BOMB_EXPLODED:
                        self.game_grid[row][col] = ql.TileItems.BOMB_EXPLODED
                        self.game_state = GameState.LOST
                        pyxel.stop(self._playing_bg)
                        pyxel.play(self._losing_bg, 4, loop=True)
コード例 #28
0
    def Update(self):
        self.controller.Update()

        if 9 in self.controller.up_list:
            self.Clear()
            return

        if not self.game:
            if pyxel.play_pos(0) != -1:
                pyxel.stop(0)
            return

        if pyxel.play_pos(0) == -1:
            pyxel.playm(0, loop=True)

        if self.enemy_pre_position == self.enemy_position:
            self.game_count += 1
            if self.game_count > 30:
                self.game = False
                print('[###,###]CLEAR THE GAME')
                return
        else:
            self.game_count = 0

        self.pre_pos = self.pos[:]
        self.pos[0] += self.controller.stick[0] * self.move_scale
        self.pos[1] += self.controller.stick[1] * self.move_scale

        self.enemy_pre_position = self.enemy_position[:]
        self.enemy_position[0] += self.enemy_normal[0]
        self.enemy_position[1] += self.enemy_normal[1]

        result = self.field.JudgeLine(self.field.border_line,
                                      self.field.border_line_sub,
                                      self.enemy_position)
        if len(result) > 0:
            self.enemy_position = self.enemy_pre_position[:]
            self.enemy_pre_normal = self.enemy_normal[:]
            self.enemy_normal = [0, 0]
            start_time = time()
            while 2 > time() - start_time and (self.enemy_normal == [0, 0]
                                               or self.enemy_normal
                                               == self.enemy_pre_normal):
                self.enemy_normal = [[
                    -1 * self.move_scale, 0, 1 * self.move_scale
                ][ri(-1, 1)], [-1 * self.move_scale, 0,
                               1 * self.move_scale][ri(-1, 1)]]
            if not 2 > time() - start_time:
                self.game = False
                self.game_message = 'GAMEOVER'
                print('[###,###]GAMEOVER')
                return
        result = self.field.JudgeLine(self.field.creation_line,
                                      self.field.creation_line_sub,
                                      self.enemy_position)
        if len(result) > 0:
            self.game = False
            self.game_message = 'GAMEOVER'
            print('[###,###]GAMEOVER')
            return

        result = self.field.JudgeLine(self.field.creation_line,
                                      self.field.creation_line_sub, self.pos)
        if len(result) > 0:
            if self.field.creation[0][0] != self.pos:
                self.pos = self.pre_pos[:]
                return

        self.pre_on_line = self.on_line
        result = self.field.JudgeLine(self.field.border_line,
                                      self.field.border_line_sub, self.pos)
        if len(result) > 0:
            self.on_line = True
        else:
            self.on_line = False

        if not self.on_line and self.pre_on_line:
            # 領域外に出たとき
            result = self.field.JudgeLine(self.field.border_line,
                                          self.field.border_line_sub,
                                          self.pre_pos)
            for num, index in result:
                normal = [0, 0]
                normal[num] = self.field.border_line_normal[num][index]
                if normal == self.controller.stick:
                    self.field.creation[0][0] = self.pre_pos[:]
                    self.field.creation[1][0] = self.field.ConvertToNormal(
                        self.controller.stick)
                    self.field.creation[2][0] = self.pos[:]
                    self.field.CreationUpdate(self.controller.stick, self.pos,
                                              self.pre_pos)
                    return
            self.pos = self.pre_pos[:]
            self.on_line = True
            return
        elif self.on_line and not self.pre_on_line:
            print(f'[{self.pos[0]:>3},{self.pos[1]:>3}]draw end')
            self.field.creation[0][1] = self.pos[:]
            self.field.creation[1][1] = self.field.ConvertToNormal(
                self.controller.stick)
            self.field.creation[2][1] = self.pre_pos[:]
            self.field.CreationUpdate(self.controller.stick, self.pos,
                                      self.pre_pos)
            if self.field.Search(self.enemy_position) == 'error':
                self.game = False
                self.game_message = 'GAMEOVER'
                print('[###,###]GAMEOVER')
                return
            self.field.UpdateAllLine()
            self.field.UpdateBorderLine()
            self.field.CreationClear()
        elif not self.on_line and not self.pre_on_line:
            self.field.CreationUpdate(self.controller.stick, self.pos,
                                      self.pre_pos)
            # 領域の塗りつぶしと割合の計算

        if not self.on_line and self.pre_pos != self.pos:
            pyxel.play(1, 1)
        elif pyxel.play_pos(1) != -1:
            pyxel.stop(1)
コード例 #29
0
 def play_music(self):
     pyxel.play(0, [0, 1], loop=True)
     pyxel.play(1, [2, 3], loop=True)
     pyxel.play(2, 4, loop=True)
コード例 #30
0
 def sfx_finish(self):
     """Play finish sound."""
     pyxel.play(ch=0, snd=1)