예제 #1
0
def create_bullet(x, y, direction, speed, sprite_name, owner_id, damage=3, life=3000, scale=.2, radius=50):
	_bullet = create(x, y, direction, speed, sprite_name, owner_id, damage=damage, life=life)
	_owner = entities.get_entity(_bullet['owner_id'])
	_bullet['sprite'].anchor_x = 0
	_bullet['sprite'].anchor_y = sprites.get_size(_bullet['sprite'])[1]/2
	
	entities.trigger_event(_bullet, 'set_scale', scale=scale)
	entities.trigger_event(_bullet, 'set_rotation', degrees=_bullet['direction'])
	
	return _bullet
예제 #2
0
def create_missile(x, y, direction, speed, sprite_name, owner_id, life=3000, scale=.2, turn_rate=.15, tracking=True, drunk=True, radius=50):
	_bullet = create(x, y, direction, speed, sprite_name, owner_id, life=life, turn_rate=turn_rate, radius=radius)
	_owner = entities.get_entity(_bullet['owner_id'])
	_bullet['sprite'].anchor_x = 0
	_bullet['sprite'].anchor_y = sprites.get_size(_bullet['sprite'])[1]/2
	
	entities.trigger_event(_bullet, 'set_scale', scale=scale)
	entities.register_event(_bullet, 'tick', tick_missile)
	entities.register_event(_bullet, 'hit', hit_missile)
	
	if drunk:
		entities.register_event(_bullet, 'tick', tick_drunk)
	
	if tracking:
		_bullet['target_id'] = ai.find_target(_owner, max_distance=1600)
		
		if _bullet['target_id']:
			_target = entities.get_entity(_bullet['target_id'])
			
			entities.register_event(_bullet, 'tick', tick_track)
			entities.register_event(_target,
			                        'delete',
			                        lambda target: _bullet['_id'] in entities.ENTITIES and entities.unregister_event(_bullet,
			                                                                                                         'tick',
			                                                                                                         tick_track))
			
			if 'player' in _owner and _owner['player']:
				effects.create_particle(_target['position'][0],
					                    _target['position'][1],
					                    'crosshair.png',
					                    background=False,
					                    scale_rate=.95,
					                    fade_rate=.98,
					                    spin=random.choice([-3, -6, 3, 6]))
	else:
		_bullet['target_id'] = None
	
	_bullet['engine_power'] = 100
	
	return _bullet