Exemplo n.º 1
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.º 2
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.º 3
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.º 4
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.º 5
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.º 6
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.º 7
0
 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
Exemplo n.º 8
0
 def test_doesnt_return_linear_value_for_two_thirds(self):
     self.assertNotAlmostEquals(8.333, Game.slerp(5.0, 10.0, 1.0 / 3 * 2), 3)
Exemplo n.º 9
0
 def test_doesnt_return_linear_value_for_one_third(self):
     self.assertNotAlmostEquals(6.667, Game.slerp(5.0, 10.0, 1.0 / 3), 3)
Exemplo n.º 10
0
 def test_returns_correct_mid_value(self):
     self.assertEquals(7.5, Game.slerp(5.0, 10.0, 0.5))
Exemplo n.º 11
0
 def test_returns_correct_end_value(self):
     self.assertEquals(10.0, Game.slerp(5.0, 10.0, 1.0))
Exemplo n.º 12
0
 def test_returns_correct_start_value(self):
     self.assertEquals(5.0, Game.slerp(5.0, 10.0, 0.0))