예제 #1
0
        def update(self):
            if pyxel.btnp(pyxel.KEY_Q):
                pyxel.quit()

            self.bola.update()

            for barra in self.barras:
                barra.update()

                if (barra.hitbox.x1 < self.bola.position.x < barra.hitbox.x2
                and barra.hitbox.y1 < self.bola.position.y < barra.hitbox.y2):
                    self.bola.velocidade.x = -self.bola.velocidade.x
                    self.score += 1
                    print(self.score)

            if (self.bola.position.x < 0 or
                self.bola.position.x > LARGURA_TELA):
                pyxel.quit()
예제 #2
0
    def update(self):
        if pyxel.btnp(pyxel.KEY_Q):
            pyxel.quit()

        if pyxel.btnp(pyxel.KEY_1):
            self.play_music(True, True, True)

        if pyxel.btnp(pyxel.KEY_2):
            self.play_music(True, False, False)

        if pyxel.btnp(pyxel.KEY_3):
            self.play_music(False, True, False)

        if pyxel.btnp(pyxel.KEY_4):
            self.play_music(False, False, True)

        if pyxel.btnp(pyxel.KEY_5):
            self.play_music(False, False, False)
예제 #3
0
    def update(self):
        if pyxel.btnp(pyxel.KEY_ESCAPE):
            pyxel.quit()

        if not self.isRoundActive:
            if pyxel.btnp(pyxel.KEY_ENTER):
                if self.hasGameEnded:
                    self.p1Score = 0
                    self.p2Score = 0
                self.initValues()

        if self.isRoundActive:
            self.updateControlKeys()
            self.checkBallCollision()
            self.checkGameEndScore()

            self.Bx = self.Bx + self.vx
            self.By = self.By + self.vy
예제 #4
0
    def update(self):
        """Update the game settings."""
        # This could use a refactor, but it's pointless to refactor before we
        # know what all the controls should be.

        if pyxel.btnp(pyxel.KEY_Q):
            pyxel.quit()
        elif pyxel.btnp(pyxel.KEY_W):
            self.player.walk(0)
        elif pyxel.btnp(pyxel.KEY_D):
            self.player.walk(2)
        elif pyxel.btnp(pyxel.KEY_S):
            self.player.walk(4)
        elif pyxel.btnp(pyxel.KEY_A):
            self.player.walk(6)

        for objekt in self.things:
            objekt.update()
예제 #5
0
    def Update(self):
        prev_gama_state = self.gama_state
        if self.gama_state == GamaState.Title:
            self.gama_state = self.title.Update()
        elif self.gama_state == GamaState.GamaMain:
            self.gama_state = self.gama_main.Update()
        elif self.gama_state == GamaState.GamaResult:
            self.gama_state = self.gama_result.Update()
        elif self.gama_state == GamaState.Exit:
            pyxel.quit()
        else:
            raise Exception("updateで存在しないGamaStateが選択されました。")

        if prev_gama_state != self.gama_state:
            if self.gama_state == GamaState.GamaMain:
                self.gama_main = GamaMain()
            if self.gama_state == GamaState.GamaResult:
                self.gama_result.SetResutl(self.gama_main)
예제 #6
0
파일: game.py 프로젝트: redream/GeneticAlgo
def update():
    global show_labels, eye_debug
    if pyxel.btnp(pyxel.KEY_Q):
        pyxel.quit()

    if pyxel.btnp(pyxel.KEY_T):
        show_labels = not show_labels

    if pyxel.btnp(pyxel.KEY_D):
        eye_debug = not eye_debug

    for bug in bugs:
        bug.update(food, bugs)

    for bit in food:
        bit.update()

    for bit in list(food):
        if bit.eaten:
            food.remove(bit)

    if pyxel.frame_count % 4 == 0:
        empty_spot = False
        while empty_spot == False:

            x = random.uniform(10, 246)
            y = random.uniform(10, 246)
            empty_spot = True

            for bug in bugs:
                dist = math.sqrt((x - bug.x)**2 + (y - bug.y)**2)

                if dist < 30:
                    empty_spot = False
                    break

        food.append(Food(x, y, False))

    for bug in list(bugs):
        if bug.dead:
            bugs.remove(bug)
            if len(bugs) < 15:
                bugs.append(
                    Bug(random.uniform(10, 246), random.uniform(10, 246)))
