Exemplo n.º 1
0
 def execute(self, window, player_num):
     self.window = window
     self.player_num = player_num
     self.z = -10
     self.image = self.window.media.gfx['player']
     self.x = Game.screen_resolution[0] / 2 + self.start_offsets[self.player_num][0]
     self.y = Game.screen_resolution[1] / 2 + self.start_offsets[self.player_num][1]
     self.anim_time = 0
     self.alpha = 0.0
     self.colour = Player.colours[self.player_num]
     self.selected = False
     self.do_die = False
     while True:
         if not self.selected:
             for k,v in enumerate(self.window.input.joys[self.player_num].released_buttons):
                 if k == 7:
                     continue
                 if v or (player_num == 2 and Game.keyboard_key_released(K_SPACE)):
                     self.window.media.sfx['playerregister'].sound.play()
                     for frame, total in Game.timer_ticks(15):
                         self.alpha = Game.slerp(0.0, 0.95, frame / total)
                         self.anim()
                         yield
                     self.selected = True
                     self.window.selected_players.append(self.player_num)
         else:
             if self.do_die:
                 for frame, total in Game.timer_ticks(10):
                     self.alpha = Game.slerp(0.0, 0.95, frame / total)
                     self.anim()
                     yield
                 self.destroy()
         self.anim()
         yield
Exemplo n.º 2
0
    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)
Exemplo n.º 3
0
 def execute(self, window, player_num):
     self.window = window
     self.player_num = player_num
     self.z = -10
     self.image = self.window.media.gfx['player']
     self.x = Game.screen_resolution[0] / 2 + self.start_offsets[self.player_num][0]
     self.y = Game.screen_resolution[1] / 2 + self.start_offsets[self.player_num][1] - 50
     self.anim_time = 0
     self.alpha = 0.0
     self.alpha_to = .10
     self.blend = True
     if self.player_num in self.window.player_scores:
         self.colour = Player.colours[self.player_num]
         self.alpha_to = .95
     for frame, total in Game.timer_ticks(60):
         self.alpha = Game.slerp(0.0, self.alpha_to, frame / total)
         self.anim()
         yield
     self.score_text = None
     if self.player_num in self.window.player_scores:
         self.score_text = ScoreBoardScore(self.window, self, self.window.player_scores[self.player_num])
     self.parent.shown_score = True
     while True:
         self.anim()
         yield
Exemplo n.º 4
0
 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")
Exemplo n.º 5
0
 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()
Exemplo n.º 6
0
 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 = ""
Exemplo n.º 7
0
 def execute(self, window, grid_pos):
     self.window = window
     self.grid_pos = grid_pos
     self.image = self.window.media.gfx['grid']
     self.x, self.y = self.window.grid_pos_to_screen(*self.grid_pos)
     if self.grid_pos[0] % 2:
         self.y -= self.tile_height / 2
     self.colour = (.5, .5, 1.0)
     self.z = self.window.grid.z
     self.claimed_seq = random.randint(2, 5)
     self.claimed = False
     self.claimed_by = -1
     self.image_seq = 1
     self.image_seq_overlay = None
     self.do_die = False
     while True:
         while not self.on:
             if self.on == 1:
                 while self.alpha < 1.0:
                     self.alpha += .25
                     yield
                 self.on = 2
             yield
         self.alpha_to = .6
         if self.alpha > self.alpha_to:
             self.alpha -= .05
         if self.alpha < self.alpha_to:
             self.alpha += .05
         if self.do_die:
             for frame, total in Game.timer_ticks(10):
                 self.scale = Game.slerp(1.0, 0.0, frame / total)
                 yield
             self.destroy()
         yield
Exemplo n.º 8
0
 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
Exemplo n.º 9
0
 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
Exemplo n.º 10
0
 def execute(self, window):
     self.window = window
     self.window.selected_players = []
     self.objs = []
     for x in range(Window.max_players):
         if x < len(self.window.input.joys):
             self.objs.append(PlayerSelectPlayer(self.window, x))
     self.text = Game.write_text(Game.screen_resolution[0] / 2, (Game.screen_resolution[1] / 2) - 200, text = "press buttons to register", font = self.window.media.fnt['player_select_press_buttons'], alignment = ALIGN_CENTRE)
     self.text.z = -10
     self.text.alpha = 0.0
     for frame, total in Game.timer_ticks(15):
         self.text.alpha = Game.slerp(0.0, 1.0, frame / total)
         yield
     self.text2 = None
     while True:
         if len(self.window.selected_players) > 1:
             if self.text2 is None:
                 self.text2 = Game.write_text(Game.screen_resolution[0] / 2, (Game.screen_resolution[1] / 2) + 200, text = "press start", font = self.window.media.fnt['player_select_press_buttons'], alignment = ALIGN_CENTRE)
                 self.text2.z = -10
                 self.text2.alpha = 0.0
                 for frame, total in Game.timer_ticks(10):
                     self.text2.alpha = Game.slerp(0.0, 1.0, frame / total)
                     yield
             if self.window.pressed_start():
                 self.window.media.sfx['pressstart'].sound.play()
                 self.window.media.mus['title'].sound.fadeout(2000)
                 for x in self.objs:
                     x.die()
                 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_PLAYING)
                 self.destroy()
         yield
Exemplo n.º 11
0
 def execute(self, window):
     self.window = window
     self.shown_score = False
     self.press_start_text = None
     self.objs = []
     for frame, total in Game.timer_ticks(20):
         yield
     for x in range(Window.max_players):
         self.objs.append(ScoreBoardPlayer(self.window, x))
     for frame, total in Game.timer_ticks(50):
         yield
     while True:
         if self.shown_score:
             if self.press_start_text is None:
                 self.press_start_text = Game.write_text((Game.screen_resolution[0] / 2), Game.screen_resolution[1] - 100, font = self.window.media.fnt['score_press_start'], text = "- press start -", alignment = ALIGN_CENTRE)
                 for frame, total in Game.timer_ticks(30):
                     self.press_start_text.alpha = Game.slerp(0.0, 1.0, frame / total)
                     yield
             for joy in self.window.input.joys:
                 if joy.released_buttons[7]:
                     self.window.media.sfx['pressstart'].sound.play()
                     for frame, total in Game.timer_ticks(20):
                         self.press_start_text.alpha = Game.slerp(1.0, 0.0, frame / total)
                         yield
                     for frame, total in Game.timer_ticks(10):
                         for x in self.objs:
                             x.alpha = Game.slerp(x.alpha_to, 0.0, frame / total)
                         yield
                     self.destroy()
                     self.window.change_state(Window.STATE_TITLE)
         yield
Exemplo n.º 12
0
 def execute(self, window):
     self.window = window
     self.time = self.parent.time
     self.text = Game.write_text((Game.screen_resolution[0] / 2), 30, font = self.window.media.fnt['timer'], text = str(self.time), alignment = ALIGN_CENTRE)
     self.text.z = -20
     self.text.alpha = 0.0
     self.text.scale_point = (self.text.text_image_size[0] / 2, self.text.text_image_size[1] / 2)
     for frame, total in Game.timer_ticks(30):
         self.text.alpha = Game.lerp(0.0, 1.0, frame / total)
         yield
     yield self.switch_state("state_normal")
Exemplo n.º 13
0
 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
Exemplo n.º 14
0
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
Exemplo n.º 15
0
 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
Exemplo n.º 16
0
 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
Exemplo n.º 17
0
 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
Exemplo n.º 18
0
 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])
Exemplo n.º 19
0
 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
Exemplo n.º 20
0
 def execute(self, window, player_num, rotation):
     self.window = window
     self.player_num = player_num
     self.rotation = rotation
     self.x, self.y = self.parent.x, self.parent.y
     self.z = -2
     self.colour = self.parent.colour
     self.blend = True
     self.image = self.window.media.gfx['shot']
     while True:
         self.move_forward(18.0)
         self.grid_pos = self.window.screen_to_grid_pos(self.x, self.y)
         t = self.window.grid.get_tile(*self.grid_pos)
         if t is None:
             self.alpha -= .2
             if self.alpha < 0.0:
                 self.destroy()
         else:
             p = self.collide_with_player()
             if not p is None:
                 angle_between = Game.angle_between_points((self.x, self.y), (p.x, p.y))
                 p.bump(Vector2d(dir = math.radians(float(angle_between)), mag = 10.0))
                 self.window.do_cam_shake(10)
                 p.hit_by_shot()
                 self.window.particle_emitters['shot_' + str(p.player_num)].add_point((self.x, self.y), death_timer = 5)
                 while self.scale > 0:
                     self.scale -= .2
                     yield
                 self.destroy()
         self.move_forward(10.0)
         yield
Exemplo n.º 21
0
    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)
Exemplo n.º 22
0
 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)
Exemplo n.º 23
0
 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
Exemplo n.º 24
0
 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])
Exemplo n.º 25
0
 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            
Exemplo n.º 26
0
 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)
Exemplo n.º 27
0
 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()
Exemplo n.º 28
0
 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
Exemplo n.º 29
0
 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
Exemplo n.º 30
0
 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
Exemplo n.º 31
0
 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
Exemplo n.º 32
0
 def execute(self, window):
     self.window = window
     self.text = Game.write_text(
         Game.screen_resolution[0] / 2, 100, self.window.F_BENCHMARK_NAME, ALIGN_CENTER, self.name
     )
     self.average_execution_time = 0.0
     self.average_render_time = 0.0
     self.test_entities = []
     for entity_num in range(self.num_test_entities):
         self.create_single_test_entity()
     self.switch_state("run_test")
Exemplo n.º 33
0
 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
Exemplo n.º 34
0
 def execute(self, game, x, y, angle_to = 0.0):
     self.image = game.graphics['shot']
     self.x = x
     self.y = y
     self.ox = x+random.random()
     self.oy = y+random.random()
     self.z = 512
     self.collision_circle_radius = self.image.width/2
     self.age=0
     while True:
         self.age+=1
         xv = self.x-self.ox
         yv = self.y-self.oy
         self.ox = self.x
         self.oy = self.y
         self.x+=xv*.98
         self.y+=yv*.98+.1
         shots = Game.get_entities(Shot)
         slen = len(shots)
         for ai in range(slen-1):
             a=shots[ai]
             for bi in range(ai+1, slen):
                 b=shots[bi]
                 dvx = a.x-b.x
                 dvy = a.y-b.y
                 dist_sqr = dvx**2+dvy**2
                 rads = a.collision_circle_radius+b.collision_circle_radius
                 #if Game.collision_circle_to_circle(a,b):
                 if dist_sqr < rads**2:
                     td = math.sqrt(dist_sqr)
                     if td==0:td=0.0001
                     nx=dvx/td
                     ny=dvy/td
                     diffd = td-rads
                     fx = nx*diffd
                     fy = ny*diffd
                     a.x -= fx*.5
                     a.y -= fy*.5
                     b.x += fx*.5
                     b.y += fy*.5
                     #b.x -= fx
                     #b.y -= fy
         #if self.x < 0 or self.x > Game.screen_resolution[0]-0 or self.y < 0 or self.y > Game.screen_resolution[1]:
         if self.y > Game.screen_resolution[1]*.7:
             self.y=Game.screen_resolution[1]*.7
         if self.x > Game.screen_resolution[0]*.4:
             self.x=Game.screen_resolution[0]*.4
         if self.x < 20:
             self.x=20
         if self.age>600:
             self.destroy()
         yield
Exemplo n.º 35
0
    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)
Exemplo n.º 36
0
 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)
Exemplo n.º 37
0
 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)
     while True:
         if Game.keyboard_key_down(K_ESCAPE):
             sys.exit()
         self.pattern_vortex(300.0, 300.0, 1)
         self.pattern_vortex(700.0, 300.0)
         self.fps_text.text = "FPS " + str(Game.fps)
         self.entity_text.text = str(len(Game.entity_list)) + " entities"
         yield
Exemplo n.º 38
0
 def __init__(self):
     self.gfx['tiles_ground'] = Game.load_image(
         os.path.join("assets", "tiles", "ground.png"))
     self.gfx['tiles_objects'] = Game.load_image(
         os.path.join("assets", "tiles", "objects.png"))
Exemplo n.º 39
0
from myrmidon.consts import *


class Test_entity(Entity):
    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


class Window(Entity):
    def execute(self):
        self.test_image = Game.load_image(os.path.join("media", "ship.png"))
        Test_entity(self)
        while True:
            yield


# Start game
Game.screen_resolution = (1024, 768)
Game.full_screen = False
Game.define_engine(*(["kivy"] * 4))
Window()
Exemplo n.º 40
0
 def execute(self):
     self.test_image = Game.load_image(os.path.join("media", "ship.png"))
     Test_entity(self)
     while True:
         yield