当前位置: 首页>>代码示例>>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;未经允许,请勿转载。