예제 #7
0
def update():
    global puzzle_board
    global solution_board
    global is_valid
    global cell_selected
    global selected_value
    global game_won
    import pyxel
    if pyxel.btnp(pyxel.KEY_Q):
        pyxel.quit()

    # select the board spot when the player clicks the left mouse button
    if pyxel.btnp(pyxel.MOUSE_LEFT_BUTTON):
        mouse_pos = (pyxel.mouse_x, pyxel.mouse_y)
        print(mouse_pos)
        board_spot = get_board_spot(*mouse_pos)
        if mouse_pos[1] < 155:
            cell_selected = board_spot
        else:
            selected_value = board_spot[0] + 1
            print('selected value:', selected_value)
    # update the board spot when the player clicks the right mouse button
    if pyxel.btnp(pyxel.MOUSE_RIGHT_BUTTON):
        mouse_pos = (pyxel.mouse_x, pyxel.mouse_y)
        print(mouse_pos)
        board_spot = get_board_spot(*mouse_pos)
        x, y = board_spot
        cell_value = puzzle_board[x][y]
        if cell_value != selected_value:
            puzzle_board[x][y] = selected_value
        else:
            puzzle_board[x][y] = 0

    is_valid = board_valid(puzzle_board, solution_board)

    if board_is_full(puzzle_board):
        print('full')
        if board_valid(puzzle_board):
            print('hi')
            game_won = True
        else:
            game_won = False
    else:
        game_won = False
예제 #8
0
    def update(self):
        if pyxel.btnp(pyxel.KEY_Q):
            pyxel.quit()

        if pyxel.btn(pyxel.constants.KEY_Z) and self.is_player_grounded():
            self.player.v_velo = -3.2
            self.player.state = 'jump'
        if pyxel.btn(pyxel.constants.KEY_LEFT):
            self.player.h_velo = -1
            self.player.state = 'move'
            self.player.facing = 'left'
            self.player_move_count = (self.player_move_count + 1) % 6
        if pyxel.btn(pyxel.constants.KEY_RIGHT):
            self.player.h_velo = 1
            self.player.state = 'move'
            self.player.facing = 'right'
            self.player_move_count = (self.player_move_count + 1) % 6

        self.update_player()
예제 #9
0
    def update_title(self):
        '''
        タイトル
        '''
        if self.selected == 0:
            if pyxel.btnp(pyxel.KEY_N):
                pyxel.stop()
                pyxel.play(3, 0, loop=False)
                self.selected = 1
                self.tick = 0

            if pyxel.btnp(pyxel.KEY_C) and self.doContinue:
                pyxel.stop()
                pyxel.play(3, 0, loop=False)
                self.selected = 2
                self.tick = 0

            if pyxel.btnp(pyxel.KEY_Q):
                pyxel.stop()
                pyxel.play(3, 0, loop=False)
                self.selected = 3
                self.tick = 0

        else:
            if self.tick > 21:
                if self.selected == 1:
                    self.selected = 0
                    self.stateStack.push(State.MAKECHARACTER)
                elif self.selected == 2:
                    # セーブデータをロード
                    with open("savedata.dat", mode="rb") as f:
                        SaveData = pickle.load(f)
                    # stateStackを復元する
                    self.stateStack.states = SaveData.states
                    # 先頭は必ずキャンプなので、popする
                    self.stateStack.pop()
                    # StateStackへの参照を設定し直す
                    for state in self.stateStack.states:
                        state.stateStack = self.stateStack
                    # プレイヤーパーティーの復元
                    playerParty.resotreSaveData(SaveData.playerParty)
                elif self.selected == 3:
                    pyxel.quit()
예제 #10
0
    def update(self):
        pyxel.mouse(True)
        if pyxel.btnp(pyxel.KEY_Q):
            pyxel.quit()

        for i in range(len(self.credito)):
            self.credAlt[i] -= .5

        for j in range(len(self.credAlt)):
            if self.credAlt[j] < 20:
                self.credAlt[j] += 210

        if pyxel.mouse_x > 3 and pyxel.mouse_x < 11:
            if pyxel.mouse_y > self.height / 16 and pyxel.mouse_y < self.height / 16 + 8:
                self.animSeta = 1
            else:
                self.animSeta = 0
        else:
            self.animSeta = 0
