Пример #1
0
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 logic():
	_time = get_time()
	_world = WORLDS[ACTIVE_WORLD]
	_world['last_tick'] = _time
	
	if _time>=_world['next_tick']:
		_world['next_tick'] = _time+(1.0/display.get_tps())
		
		events.trigger_event('tick')
	
	events.trigger_event('cleanup')