當前位置: 首頁>>代碼示例>>Python>>正文


Python Stage.process_input方法代碼示例

本文整理匯總了Python中stage.Stage.process_input方法的典型用法代碼示例。如果您正苦於以下問題:Python Stage.process_input方法的具體用法?Python Stage.process_input怎麽用?Python Stage.process_input使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在stage.Stage的用法示例。


在下文中一共展示了Stage.process_input方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: main

# 需要導入模塊: from stage import Stage [as 別名]
# 或者: from stage.Stage import process_input [as 別名]

#.........這裏部分代碼省略.........
                    selected_swing.destroy_joint(child_bonus, grandchild_bonus)
                elif event.type == KEYDOWN and event.key == K_s and stage.running == True:
                    # SECRET WEAPONNNNN!!!!
                    for swing in stage.swings:
                        swing.destroy_joint(child_bonus, grandchild_bonus)
                elif event.type == KEYDOWN and event.key == K_r and stage.running == True:
                    # If there is no ball, respawn the ball
                    if selected_swing.ball == None:
                        selected_swing.respawn_ball(selected_swing.circle_mass, selected_swing.radius, 1, "red")
                    else:
                        # If there is a ball create a new child

                        # the masses of the segments and balls are determined by which tier the swing is
                        # Tier1 swing is the original swing and can have 3 children. Has 3 segments
                        # Tier2 swings are children of tier1 swings and can have 2 children. Masses are 1/3 of the tier1. Has 2 segments
                        # Tier3 swings are children of tier2 swings and can't have children. Masses are 1/2 of tier2. Has 1 segment

                        new_tier = selected_swing.tier + 1

                        if new_tier == 2:
                            new_swing = Polyswing(
                                stage,
                                200,
                                550,
                                1,
                                10,
                                0.33 * selected_swing.section_mass,
                                500,
                                1,
                                0.33 * selected_swing.circle_mass,
                                15,
                                1,
                                2,
                                selected_swing,
                                2,
                                new_tier,
                                "red",
                            )
                        else:  # its tier 3
                            new_swing = Polyswing(
                                stage,
                                200,
                                550,
                                1,
                                10,
                                0.5 * selected_swing.section_mass,
                                500,
                                1,
                                0.5 * selected_swing.circle_mass,
                                10,
                                1,
                                1,
                                selected_swing,
                                0,
                                new_tier,
                                "red",
                            )
                elif event.type == KEYDOWN and event.key == K_t:
                    # toggle through the swings
                    try:
                        selected_swing.selected = False
                    except UnboundLocalError:
                        print "no selected swing yet"
                    try:
                        selected_swing = stage.swings[swing_index]
                    except IndexError:
                        print "the swing that was selected isn't there anymore"
                    selected_swing.selected = True
                    if swing_index + 1 > len(stage.swings) - 1:
                        swing_index = 0
                    else:
                        swing_index = swing_index + 1
                elif event.type == KEYDOWN and event.key == K_SPACE:
                    barrel_cannon1.shoot(1200, bullet_color)
                    # new_ball = Bullet(stage, f275, 36 ,2.0,10,0.5,bullet_color)
            except UnboundLocalError:
                print "im too lazy to fix this problem right now"  # cant release or make the ball for poly_swing2 unless it exists

        if stage.running == True:
            barrel_cannon1.move()
            spinner1.move()
            spinner2.move()

        screen.fill(THECOLORS[bg_color])
        stage.process_input()

        stage.draw_stats()

        # create new threads for these calls?
        if stage.running == True:  # two of these need to be done because step must be infront of draw
            stage.bullet_reload(pg_time)
            stage.space.step(1 / 60.0)
        else:
            stage.set_end_time()

        stage.draw_self()

        pygame.display.flip()
        clock.tick(60)
        pygame.display.set_caption("FPS: " + str(clock.get_fps()))
開發者ID:nchokas,項目名稱:PysProblem,代碼行數:104,代碼來源:pymunk_test2.py


注:本文中的stage.Stage.process_input方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。