예제 #11
0
파일: pong.py 프로젝트: izmirli/pyxel
 def handle_key_input(self):
     if pyxel.btn(pyxel.KEY_Q):
         pyxel.play(0, self.sound['quit'])
         pyxel.quit()
         return
     if pyxel.btn(pyxel.KEY_R):
         self.restart()
     if pyxel.btnp(pyxel.KEY_P):
         self.game_paused = not self.game_paused
         pyxel.play(0, self.sound['paused'])
     if pyxel.btn(pyxel.KEY_UP):
         self.p1['vy'] = -HANDLE_SPEED
     if pyxel.btn(pyxel.KEY_DOWN):
         self.p1['vy'] = HANDLE_SPEED
     if not self.bot:
         if pyxel.btn(pyxel.KEY_W):
             self.p2['vy'] = -HANDLE_SPEED
         if pyxel.btn(pyxel.KEY_S):
             self.p2['vy'] = HANDLE_SPEED
예제 #12
0
    def update(self):
        if pyxel.btnp(pyxel.KEY_Q):
            pyxel.quit()

        if pyxel.btn(pyxel.KEY_RIGHT):
            if self.x <= MAP_WIDTH-SCREEN_PIXELS:
                self.x = self.x + 1
                
        if pyxel.btn(pyxel.KEY_LEFT):
            if self.x > 0:                
                self.x = self.x - 1

        if pyxel.btn(pyxel.KEY_DOWN):
            if self.y <= MAP_HEIGHT-SCREEN_PIXELS:                
                self.y = self.y + 1

        if pyxel.btn(pyxel.KEY_UP):
            if self.y > 0:                
                self.y = self.y - 1
예제 #13
0
    def update(self):
        if pyxel.btnp(pyxel.KEY_Q):
            pyxel.quit()

        if self.game_state == GameState.INTRO:
            self.handle_intro_events()

        elif self.game_state == GameState.PLAYER1:
            self.handle_player1()
        elif self.game_state == GameState.PLAYER2:
            self.handle_player2()
        elif self.game_state == GameState.PLAYER3:
            self.handle_player3()
        elif self.game_state == GameState.PLAYER4:
            self.handle_player4()
        elif self.game_state == GameState.CIRCUIT:
            self.handle_circuit()
        elif self.game_state == GameState.RESULTS:
            self.handle_results()
예제 #14
0
 def update(self):
     if pyxel.btnp(pyxel.KEY_Q):
         pyxel.quit()
     if pyxel.btnp(pyxel.KEY_LEFT):
         self.startx = 1
     elif pyxel.btnp(pyxel.KEY_RIGHT):
         self.startx = 0
     if pyxel.btnp(pyxel.KEY_DOWN):
         self.start = 0
     elif pyxel.btnp(pyxel.KEY_UP):
         self.start = 1
     if self.start == 1:
         self.y = (self.y - 1) % pyxel.height
     else:
         self.y = (self.y + 1) % pyxel.height
     if self.startx == 1:
         self.x = (self.x - 1) % pyxel.width
     else:
         self.x = (self.x + 1) % pyxel.width
예제 #15
0
파일: graslay.py 프로젝트: Ontake44/graslay
 def doPause(self):
     if pyxel.btnp(pyxel.KEY_ESCAPE) or pyxel.btnp(pyxel.GAMEPAD_1_START):
         self.pauseMode = gcommon.PAUSE_NONE
         pygame.mixer.music.unpause()
     elif gcommon.checkUpP():
         self.pauseMenuPos = (self.pauseMenuPos - 1) % 4
         return
     elif gcommon.checkDownP():
         self.pauseMenuPos = (self.pauseMenuPos + 1) % 4
         return
     if self.mouseManager.visible:
         n = gcommon.checkMouseMenuPos(self.pauseMenuRects)
         if n != -1:
             self.pauseMenuPos = n
     if self.pauseCnt > 30:
         if self.pauseMenuPos == 0:
             # CONTINUE
             if gcommon.checkShotKeyRectP(
                     self.pauseMenuRects[self.pauseMenuPos]):
                 self.pauseMode = gcommon.PAUSE_NONE
                 pygame.mixer.music.unpause()
         elif self.pauseMenuPos == 1:
             # MOUSE OFF/ON
             n = -1
             if self.mouseManager.visible:
                 n = gcommon.checkMouseMenuPos(self.pauseMouseOnOffRects)
             if gcommon.checkRightP() or (gcommon.checkShotKeyP()
                                          and n == 1):
                 Settings.mouseEnabled = True
             elif gcommon.checkLeftP() or (gcommon.checkShotKeyP()
                                           and n == 0):
                 Settings.mouseEnabled = False
         elif self.pauseMenuPos == 2:
             if gcommon.checkShotKeyRectP(
                     self.pauseMenuRects[self.pauseMenuPos]):
                 # TITLE
                 gcommon.app.startTitle()
         elif self.pauseMenuPos == 3:
             if gcommon.checkShotKeyRectP(
                     self.pauseMenuRects[self.pauseMenuPos]):
                 # EXIT
                 pyxel.quit()
     self.pauseCnt += 1
