• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python myrmidon.Game类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: __init__

    def __init__(self):
        Game.load_engine_plugins(self, "gfx")
        
        self.max_textures = glGetInteger(GL_MAX_TEXTURE_IMAGE_UNITS)

        #
        self.init_shaders()
        
        # Set up screen and reset viewport
        glClearColor(*self.clear_colour)
        glClear(GL_COLOR_BUFFER_BIT)
        glViewport(0, 0, Game.screen_resolution[0], Game.screen_resolution[1])

        glMatrixMode(GL_MODELVIEW)	

        # Blending setup
        glEnable(GL_BLEND)
        glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)

        glEnable(GL_CULL_FACE)        
        
        # Get uniform pointer list
        self.uniforms = {}
        for uni in ["screen_resolution"] + ["textures[%d]" % x for x in range(self.max_textures)]:
            self.uniforms[uni] = glGetUniformLocation(self.shader_program, uni)

        # Initialise all vertex attributes
        self.attributes = {}
        for att in ("position","color","texcoord"):
            self.attributes[att] = glGetAttribLocation(self.shader_program, att)	
            
        # Create global VBO
        self.vertex_buffer = VBO(array([]), target=GL_ARRAY_BUFFER, usage=GL_STREAM_DRAW)
开发者ID:Fiona,项目名称:Myrmidon,代码行数:33,代码来源:engine.py


示例2: execute

 def execute(self, window):
     self.window = window
     self.text = Game.write_text(Game.screen_resolution[0] / 2, Game.screen_resolution[1] / 2, text = "d  i  a  g  o  n  e  x", font = self.window.media.fnt['title_name'], alignment = ALIGN_CENTRE)
     self.text.z = -10
     self.text.alpha = 0.0
     self.window.media.mus['title'].sound.play(loops = -1)
     for frame, total in Game.timer_ticks(30):
         yield
     for frame, total in Game.timer_ticks(30):
         self.text.alpha = Game.lerp(0.0, 1.0, frame / total)
         yield
     self.text2 = Game.write_text(Game.screen_resolution[0] / 2, (Game.screen_resolution[1] / 2) + 200, text = "press start", font = self.window.media.fnt['title_press_start'], alignment = ALIGN_CENTRE)
     self.text2.z = -10
     self.text2.alpha = 0.0
     for frame, total in Game.timer_ticks(30):
         self.text2.alpha = Game.slerp(0.0, 1.0, frame / total)
         yield
     while True:
         if self.window.pressed_start():
             self.window.media.sfx['pressstart'].sound.play()
             break
         yield
     for frame, total in Game.timer_ticks(20):
         self.text.alpha = Game.slerp(1.0, 0.0, frame / total)
         self.text2.alpha = Game.slerp(1.0, 0.0, frame / total)
         yield
     self.window.change_state(Window.STATE_SELECT_PLAYERS)
     self.destroy()
开发者ID:Fiona,项目名称:Diagonex,代码行数:28,代码来源:__main__.py


示例3: _update

 def _update(self):
     if Game.mouse().wheel_up:
         self.text.text = "UP"
     elif Game.mouse().wheel_down:
         self.text.text = "DOWN"
     else:
         self.text.text = ""
开发者ID:Fiona,项目名称:Myrmidon,代码行数:7,代码来源:feature_test.py


示例4: state_pulse

 def state_pulse(self, time):
     self.time = time
     self.text.text = str(time)
     for frame, total in Game.timer_ticks(30):
         self.text.scale = Game.lerp(1.2, 1.0, frame / total)
         yield
     yield self.switch_state("state_normal")
开发者ID:Fiona,项目名称:Diagonex,代码行数:7,代码来源:__main__.py


示例5: state_grabbed

 def state_grabbed(self):
     while True:
         self.x = Game.mouse().x#rel[0]
         self.y = Game.mouse().y#rel[1]
         self.check_snapping()
         if Game.mouse().left_up:
             self.app.hover_block = None
             self.app.grab_block = None
             yield self.switch_state("state_normal")            
         yield
开发者ID:piratebunny,项目名称:patch,代码行数:10,代码来源:main.py


示例6: state_hover

 def state_hover(self):
     while True:
         self.alpha = 0.9
         if not self.collide_with(Game.mouse()).result:
             self.app.hover_block = None
             yield self.switch_state("state_normal")
         if Game.mouse().left_down:
             self.app.grab_block = self
             yield self.switch_state("state_grabbed")
         yield
开发者ID:piratebunny,项目名称:patch,代码行数:10,代码来源:main.py


示例7: _setup

 def _setup(self):
     TextTest._setup(self)
     self.text.destroy()
     t1 = Game.write_text(self.x-10, self.y-10, font=Application.F_BIG, text="test", alignment=ALIGN_CENTRE)
     t1.colour = (0.75, 0.75, 0.75)
     t1.blend = True
     t2 = Game.write_text(self.x+00, self.y+00, font=Application.F_BIG, text="test", alignment=ALIGN_CENTRE)
     t2.colour = (0.75, 0.75, 0.75)
     t2.blend = True
     t3 = Game.write_text(self.x+10, self.y+10, font=Application.F_BIG, text="test", alignment=ALIGN_CENTRE)
     t3.colour = (0.75, 0.75, 0.75)
     t3.blend = True
开发者ID:Fiona,项目名称:Myrmidon,代码行数:12,代码来源:feature_test.py


示例8: execute

 def execute(self):
     self.images = {
         'blue_block' : Game.load_image("blue_block.png"),
         'red_block' : Game.load_image("red_block.png"),
         }
     self.blocks = [
         Block(self, 100, 100, 'red'),
         Block(self, 100, 300, 'blue')
         ]
     while True:
         if Game.keyboard_key_released(K_ESCAPE):
             sys.exit()
         yield
