def explosions(screen: Screen) -> List[Explosion]: effects = [] x_regions = [ (0, screen.width), (0, screen.width // 3), (screen.width // 3 * 2, screen.width), ] y_regions = [ (0, screen.height), (screen.height // 2, screen.height), ] for _ in range(20): x = randint(*choice(x_regions)) y = randint(*choice(y_regions)) effects.append( Explosion( screen, x, y, randint(20, 30), start_frame=randint(0, 250), ) ) return effects
def _explosions(screen): for _ in range(20): yield Explosion( screen, randint(int(screen.width * 0.2), int(screen.width - (screen.width * 0.2))), randint(int(screen.height * 0.2), int(screen.height - (screen.height * 0.2))), randint(20, 30), start_frame=randint(0, 250), )
def test_explosion(self): """ Test that Explosion works as expected. """ screen = MagicMock(spec=Screen, colours=8) canvas = Canvas(screen, 10, 40, 0, 0) effect = Explosion(canvas, 4, 4, 25) self.check_effect(canvas, effect, lambda value: self.assertIn(chr(value[0]), ' #'), iterations=25)
def startup_animation(screen): scenes = [] effects = [] for _ in range(10): effects.append( Explosion(screen, randint(3, screen.width - 4), randint(1, screen.height - 2), randint(20, 30), start_frame=randint(0, 250))) effects.append(Print(screen, FigletText("Welcome \nto \nNaparm", font='standard'), screen.height // 2 - 10, speed=1, start_frame=100)) scenes.append(Scene(effects, -1)) screen.play(scenes, stop_on_resize=True, repeat=False)
def demo(screen): screen.set_title("ASCIIMATICS demo") scenes = [] # First scene: title page effects = [ Print(screen, Rainbow(screen, FigletText("ASCIIMATICS", font="big")), y=screen.height // 4 - 5), Print(screen, FigletText("Particle System"), screen.height // 2 - 3), Print(screen, FigletText("Effects Demo"), screen.height * 3 // 4 - 3), Print(screen, SpeechBubble("Press SPACE to continue..."), screen.height - 3, transparent=False, start_frame=70) ] scenes.append(Scene(effects, -1)) # Next scene: just dissolve the title. effects = [ ShootScreen(screen, screen.width // 2, screen.height // 2, 100), ] scenes.append(Scene(effects, 40, clear=False)) # Next scene: sub-heading. effects = [ DropScreen(screen, 100), Print(screen, Rainbow(screen, FigletText("Explosions", font="doom")), y=screen.height // 2 - 5, stop_frame=30), DropScreen(screen, 100, start_frame=30) ] scenes.append(Scene(effects, 80)) # Next scene: explosions effects = [] for _ in range(20): effects.append( Explosion(screen, randint(3, screen.width - 4), randint(1, screen.height - 2), randint(20, 30), start_frame=randint(0, 250))) effects.append(Print(screen, SpeechBubble("Press SPACE to continue..."), screen.height - 6, speed=1, transparent=False, start_frame=100)) scenes.append(Scene(effects, -1)) # Next scene: sub-heading. effects = [ Print(screen, Rainbow(screen, FigletText("Rain", font="doom")), y=screen.height // 2 - 5, stop_frame=30), DropScreen(screen, 100, start_frame=30) ] scenes.append(Scene(effects, 80)) # Next scene: rain storm. effects = [ Rain(screen, 200), Print(screen, SpeechBubble("Press SPACE to continue..."), screen.height - 6, speed=1, transparent=False, start_frame=100) ] scenes.append(Scene(effects, -1)) # Next scene: sub-heading. effects = [ Print(screen, Rainbow(screen, FigletText("Fireworks", font="doom")), y=screen.height // 2 - 5, stop_frame=30), DropScreen(screen, 100, start_frame=30) ] scenes.append(Scene(effects, 80)) # Next scene: fireworks effects = [] for _ in range(20): effects.append( StarFirework(screen, randint(3, screen.width - 4), randint(1, screen.height - 2), randint(20, 30), start_frame=randint(0, 250))) effects.append(Print(screen, SpeechBubble("Press SPACE to continue..."), screen.height - 6, speed=1, transparent=False, start_frame=100)) scenes.append(Scene(effects, -1)) screen.play(scenes, stop_on_resize=True)