예제 #16
0
def atualizar():
    """
    Atualiza o jogo. Roda a cada frame.
    """
    # Sai com Q ou ESC
    if pyxel.btnp(pyxel.KEY_Q):
        pyxel.quit()

    # Reinicia com R
    elif _.ativo and pyxel.btnp(pyxel.KEY_R):
        _.reiniciar()

    # Roda o jogo
    elif _.ativo:
        _.atualizar_jogo()

    # Ativa com espaço ou seta para cima
    elif pyxel.btnp(pyxel.KEY_SPACE) or pyxel.btnp(pyxel.KEY_UP):
        _.ativo = True
예제 #17
0
파일: main.py 프로젝트: runlucky/TsuboMan
    def update(self):
        if pyxel.btnp(pyxel.KEY_Q):
            pyxel.quit()

        if pyxel.btnp(pyxel.KEY_SPACE):
            self.vy = -5

        if pyxel.btn(pyxel.KEY_RIGHT):
            self.x += 1

        if pyxel.btn(pyxel.KEY_LEFT):
            self.x += -1


        self.y += self.vy
        self.vy += App.gravity
        self.vy = max(self.vy, -5)

        self.y = min(self.y, 100)
예제 #18
0
    def update(self):
        if pyxel.btnp(pyxel.KEY_Q):
            pyxel.quit()
        
        if pyxel.btnp(pyxel.KEY_R) and self.player.alive == False:
            self.player.alive = True
            self.enemy.hp = 50

        
        if pyxel.btnp(pyxel.MOUSE_LEFT_BUTTON) and self.player.alive:
            new_bullet = Bullet()
            new_bullet.x = pyxel.mouse_x
            new_bullet.y = pyxel.mouse_y
            new_bullet.size = 1
            self.Bullets.append(new_bullet)
            #print(len(self.Bullets))
        
        if pyxel.frame_count % random.randint(1,10) == random.randint(0,10):
            new_bullet = Bullet()
            new_bullet.init(x=self.enemy.x, y=self.enemy.y, vy=7, size=4, color=8)
            self.Bullets.append(new_bullet)

        
        self.player.update()
        self.enemy.update()
        for i, bullet in enumerate(self.Bullets):
            bullet.update()

            if bullet.isOutside():
                #print(bullet.isOutside())
                del self.Bullets[i]

            if isCollision(bullet, self.player):
                self.player.alive = False
            
            if isCollision(bullet, self.enemy):
                self.enemy.hurt()
                del self.Bullets[i]
                #self.Particles.append(Particle())
        
        for i, particle in enumerate(self.Particles):
            particle.update()
예제 #19
0
    def update(self):
        if randint(1, 100) in range(25):
            self.stars.append(
                Star(randint(int(self.x / 2) - 20,
                             int(self.x / 2) + 40),
                     randint(int(self.y / 2) - 40,
                             int(self.y / 2) + 20), 7))

        for star in self.stars:
            if not star.is_alive:
                self.stars.remove(star)
                continue

            if star.x < 10 or star.x > self.x - 10 or star.y < 10 or star.y > self.y - 10:
                star.is_alive = False
                star.color = 1
                continue

            if star.x > int(self.x / 2) and star.y > int(self.y / 2):
                if randint(1, 10) % 2 == 0:
                    star.x += 1
                else:
                    star.y += 1

            elif star.x > int(self.x / 2) and star.y < int(self.y / 2):
                if randint(1, 10) % 2 == 0:
                    star.x += 1
                else:
                    star.y -= 1
            elif star.x < int(self.x / 2) and star.y > int(self.y / 2):
                if randint(1, 10) % 2 == 0:
                    star.x -= 1
                else:
                    star.y += 1
            else:
                if randint(1, 10) % 2 == 0:
                    star.x -= 1
                else:
                    star.y -= 1

        if pyxel.btnp(pyxel.KEY_Q):
            pyxel.quit()
