コード例 #1
0
ファイル: weapons.py プロジェクト: witheld9/vector-kill
def tick(entity):
	entity['recoil_time'] -= 1
	
	if not entity['owner_id'] in entities.ENTITIES:
		entities.unregister_event(entity, 'tick', tick)
		
		return False
	
	if entity['recoil_time']>0:
		return False
	elif not entity['rounds']:
		if entity['reload_time']:
			if entity['owner_id'] in entities.ENTITIES and 'player' in entities.get_entity(entity['owner_id']) and entity['reload_time'] == entity['reload_time_max']:
				display.print_text(0, 0, 'RELOADING', show_for=(entity['reload_time']/display.get_tps())*2, fade_out_speed=255)
				
			entity['reload_time'] -= 1
		else:
			entity['reload_time'] = entity['reload_time_max']
			entity['recoil_time'] = 1
			entity['rounds'] = entity['max_rounds']
			entity['firing'] = False
			entities.unregister_event(entity, 'tick', tick)
		
		return False
	
	_owner = entities.get_entity(entity['owner_id'])
	
	if 'shoot_direction' in entity:
		_direction = entity['shoot_direction']
	elif 'shoot_direction' in _owner:
		_direction = _owner['shoot_direction']
	else:
		_direction = _owner['direction']
	
	if entity['kickback']:
		entities.trigger_event(entities.get_entity(entity['owner_id']), 'push', velocity=numbers.velocity(_direction+180, entity['kickback']))
	
	if entity['missile']:
		bullet.create_missile(_owner['position'][0],
		                      _owner['position'][1],
		                      _direction,
		                      entity['speed'],
		                      'bullet.png',
		                      entity['owner_id'],
		                      turn_rate=entity['turn_rate'],
		                      tracking=entity['tracking'],
		                      radius=entity['damage_radius'])
	
	if entity['bullet']:
		bullet.create_bullet(_owner['position'][0],
		                     _owner['position'][1],
		                     _direction+random.randint(-entity['spray'], entity['spray']),
		                     entity['speed'],
		                     'bullet.png',
		                     entity['owner_id'],
		                     scale=.6,
		                     radius=entity['damage_radius'])
	
	entity['recoil_time'] = entity['recoil_time_max']
	entity['rounds'] -= 1
コード例 #2
0
    def test_create_bullet_with_TELEPORTATION_BULLET(self):
        start = (0, 0)
        destination = (10, 10)
        pop_power = 1

        s = bullet.create_bullet(bullet.TELEPORTATION_BULLET, start, destination, pop_power)

        self.assertIsInstance(s, bullet.TeleportationBullet)
コード例 #3
0
    def test_create_bullet_with_EXPLOSION_BULLET(self):
        start = (0, 0)
        destination = (10, 10)
        pop_power = 1

        s = bullet.create_bullet(bullet.EXPLOSION_BULLET, start, destination, pop_power)

        self.assertIsInstance(s, bullet.ExplosionBullet)
コード例 #4
0
    def test_create_bullet_with_STANDARD_BULLET(self):
        start = (0, 0)
        destination = (10, 10)
        pop_power = 1

        s = bullet.create_bullet(bullet.STANDARD_BULLET, start, destination, pop_power)

        self.assertIsInstance(s, bullet.StandardBullet)
コード例 #5
0
ファイル: tower.py プロジェクト: NanoBreeze/ML-Tower-Defence
 def create_bullets(self, balloon):
     """
     :param balloon:
     :return: bullet
     Creates a bullet directed towards the given balloon
     """
     return bullet.create_bullet(bullet_type=bullet.STANDARD_BULLET,
                                 start=(self.rect.centerx, self.rect.centery),
                                 destination=(balloon.get_centerX(), balloon.get_centerY()),
                                 pop_power=self._attack_values.pop_power,
                                 tower_increment_pop_method=self.increment_pop_count)
