예제 #1
0
def spawn_enemies():
	global TRANSITION_PAUSE, CHANGE_WAVE_FIRE, CHANGE_WAVE, ANNOUNCE, WAVE
	
	_i = random.choice([0, 1, 2, 3])
	
	if WAVE == 3:
		TRANSITION_PAUSE = 30*30
		CHANGE_WAVE = True
		CHANGE_WAVE_FIRE = False
		
		return False
	
	if LEVEL == 2:
		return False
	
	if _i == 1:
		_xrange = random.choice([(100, worlds.get_size()[0]*.25),
		                         (worlds.get_size()[0]*.25, worlds.get_size()[0]*.5),
		                         (worlds.get_size()[0]*.5, worlds.get_size()[0]*.75),
		                         (worlds.get_size()[0]*.75, worlds.get_size()[0]-100)])
		_y = 100
	elif _i == 2:
		_x = worlds.get_size()[0]-100
		_y = random.choice([(100, worlds.get_size()[1]*.25),
		                         (worlds.get_size()[1]*.25, worlds.get_size()[1]*.5),
		                         (worlds.get_size()[1]*.5, worlds.get_size()[1]*.75),
		                         (worlds.get_size()[1]*.75, worlds.get_size()[1]-100)])
	elif _i == 3:
		_x = 100
		_y = random.randint(100, worlds.get_size()[1]-100)
	else:
		_x = random.randint(100, worlds.get_size()[0]-100)
		_y = worlds.get_size()[1]-100
	
	_missile_turrets = int(round(10*((WAVE+1)/5.0)))
	_gun_turrets = int(round(10*(WAVE/5.0)))
	_fleas = int(round(5*(WAVE/5.0)))
	
	for i in range(_fleas):
		if _i == 1:
			_x = random.randint(100, worlds.get_size()[0]-100)
			_y = 100
		elif _i == 2:
			_x = worlds.get_size()[0]-100
			_y = random.randint(100, worlds.get_size()[1]-100)
		elif _i == 3:
			_x = 100
			_y = random.randint(100, worlds.get_size()[1]-100)
		else:
			_x = random.randint(100, worlds.get_size()[0]-100)
			_y = worlds.get_size()[1]-100
		
		_entity = ships.create_flea(x=_x, y=_y, hazard=True)
		_move_direction = numbers.direction_to((_x, _y,), (worlds.get_size()[0]/2, worlds.get_size()[1]/2))
		
		entities.trigger_event(_entity, 'push', velocity=numbers.velocity(_move_direction, 20))
	
	for i in range(_gun_turrets):
		if _i == 1:
			_x = random.randint(200, worlds.get_size()[0]-200)
			_y = 200
		elif _i == 2:
			_x = worlds.get_size()[0]-200
			_y = random.randint(200, worlds.get_size()[1]-200)
		elif _i == 3:
			_x = 200
			_y = random.randint(200, worlds.get_size()[1]-200)
		else:
			_x = random.randint(200, worlds.get_size()[0]-200)
			_y = worlds.get_size()[1]-200
		
		_entity = ships.create_gun_turret(x=_x, y=_y)
		_move_direction = numbers.direction_to((_x, _y,), (worlds.get_size()[0]/2, worlds.get_size()[1]/2))
		
		entities.trigger_event(_entity, 'push', velocity=numbers.velocity(_move_direction, 20))
	
	for i in range(_missile_turrets):
		if _i == 1:
			_x = random.randint(100, worlds.get_size()[0]-100)
			_y = 100
		elif _i == 2:
			_x = worlds.get_size()[0]-100
			_y = random.randint(100, worlds.get_size()[1]-100)
		elif _i == 3:
			_x = 100
			_y = random.randint(100, worlds.get_size()[1]-100)
		else:
			_x = random.randint(100, worlds.get_size()[0]-100)
			_y = worlds.get_size()[1]-100
		
		_entity = ships.create_missile_turret(x=_x, y=_y)
		_move_direction = numbers.direction_to((_x, _y,), (worlds.get_size()[0]/2, worlds.get_size()[1]/2))
		
		entities.trigger_event(_entity, 'push', velocity=numbers.velocity(_move_direction, 20))
	
	WAVE += 1
	ANNOUNCE = True