예제 #20
0
    def update(self):
        if pyxel.btnp(pyxel.KEY_Q):
            pyxel.quit()

        # ====== ctrl cat ======
        dx = pyxel.mouse_x - self.mcat.pos.x  # x軸方向の移動量(マウス座標 - cat座標)
        dy = pyxel.mouse_y - self.mcat.pos.y  # y・・・〃・・・
        if dx != 0:
            self.mcat.update(pyxel.mouse_x, pyxel.mouse_y, dx)
        elif dy != 0:
            self.mcat.update(pyxel.mouse_x, pyxel.mouse_y, self.mcat.vec)

        # ====== ctrl Ball ======
        if pyxel.btnp(pyxel.MOUSE_LEFT_BUTTON):
            new_ball = Ball()
            if self.mcat.vec > 0:
                new_ball.update(self.mcat.pos.x + CAT_W / 2 + 6,
                                self.mcat.pos.y + CAT_H / 2, self.mcat.vec,
                                new_ball.size, new_ball.color)
            else:
                new_ball.update(self.mcat.pos.x + CAT_W / 2 - 6,
                                self.mcat.pos.y + CAT_H / 2, self.mcat.vec,
                                new_ball.size, new_ball.color)
            self.Balls.append(new_ball)

        ball_count = len(self.Balls)
        for i in range(ball_count):
            if 0 < self.Balls[i].pos.x and self.Balls[i].pos.x < WINDOW_W:
                # Ball update
                if self.Balls[i].vec > 0:
                    self.Balls[i].update(
                        self.Balls[i].pos.x + self.Balls[i].speed,
                        self.Balls[i].pos.y, self.Balls[i].vec,
                        self.Balls[i].size, self.Balls[i].color)
                else:
                    self.Balls[i].update(
                        self.Balls[i].pos.x - self.Balls[i].speed,
                        self.Balls[i].pos.y, self.Balls[i].vec,
                        self.Balls[i].size, self.Balls[i].color)
            else:
                del self.Balls[i]
                break
예제 #21
0
    def update(self):
        if self.midi_device_flag:
            if self.midi_input is not None:
                if self.midi_input.poll():
                    self.midi_events = self.midi_input.read(10)
                    print("full midi_events:" + str(self.midi_events))
        else:
            if pyxel.btnp(pyxel.KEY_E):
                self.add_key(1, 1)
            if pyxel.btnp(pyxel.KEY_D):
                self.add_key(1, -1)
            if pyxel.btnp(pyxel.KEY_R):
                self.add_key(2, 1)
            if pyxel.btnp(pyxel.KEY_F):
                self.add_key(2, -1)
            if pyxel.btnp(pyxel.KEY_T):
                self.add_key(3, 1)
            if pyxel.btnp(pyxel.KEY_G):
                self.add_key(3, -1)
            if pyxel.btnp(pyxel.KEY_Y):
                self.add_key(4, 1)
            if pyxel.btnp(pyxel.KEY_H):
                self.add_key(4, -1)
            if pyxel.btnp(pyxel.KEY_U):
                self.add_key(5, 1)
            if pyxel.btnp(pyxel.KEY_J):
                self.add_key(5, -1)
            if pyxel.btnp(pyxel.KEY_I):
                self.add_key(6, 1)
            if pyxel.btnp(pyxel.KEY_K):
                self.add_key(6, -1)

            self.midi_events = [[[
                0, self.key_channel, self.key_value[self.key_channel], 0
            ], 0]]
            print("full midi_events:" + str(self.midi_events))

        if pyxel.btnp(pyxel.KEY_Q):
            if self.midi_device_flag:
                self.midi_input.close()
                pygame.midi.quit()
            pyxel.quit()