开发者ID:piratebunny,项目名称:patch,代码行数:13,代码来源:main.py


示例9: inputhook_myrmidon_pygame

def inputhook_myrmidon_pygame():
    """The pygame eventloop hook."""
    engine_window = Game.engine['window']
    if not engine_window:
        return 0

    for x in Game._module_list:
        x._module_setup(cls)

    if Game.started:
        Game.app_loop_callback(0)

    return 0
开发者ID:Fiona,项目名称:Myrmidon,代码行数:13,代码来源:ipython_hook.py


示例10: execute

 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,代码行数:14,代码来源:complex_example.py


示例11: test_lowering_val_lowers_appropriate_rgb_channels_uniformally

 def test_lowering_val_lowers_appropriate_rgb_channels_uniformally(self, engines):
     engines['gfx'].rgb_to_colour = self._stub_colour
     result = Game.hsva_to_colour(60, 1.0, 0.25, 255)
     self.assertAlmostEqual(0.25, result[0], 2)
     self.assertAlmostEqual(0.25, result[1], 2)
     self.assertAlmostEqual(0.0,  result[2], 2)
     self.assertEqual(1.0, result[3])
开发者ID:chozabu,项目名称:Myrmidon,代码行数:7,代码来源:test_Game.py


示例12: produce_particles

    def produce_particles(self):
        if not self.particle_system._executing:
            return
        remove = []
        for p in self.points:
            p.life += 1
            if not p.death_timer == None and p.life == p.death_timer:
                remove.append(p)
                continue
            if p.stop_producing_particles:
                continue
            if not p.wait_rate == None:
                if p.wait < p.wait_rate:
                    p.wait += 1
                    continue
                p.wait = 0
            for i in range(self.rate if p.rate == None else p.rate):
                angle = random.randrange(p.angle_from, p.angle_to)
                pos = p.pos
                if self.shift_pos > 0:
                    pos = Game.move_forward(pos, random.randrange(0, self.shift_pos), angle)
                self.particles.add(Particle(pos, 0.0, angle, 0))

        for p in remove:
            self.points.remove(p)
开发者ID:Fiona,项目名称:Diagonex,代码行数:25,代码来源:particles.py


示例13: execute

 def execute(self):
     self.media = Media()
     self.map = Map(self, os.path.join('maps', Consts.default_map_file))
     while True:
         if Game.keyboard_key_released(K_q):
             self.quit_game()
         yield
开发者ID:Fiona,项目名称:spacefarm,代码行数:7,代码来源:Window.py


示例14: test_lowering_saturation_increases_appropriate_rgb_channels_uniformally

 def test_lowering_saturation_increases_appropriate_rgb_channels_uniformally(self, engines):
     engines["gfx"].rgb_to_colour = self._stub_colour
     result = Game.hsva_to_colour(60, 0.25, 1.0, 255)
     self.assertAlmostEqual(1.0, result[0], 2)
     self.assertAlmostEqual(1.0, result[1], 2)
     self.assertAlmostEqual(0.75, result[2], 2)
     self.assertEqual(1.0, result[3])
开发者ID:jvlomax,项目名称:Myrmidon,代码行数:7,代码来源:test_Game.py


示例15: test_iterator_throws_stop_after_given_number_of_iterations

 def test_iterator_throws_stop_after_given_number_of_iterations(self):
     val = Game.timer_ticks(3)
     next(val)
     next(val)
     next(val)
     with self.assertRaises(StopIteration):
         next(val)
开发者ID:jvlomax,项目名称:Myrmidon,代码行数:7,代码来源:test_Game.py


示例16: state_normal

 def state_normal(self):
     while True:
         self.alpha = 1.0
         if self.collide_with(Game.mouse()).result:
             if not self.app.hover_block:
                 self.app.hover_block = self
                 yield self.switch_state("state_hover")
         yield            
开发者ID:piratebunny,项目名称:patch,代码行数:8,代码来源:main.py


示例17: pattern_vortex

 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,代码行数:8,代码来源:cymunk_balls.py


示例18: handle_player_collision

 def handle_player_collision(self):
     p = self.collide_with_player(box_size = 64)
     if not p is None:
         angle_between = Game.angle_between_points((self.x, self.y), (p.x, p.y))
         self.window.do_cam_shake(5)
         p.bump(Vector2d(dir = math.radians(float(angle_between)), mag = 15.0))
         self.bump(Vector2d(dir = math.radians(float(angle_between)), mag = -15.0))
         random.choice(self.window.media.sfx['hurt']).sound.play()
         self.window.media.sfx['bounce'].sound.play()
开发者ID:Fiona,项目名称:Diagonex,代码行数:9,代码来源:__main__.py


示例19: execute

 def execute(self, position):
     self.x, self.y = position
     self.image = Application.G_WORD
     self.desc_obj = Game.write_text(self.x, self.y+self.TEXT_OFFSET, Application.F_MAIN, ALIGN_TOP,
                                     self.description)
     self.desc_obj.colour = (1, 1, 1)
     self._setup()
     while True:
         self._update()
         yield
开发者ID:Fiona,项目名称:Myrmidon,代码行数:10,代码来源:feature_test.py


示例20: execute

 def execute(self, window):
     self.window = window
     self.image = self.window.test_image
     self.x, self.y = 0, 0
     #self.colour = (1.0, 0.0, 0.0)
     #self.alpha = 0.5
     while True:            
         self.x, self.y = Game.mouse().pos
         #self.rotation -= 1
         #self.scale += 0.005
         yield
开发者ID:arcticshores,项目名称:Myrmidon,代码行数:11,代码来源:kivy_test.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python osc.sendMsg函数代码示例发布时间:2022-05-27
下一篇:
Python regex_expose.findall函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap