コード例 #1
0
ファイル: __main__.py プロジェクト: Fiona/Diagonex
 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
コード例 #2
0
ファイル: __main__.py プロジェクト: Fiona/Diagonex
 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
コード例 #3
0
ファイル: __main__.py プロジェクト: Fiona/Diagonex
 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
コード例 #4
0
ファイル: __main__.py プロジェクト: Fiona/Diagonex
 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()
コード例 #5
0
ファイル: test_Game.py プロジェクト: jvlomax/Myrmidon
 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)
コード例 #6
0
ファイル: __main__.py プロジェクト: Fiona/Diagonex
 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
コード例 #7
0
ファイル: __main__.py プロジェクト: Fiona/Diagonex
 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")
コード例 #8
0
ファイル: __main__.py プロジェクト: Fiona/Diagonex
 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
コード例 #9
0
ファイル: __main__.py プロジェクト: Fiona/Diagonex
 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")
コード例 #10
0
ファイル: __main__.py プロジェクト: Fiona/Diagonex
 def execute(self, window, player_num, respawn = False):
     self.init()
     self.window = window
     self.player_num = player_num
     self.joy = self.window.input.joys[self.player_num]
     self.health_display = None
     self.respawning = False
     self.x = Game.screen_resolution[0] / 2 + self.start_offsets[player_num][0]
     self.y = Game.screen_resolution[1] / 2 + self.start_offsets[player_num][1]
     self.alpha = 0.0
     if respawn:
         self.respawning = True
     else:
         for i in range(60):
             yield
     self.image = self.window.media.gfx['player']
     self.colour = self.colours[player_num]
     self.health = 4
     self.charged_claim = False
     self.charged_shot = False
     self.shot_dir = 0
     self.bump_cooldown = 0
     self.shot_cooldown = 0
     self.z -5
     for i in range(30):
         yield
     self.window.media.sfx['respawn'].sound.play()
     spawn_point = self.window.particle_emitters['spawn_' + str(self.player_num)].add_point((self.x, self.y), death_timer = 15)
     for frame, total in Game.timer_ticks(15):
         self.alpha = 0.0 if self.alpha else 1.0
         yield
         yield
     self.alpha = 1.0
     self.health_display = HealthDisplay(self.window)
     self.respawning = False
     while True:
         self.handle_movement()
         self.handle_shooting()
         self.grid_pos = self.window.screen_to_grid_pos(self.x, self.y)
         if self.window.grid is None:
             return
         t = self.window.grid.get_tile(*self.grid_pos)
         if not t is None:
             t.activate()
             #if t.claimed_by == self.player_num:
             #    self.velocity *= 0.9
         self.handle_claiming(t)
         self.handle_player_collision()
         self.handle_bumping(t)
         self.cap_speed()
         self.anim()
         yield
コード例 #11
0
ファイル: __main__.py プロジェクト: Fiona/Diagonex
 def execute(self, window):
     self.window = window
     self.time = self.window.timer_length
     self.timer_display = None
     for frame, total in Game.timer_ticks(60):
         yield        
     while True:
         for frame, total in Game.timer_ticks(30):
             yield
         self.time -= 1
         if self.timer_display:
             self.timer_display.switch_state("state_pulse", self.time)
         else:
             if self.time <= self.window.timer_last_section:
                 self.timer_display = TimerDisplay(self.window)
                 self.window.media.sfx['timewarning'].sound.play(loops = -1)
         if not self.time:
             break
     self.window.end_timer()
     self.timer_display.switch_state("state_die")
     while self.timer_display.is_alive():
         yield
コード例 #12
0
ファイル: __main__.py プロジェクト: Fiona/Diagonex
 def execute(self, window, player_marker, score):
     self.window = window
     self.player_marker = player_marker
     self.score = score
     self.x = self.player_marker.x
     self.y = self.player_marker.y + 75
     self.text = Game.write_text(self.x, self.y, text = self.score, font = self.window.media.fnt['final_score'], alignment = ALIGN_CENTRE)
     self.text.z = -10
     self.text.colour = (.2, .2, .2)
     scale_to = .5
     if self.is_top_score():
         self.text.colour = (1.0, 1.0, 1.0)
         scale_to = 1.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(10):
         self.text.alpha = Game.slerp(0.0, 1.0, frame / total)
         self.text.scale = Game.slerp(0.5, 1.3, frame / total)
         yield
     for frame, total in Game.timer_ticks(40):
         self.text.scale = Game.slerp(1.3, scale_to, frame / total)
         yield
     while True:
         self.text.alpha = self.player_marker.alpha
         yield
コード例 #13
0
ファイル: test_Game.py プロジェクト: jvlomax/Myrmidon
 def test_iterator_returns_iterations_made_and_target_iterations(self):
     val = Game.timer_ticks(3)
     self.assertEquals((1, 3), next(val))
     self.assertEquals((2, 3), next(val))
     self.assertEquals((3, 3), next(val))
コード例 #14
0
ファイル: test_Game.py プロジェクト: jvlomax/Myrmidon
 def test_returns_iterable(self):
     val = Game.timer_ticks(3)
     next(val)
コード例 #15
0
ファイル: __main__.py プロジェクト: Fiona/Diagonex
 def state_die(self):
     for frame, total in Game.timer_ticks(30):
         self.text.alpha = Game.lerp(1.0, 0.0, frame / total)
         yield
     self.text.destroy()