예제 #22
0
    def update(self):
        if pyxel.btn(pyxel.KEY_Q):
            pyxel.quit()

        if self.soundChange == True:
            self.play_music()

        self.mudaEstado()

        if self.stat == "MENU":
            self.status[0].update()
        elif self.stat == "PAUSA":
            self.status[1].update()
        elif self.stat == "JOGO":
            self.status[2].update()
        elif self.stat == "CREDITOS":
            self.status[3].update()
        elif self.stat == "GAMEOVER":
            self.status[4].update()
        self.status[4].setPontos(self.pontos)
    def update(self):
        if pyxel.btn(pyxel.KEY_Q):
            pyxel.quit()

        if self.state == "wait":
            if pyxel.btn(pyxel.KEY_Z):
                self.state = "fly"
            return

        if pyxel.btn(pyxel.KEY_Z) and self.player.v_velo >= 0:
            self.player.v_velo = -4.5

        self.player.update_player()
        if (pyxel.frame_count % 8 == 0):
            self.player.wings_pos = (self.player.wings_pos + 1) % 2

        is_game_over = self.check_collision()
        if is_game_over:
            self.reset()
        self.lvl.update_level()
예제 #24
0
 def update(self):
     if pyxel.btnp(pyxel.KEY_Q): pyxel.quit()
     if pyxel.btnp(pyxel.KEY_SPACE):
         if self.FLAG == 0 or self.FLAG == 3: self.FLAG = 1
         if self.FLAG == 2: self.trueReset(1)
     if self.FLAG == 1 and (pyxel.btnp(pyxel.KEY_Z) or pyxel.btnp(
             pyxel.KEY_X) or pyxel.btnp(pyxel.KEY_C)):
         if (pyxel.btnp(pyxel.KEY_Z) and self.color
                 == 8) or (pyxel.btnp(pyxel.KEY_X)
                           and self.color == 10) or (pyxel.btnp(pyxel.KEY_C)
                                                     and self.color == 12):
             self.calc()
         else:
             self.loselife()
         self.reset()
     if self.r >= self.r2:
         self.loselife()
         self.reset()
     if self.LIFE <= 0: self.FLAG = 2
     if self.TIME == 0: self.levelup()
예제 #25
0
def update():
    global x, y, barriles

    for i in range(10):
        if pyxel.frame_count == 60 * i:
            barriles.append("barril" + str(i))
            barriles[i] = BarrilesRodando()
    if pyxel.btnp(pyxel.KEY_SPACE):
        mario.saltar = True
    if pyxel.btnp(pyxel.KEY_Q):
        pyxel.quit()
    if pyxel.btnp(pyxel.KEY_R):
        return None
    mario.x, mario.y = mario.move(mario.x, mario.y, barriles)
    for i in range(len(barriles)):
        if len(barriles) == 0:
            pass
        else:
            barriles[i].x, barriles[i].y = barriles[i].moveBarril(
                barriles[i].x, barriles[i].y)
예제 #26
0
    def update(self):
        # If player presses Q on keyboard
        # program will exit
        if pyxel.btnp(pyxel.KEY_Q):
            pyxel.quit()

        rocks_count = len(self.rocks)
        
        if pyxel.btnp(pyxel.MOUSE_LEFT_BUTTON):
        	for i in range(rocks_count):
        		rock = self.rocks[i]

        # Counts backwards from 9 to 0
        for i in range(rocks_count - 1, -1, -1):
        	ri = self.rocks[i]
        	ri.update()
		
		myss = Spaceship()
        self.ship = Spaceship()  
		myss.drawSpaceship() 
예제 #27
0
    def update(self):
        # check win
        if self.runner == self.end:
            pyxel.play(0, [0, 1, 2], loop=False)
            self.restart()
            return

        if pyxel.btnp(pyxel.KEY_ESCAPE):
            pyxel.quit()
        elif pyxel.btnp(pyxel.KEY_G):
            self.restart()
            return
        elif pyxel.btnp(pyxel.KEY_RIGHT) or pyxel.btnp(pyxel.KEY_D):
            self.move_if_possible(RIGHT)
        elif pyxel.btnp(pyxel.KEY_LEFT) or pyxel.btnp(pyxel.KEY_A):
            self.move_if_possible(LEFT)
        elif pyxel.btnp(pyxel.KEY_UP) or pyxel.btnp(pyxel.KEY_W):
            self.move_if_possible(UP)
        elif pyxel.btnp(pyxel.KEY_DOWN) or pyxel.btnp(pyxel.KEY_S):
            self.move_if_possible(DOWN)