예제 #2
0
def spawn_enemies():
    global TRANSITION_PAUSE, ANNOUNCE, LEVEL

    if LEVEL == 5:
        _boss = ships.create_ivan(x=random.randint(0,
                                                   worlds.get_size()[0]),
                                  y=random.randint(0,
                                                   worlds.get_size()[1]))
        _details = [
            '<b>Stolovitzky, Ivan</b>', '<i>Suicidal maniac</i>',
            'Wanted for: <b>Intergalactic Manslaughter</b>'
        ]

        display.camera_zoom(1.5)
        display.camera_focus_on(_boss['position'])
        display.clear_text_group('bot_center')
        display.print_text(display.get_window_size()[0] / 2,
                           display.get_window_size()[1] * .75,
                           'CRAZY IVAN',
                           font_size=42,
                           text_group='bot_center',
                           center=True,
                           color=(0, 240, 0, 50),
                           fade_in_speed=24,
                           show_for=3)

        _i = 0
        for detail_text in _details:
            display.print_text(display.get_window_size()[0] * .6,
                               display.get_window_size()[1] * .65 - (24 * _i),
                               detail_text,
                               font_size=20,
                               text_group='bot_center',
                               color=(240, 240, 240, 0),
                               fade_in_speed=(len(_details) - _i) * 2,
                               show_for=3)
            _i += 1

        clock.hang_for(180)
        entities.register_event(_boss, 'kill',
                                lambda entity: progress.unlock_chaingun())

        TRANSITION_PAUSE = 240
        ANNOUNCE = True
        LEVEL += 1

        return False

    if not LEVEL % 4:
        for i in range(1 * (LEVEL - 1)):
            ships.create_flea(x=random.randint(0,
                                               worlds.get_size()[0]),
                              y=random.randint(0,
                                               worlds.get_size()[1]))

        TRANSITION_PAUSE = 120
        ANNOUNCE = True
        LEVEL += 1

        return False

    for i in range(1 * (LEVEL - 1)):
        ships.create_flea(x=random.randint(0,
                                           worlds.get_size()[0]),
                          y=random.randint(0,
                                           worlds.get_size()[1]))

    _eyemine_spawn_point = (random.randint(worlds.get_size()[0] * .25,
                                           worlds.get_size()[0] * .75),
                            random.randint(worlds.get_size()[1] * .25,
                                           worlds.get_size()[1] * .75))
    for i in range(random.randint(2, 4) * LEVEL):
        _rand_distance = 350 + (120 * LEVEL)
        _x_mod = random.randint(-_rand_distance, _rand_distance)
        _y_mod = random.randint(-_rand_distance, _rand_distance)
        ships.create_eyemine(x=_eyemine_spawn_point[0] + _x_mod,
                             y=_eyemine_spawn_point[1] + _y_mod)

    _move = random.randint(0, 1)

    if _move:
        _move_direction = random.randint(0, 359)

    for i in range(random.randint(1, 2) * LEVEL):
        _x, _y = random.randint(worlds.get_size()[0] * .25,
                                worlds.get_size()[0] * .75), random.randint(
                                    worlds.get_size()[1] * .25,
                                    worlds.get_size()[1] * .75)
        _turret = ships.create_missile_turret(x=_x, y=_y)

        if _move:
            entities.trigger_event(_turret,
                                   'set_direction',
                                   direction=_move_direction)
            entities.trigger_event(_turret,
                                   'set_minimum_velocity',
                                   velocity=[-5, -5])
            entities.trigger_event(_turret,
                                   'set_maximum_velocity',
                                   velocity=[5, 5])
            entities.trigger_event(_turret, 'thrust')

    if LEVEL >= 3:
        for i in range(random.randint(1, 2) * (int(round(LEVEL * .25)))):
            _x, _y = random.randint(worlds.get_size()[0] * .25,
                                    worlds.get_size()[0] *
                                    .75), random.randint(
                                        worlds.get_size()[1] * .25,
                                        worlds.get_size()[1] * .75)
            _turret = ships.create_gun_turret(x=_x, y=_y)

            if _move:
                entities.trigger_event(_turret,
                                       'set_direction',
                                       direction=_move_direction)
                entities.trigger_event(_turret,
                                       'set_minimum_velocity',
                                       velocity=[-5, -5])
                entities.trigger_event(_turret,
                                       'set_maximum_velocity',
                                       velocity=[5, 5])
                entities.trigger_event(_turret, 'thrust')

    if 1 * (LEVEL - 1):
        display.clear_text_group('bot_center')
        display.print_text(display.get_window_size()[0] / 2,
                           display.get_window_size()[1] * .95,
                           'ENEMY FIGHTERS INBOUND',
                           color=(0, 240, 0, 255),
                           text_group='bot_center',
                           show_for=1.5,
                           center=True)

    LEVEL += 1
    ANNOUNCE = True
    TRANSITION_PAUSE = 120