コード例 #6
0
ファイル: tower.py プロジェクト: NanoBreeze/ML-Tower-Defence
    def create_bullets(self, balloons):
        return [bullet.create_bullet(bullet_type=bullet.STANDARD_BULLET,
                                     start=(self.rect.centerx, self.rect.centery),
                                     destination=(self.rect.centerx, self.rect.centery - 100),
                                     pop_power=self._attack_values.pop_power,
                                     tower_increment_pop_method=self.increment_pop_count),

                bullet.create_bullet(bullet_type=bullet.STANDARD_BULLET,
                                     start=(self.rect.centerx, self.rect.centery),
                                     destination=(self.rect.centerx + 100, self.rect.centery - 100),
                                     pop_power=self._attack_values.pop_power,
                                     tower_increment_pop_method=self.increment_pop_count),

                bullet.create_bullet(bullet_type=bullet.STANDARD_BULLET,
                                     start=(self.rect.centerx, self.rect.centery),
                                     destination=(self.rect.centerx + 100, self.rect.centery),
                                     pop_power=self._attack_values.pop_power,
                                     tower_increment_pop_method=self.increment_pop_count),

                bullet.create_bullet(bullet_type=bullet.STANDARD_BULLET,
                                     start=(self.rect.centerx, self.rect.centery),
                                     destination=(self.rect.centerx + 100, self.rect.centery + 100),
                                     pop_power=self._attack_values.pop_power,
                                     tower_increment_pop_method=self.increment_pop_count),

                bullet.create_bullet(bullet_type=bullet.STANDARD_BULLET,
                                     start=(self.rect.centerx, self.rect.centery),
                                     destination=(self.rect.centerx, self.rect.centery + 100),
                                     pop_power=self._attack_values.pop_power,
                                     tower_increment_pop_method=self.increment_pop_count),

                bullet.create_bullet(bullet_type=bullet.STANDARD_BULLET,
                                     start=(self.rect.centerx, self.rect.centery),
                                     destination=(self.rect.centerx - 100, self.rect.centery + 100),
                                     pop_power=self._attack_values.pop_power,
                                     tower_increment_pop_method=self.increment_pop_count),

                bullet.create_bullet(bullet_type=bullet.STANDARD_BULLET,
                                     start=(self.rect.centerx, self.rect.centery),
                                     destination=(self.rect.centerx - 100, self.rect.centery),
                                     pop_power=self._attack_values.pop_power,
                                     tower_increment_pop_method=self.increment_pop_count),

                bullet.create_bullet(bullet_type=bullet.STANDARD_BULLET,
                                     start=(self.rect.centerx, self.rect.centery),
                                     destination=(self.rect.centerx - 100, self.rect.centery - 100),
                                     pop_power=self._attack_values.pop_power,
                                     tower_increment_pop_method=self.increment_pop_count)
                ]
コード例 #7
0
ファイル: ships.py プロジェクト: witheld9/vector-kill
def ivan_cycles(entity):
	if entity['warmup_cycles']:
		entity['warmup_cycles'] -= 1
		
		return False
	
	if entity['cycle'] == 'shoot':
		#if entity['shoot_cycle'] == entity['shoot_cycle_max']:
		#	for i in range(8):
		#		bullet.create_laser(entity['position'][0], entity['position'][0], 45*(i+1), entity['_id'], damage=30, length=90)
		
		entity['shoot_cycle'] -= 1
		
		if not entity['shoot_cycle']:
			entity['shoot_cycle'] = entity['shoot_cycle_max']
			entity['cycle'] = 'spawn'
		
		for direction in range(0, 360, 15):
			for i in range(4):
				bullet.create_bullet(entity['position'][0],
					                entity['position'][1],
					                direction+4*i,
					                60+(i*10),
					                'boss3_core.png',
					                entity['_id'],
					                damage=15)
	else:
		entity['spawn_cycle'] -= 1
		
		if not entity['spawn_cycle']:
			entity['spawn_cycle'] = entity['shoot_cycle_max']
			entity['cycle'] = 'shoot'
		
		for i in range(5):
			_mine = create_eyemine(x=entity['position'][0], y=entity['position'][1], max_explode_velocity=90)
			entities.trigger_event(_mine, 'push', velocity=numbers.velocity(random.randint(0, 359), 65))
コード例 #8
0
ファイル: tower.py プロジェクト: NanoBreeze/ML-Tower-Defence
 def create_bullets(self, balloon):
     return bullet.create_bullet(bullet_type=bullet.TELEPORTATION_BULLET,
                                 start=(self.rect.centerx, self.rect.centery),
                                 destination=(balloon.get_centerX(), balloon.get_centerY()),
                                 pop_power=self._attack_values.pop_power,
                                 tower_increment_pop_method=self.increment_pop_count)