예제 #28
0
파일: main.py 프로젝트: stew3254/Rogue-Like
    def update(self):
        #Quit if 'q' is pressed
        if pyxel.btnp(pyxel.KEY_Q):
            pyxel.quit()

        #Move up one
        if pyxel.btnp(pyxel.KEY_W):
            self.tryMove(0, -1, 3)  # Up

        #Move down one
        if pyxel.btnp(pyxel.KEY_S):
            self.tryMove(0, 1, 4)  # Down

        #Move left one
        if pyxel.btnp(pyxel.KEY_A):
            self.tryMove(-1, 0, 1)  # Left

        #Move right one
        if pyxel.btnp(pyxel.KEY_D):
            self.tryMove(1, 0, 0)  # Right
예제 #29
0
    def update(self):
        if self.init_flug:
            self.start_move_img()
            self.init_flug=False
        
        self.img_border_1+=self.img_speed_1
        self.img_border_2+=self.img_speed_2
        self.img_border_3+=self.img_speed_3
        if self.img_border_1>=PIC_H:
            self.img_border_1-=PIC_H
        if self.img_border_2>=PIC_H:
            self.img_border_2-=PIC_H
        if self.img_border_3>=PIC_H:
            self.img_border_3-=PIC_H

        #1,2,3ボタンで画像を止める処理
        if pyxel.btnp(pyxel.KEY_1):
            if self.img_speed_1 != 0:
                self.img_speed_1 = 0
            else:
                self.img_speed_1=decide_speed()
        
        if pyxel.btnp(pyxel.KEY_2):
            if self.img_speed_2 != 0:
                self.img_speed_2 = 0
            else:
                self.img_speed_2=decide_speed()

        if pyxel.btnp(pyxel.KEY_3):
            if self.img_speed_3 != 0:
                self.img_speed_3 = 0
            else:
                self.img_speed_3=decide_speed()

        #spaceボタンで、再び動かす処理
        if pyxel.btnp(pyxel.KEY_SPACE):
            self.start_move_img()

        #アプリ終了操作
        if pyxel.btnp(pyxel.KEY_Q):
            pyxel.quit()
예제 #30
0
 def navigation(self, game, lives):
     ''' Main navigation function that changes game's state according to
         current game state and selected item. '''
     items = 3
     if game.state == 'start':
         if pyxel.btnp(pyxel.KEY_ENTER
                       ) and self.selected_item == 1 and lives >= 1:
             game.state = 'game'
         elif pyxel.btnp(pyxel.KEY_ENTER) and self.selected_item == 2:
             game.state = 'controls'
         elif pyxel.btnp(pyxel.KEY_ENTER) and self.selected_item == 3:
             pyxel.quit()
     elif game.state == 'controls':
         items = 2
         if pyxel.btnp(pyxel.KEY_ENTER
                       ) and self.selected_item == 1 and lives >= 1:
             game.state = 'game'
         elif pyxel.btnp(pyxel.KEY_ENTER) and self.selected_item == 2:
             pyxel.quit()
     elif game.state == 'pause':
         if pyxel.btnp(pyxel.KEY_ENTER
                       ) and self.selected_item == 1 and lives >= 1:
             game.state = 'game'
         elif pyxel.btnp(pyxel.KEY_ENTER) and self.selected_item == 2:
             game.reset()
         elif pyxel.btnp(pyxel.KEY_ENTER) and self.selected_item == 3:
             pyxel.quit()
     elif game.state == 'end':
         if pyxel.btnp(pyxel.KEY_ENTER) and self.selected_item == 1:
             game.reset()
         elif pyxel.btnp(pyxel.KEY_ENTER) and self.selected_item == 2:
             game.state = 'scores'
         elif pyxel.btnp(pyxel.KEY_ENTER) and self.selected_item == 3:
             pyxel.quit()
     elif game.state == 'scores':
         items = 2
         if pyxel.btnp(pyxel.KEY_ENTER) and self.selected_item == 1:
             game.reset()
         elif pyxel.btnp(pyxel.KEY_ENTER) and self.selected_item == 2:
             pyxel.quit()
     self.make_selected_item_green(items)