예제 #3
0
def spawn_enemies():
	global TRANSITION_PAUSE, ANNOUNCE, LEVEL
	
	if LEVEL == 5:
		_boss = ships.create_ivan(x=random.randint(0, worlds.get_size()[0]), y=random.randint(0, worlds.get_size()[1]))
		_details = ['<b>Stolovitzky, Ivan</b>',
		            '<i>Suicidal maniac</i>',
		            'Wanted for: <b>Intergalactic Manslaughter</b>']
		
		display.camera_zoom(1.5)
		display.camera_focus_on(_boss['position'])
		display.clear_text_group('bot_center')
		display.print_text(display.get_window_size()[0]/2,
		                   display.get_window_size()[1]*.75,
		                   'CRAZY IVAN',
		                   font_size=42,
		                   text_group='bot_center',
		                   center=True,
		                   color=(0, 240, 0, 50),
		                   fade_in_speed=24,
		                   show_for=3)
		
		_i = 0
		for detail_text in _details:
			display.print_text(display.get_window_size()[0]*.6,
			                   display.get_window_size()[1]*.65-(24*_i),
			                   detail_text,
			                   font_size=20,
			                   text_group='bot_center',
			                   color=(240, 240, 240, 0),
			                   fade_in_speed=(len(_details)-_i)*2,
			                   show_for=3)
			_i += 1
		
		clock.hang_for(180)
		entities.register_event(_boss, 'kill', lambda entity: progress.unlock_chaingun())
		
		TRANSITION_PAUSE = 240
		ANNOUNCE = True
		LEVEL += 1
		
		return False
	
	if not LEVEL % 4:
		for i in range(1*(LEVEL-1)):
			ships.create_flea(x=random.randint(0, worlds.get_size()[0]), y=random.randint(0, worlds.get_size()[1]))
		
		TRANSITION_PAUSE = 120
		ANNOUNCE = True
		LEVEL += 1
		
		return False
	
	for i in range(1*(LEVEL-1)):
		ships.create_flea(x=random.randint(0, worlds.get_size()[0]), y=random.randint(0, worlds.get_size()[1]))
	
	_eyemine_spawn_point = (random.randint(worlds.get_size()[0]*.25, worlds.get_size()[0]*.75),
	                        random.randint(worlds.get_size()[1]*.25, worlds.get_size()[1]*.75))
	for i in range(random.randint(2, 4)*LEVEL):
		_rand_distance = 350+(120*LEVEL)
		_x_mod = random.randint(-_rand_distance, _rand_distance)
		_y_mod = random.randint(-_rand_distance, _rand_distance)
		ships.create_eyemine(x=_eyemine_spawn_point[0]+_x_mod, y=_eyemine_spawn_point[1]+_y_mod)
	
	_move = random.randint(0, 1)
	
	if _move:
		_move_direction = random.randint(0, 359)
	
	for i in range(random.randint(1, 2)*LEVEL):
		_x, _y = random.randint(worlds.get_size()[0]*.25, worlds.get_size()[0]*.75), random.randint(worlds.get_size()[1]*.25, worlds.get_size()[1]*.75)
		_turret = ships.create_missile_turret(x=_x, y=_y)
		
		if _move:
			entities.trigger_event(_turret, 'set_direction', direction=_move_direction)
			entities.trigger_event(_turret, 'set_minimum_velocity', velocity=[-5, -5])
			entities.trigger_event(_turret, 'set_maximum_velocity', velocity=[5, 5])
			entities.trigger_event(_turret, 'thrust')
	
	if LEVEL >= 3:
		for i in range(random.randint(1, 2)*(int(round(LEVEL*.25)))):
			_x, _y = random.randint(worlds.get_size()[0]*.25, worlds.get_size()[0]*.75), random.randint(worlds.get_size()[1]*.25, worlds.get_size()[1]*.75)
			_turret = ships.create_gun_turret(x=_x, y=_y)
			
			if _move:
				entities.trigger_event(_turret, 'set_direction', direction=_move_direction)
				entities.trigger_event(_turret, 'set_minimum_velocity', velocity=[-5, -5])
				entities.trigger_event(_turret, 'set_maximum_velocity', velocity=[5, 5])
				entities.trigger_event(_turret, 'thrust')
	
	if 1*(LEVEL-1):
		display.clear_text_group('bot_center')
		display.print_text(display.get_window_size()[0]/2,
		                   display.get_window_size()[1]*.95,
		                   'ENEMY FIGHTERS INBOUND',
		                   color=(0, 240, 0, 255),
		                   text_group='bot_center',
		                   show_for=1.5,
		                   center=True)
	
	LEVEL += 1
	ANNOUNCE = True
	TRANSITION_PAUSE = 120