本文整理汇总了Python中myrmidon.Game类的典型用法代码示例。如果您正苦于以下问题:Python Game类的具体用法?Python Game怎么用?Python Game使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Game类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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)
示例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()
示例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 = ""
示例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")
示例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
示例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
示例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
示例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
示例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
示例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
示例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])
示例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)
示例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
示例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])
示例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)