当前位置: 首页>>代码示例>>Python>>正文


Python Game.keyboard_key_down方法代码示例

本文整理汇总了Python中myrmidon.Game.keyboard_key_down方法的典型用法代码示例。如果您正苦于以下问题:Python Game.keyboard_key_down方法的具体用法?Python Game.keyboard_key_down怎么用?Python Game.keyboard_key_down使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在myrmidon.Game的用法示例。


在下文中一共展示了Game.keyboard_key_down方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: execute

# 需要导入模块: from myrmidon import Game [as 别名]
# 或者: from myrmidon.Game import keyboard_key_down [as 别名]
 def execute(self, game):
     self.image = game.graphics['ship']
     self.x, self.y = 500.0, 300.0
     self.z = -512
     while True:
         if Game.keyboard_key_down(K_LEFT):
             self.x -= 10.0
         if Game.keyboard_key_down(K_RIGHT):
             self.x += 10.0
         if Game.keyboard_key_down(K_UP):
             self.y -= 10.0
         if Game.keyboard_key_down(K_DOWN):
             self.y += 10.0
         yield
开发者ID:arcticshores,项目名称:Myrmidon,代码行数:16,代码来源:complex_example.py

示例2: pattern_vortex

# 需要导入模块: from myrmidon import Game [as 别名]
# 或者: from myrmidon.Game import keyboard_key_down [as 别名]
 def pattern_vortex(self, x, y, type=0):
     _range = 0
     if Game.keyboard_key_down(K_SPACE):
         _range = 10
     if random.random() > 0.9:
         _range = 1
     for c in range(_range):
         Shot(self, x, y)
开发者ID:fangbei,项目名称:Myrmidon,代码行数:10,代码来源:cymunk_balls.py

示例3: execute

# 需要导入模块: from myrmidon import Game [as 别名]
# 或者: from myrmidon.Game import keyboard_key_down [as 别名]
 def execute(self):
     # We want this entity to check for the escape key every frame, so we use a loop.
     while True:
         # Check for the escape key being pressed.
         if Game.keyboard_key_down(K_ESCAPE):
             # We can safely use the typical Python system method for quitting.
             sys.exit()
         # Each tick we leave the entity at the yield statement and will return here
         # in the next tick. If we returned instead of yielded our Entity would be
         # considered finished and would be destroyed.
         yield
开发者ID:Fiona,项目名称:Myrmidon,代码行数:13,代码来源:01_simple_window.py

示例4: pattern_vortex

# 需要导入模块: from myrmidon import Game [as 别名]
# 或者: from myrmidon.Game import keyboard_key_down [as 别名]
 def pattern_vortex(self, x, y, type = 0):
     _range = 1
     amount = 10.0
     if Game.keyboard_key_down(K_SPACE):
         _range = 10
         amount = 5.0            
     for c in range(_range):
         if type:
             self.cur2 -= amount
         else:
             self.cur += amount           
         if type:
             if self.cur2 < -360.0:
                 self.cur2 = 0.0
         else:
             if self.cur > 360.0:
                 self.cur = 0.0                
         Shot(self, x, y, self.cur2 if type else self.cur)
开发者ID:arcticshores,项目名称:Myrmidon,代码行数:20,代码来源:complex_example.py

示例5: execute

# 需要导入模块: from myrmidon import Game [as 别名]
# 或者: from myrmidon.Game import keyboard_key_down [as 别名]
 def execute(self):
     self._load_media()
     self._create_tests(TestNormal, TestImage, TestRotation, TestScaling, TestFlipHoriz, TestFlipVert, TestFlipBoth,
                        TestAlpha, TestYellow, TestCyan, TestMagenta, TestZSort, TestPosition, TestBlend,
                        TestHideShow, TestPriority, TestImageSequence, TestDrawCentrePoint, TestRotateCentrePoint,
                        TestScaleCentrePoint, TestFlipCentrePoint, TestStopExecuting,
                        TestClip, TestColourAndAlpha, TestTextPosition, TestTextRotation,
                        TestTextScaling,
                        TestTextXFlip, TestTextYFlip,
                        TestTextXAndYFlip, TestTextAlpha, TestTextYellow, TestTextCyan, TestTextMagenta,
                        TestTextBlend, TestTextShowAndHide, TestTextCentrePoint, TestTextAlignment,
                        TestTextClip, TestTextShadow,
                        TestMousePos, TestMouseButton, TestMouseWheel
                        )
     while True:
         if Game.keyboard_key_down(K_ESCAPE):
             sys.exit()
         yield
开发者ID:Fiona,项目名称:Myrmidon,代码行数:20,代码来源:feature_test.py

示例6: execute

# 需要导入模块: from myrmidon import Game [as 别名]
# 或者: from myrmidon.Game import keyboard_key_down [as 别名]
    def execute(self):
        self.graphics = {
            "ship": Game.load_image(os.path.join("media", "ship.png")),
            "shot": Game.load_image(os.path.join("media", "shot.png")),
        }
        self.font = Game.load_font(size=50)
        # Ship(self)
        self.fps_text = Game.write_text(0.0, 0.0, font=self.font, text=0)
        self.entity_text = Game.write_text(0.0, 40.0, font=self.font, text=0)
        Game.write_text(
            512.0, 730.0, font=self.font, text="Hold space to produce more entities", alignment=ALIGN_CENTRE
        )
        # add bounds
        sx = Game.screen_resolution[0]
        sy = Game.screen_resolution[1]
        seg1 = Segment(space.static_body, Vec2d(0, 0), Vec2d(0, sy), 0)
        seg1.elasticity = 1.0
        seg1.friction = 1.0

        seg2 = Segment(space.static_body, Vec2d(0, sy), Vec2d(sx, sy), 0)
        seg2.elasticity = 1.0
        seg2.friction = 1.0

        seg3 = Segment(space.static_body, Vec2d(sx, sx), Vec2d(sx, 0), 0)
        seg3.elasticity = 1.0
        seg3.friction = 1.0

        # add everything into space
        space.add_static(seg1, seg2, seg3)
        while True:
            if Game.keyboard_key_down(K_ESCAPE):
                sys.exit()
            space.step(0.1)  # TODO - use actual time delta
            self.pattern_vortex(300.0, 300.0, 1)
            self.fps_text.text = "FPS " + str(Game.current_fps)
            self.entity_text.text = str(len(Game.entity_list)) + " entities"
            yield
开发者ID:fangbei,项目名称:Myrmidon,代码行数:39,代码来源:cymunk_balls.py


注:本文中的myrmidon.Game.keyboard_key_down方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。