Esempio n. 1
0
void weather_add_lightning(int type, float x, float y)
{
	if (thunders_count < MAX_THUNDERS && lightnings_defs_count > 0)
	{
		// store the thunder
		thunders[thunders_count].type = type;
		thunders[thunders_count].x_pos = x;
		thunders[thunders_count].y_pos = y;
		thunders[thunders_count].time = cur_time;
		++thunders_count;

        lightning_type = rand()%lightnings_defs_count;
        lightning_position[0] = x;
        lightning_position[1] = y;
        lightning_stop = cur_time + 200 + rand()%200;
        lightning_falling = 1;
        
        skybox_coords_from_ground_coords(lightning_sky_position,
                                         lightning_position[0] + camera_x,
                                         lightning_position[1] + camera_y);
        
        lightning_sky_position[0] -= camera_x;
        lightning_sky_position[1] -= camera_y;

        if (skybox_update_delay > 0)
            skybox_update_colors();
	}
}
Esempio n. 2
0
void weather_update()
{
	static Uint32 last_update = 0;
	Uint32 ticks = cur_time - last_update;
	int i;

	update_wind();

	// we update the lightning
	if (lightning_falling && cur_time > lightning_stop)
	{
		lightning_falling = 0;
		if (skybox_update_delay > 0)
			skybox_update_colors();
	}

	// we update the areas
	for (i = 0; i < MAX_WEATHER_AREAS; ++i)
		if (weather_areas[i].type > 0 && weather_areas[i].intensity_change_duration > 0)
		{
			if (weather_areas[i].intensity_change_duration <= ticks)
			{
				weather_areas[i].intensity += weather_areas[i].intensity_change_speed*weather_areas[i].intensity_change_duration;
				weather_areas[i].intensity_change_duration = 0;
			}
			else
			{
				weather_areas[i].intensity += weather_areas[i].intensity_change_speed*ticks;
				weather_areas[i].intensity_change_duration -= ticks;
			}
			if (weather_areas[i].intensity_change_speed < 0.0)
			{
				if (weather_areas[i].intensity <= 0.001)
				{
					weather_areas[i].intensity = 0.0;
					weather_areas[i].type = 0;
				}
			}
			else
			{
				if (weather_areas[i].intensity > 1.0)
					weather_areas[i].intensity = 1.0;
			}
		}
	
	// we compute the ratios at the actor position
	weather_compute_ratios(weather_ratios, -camera_x, -camera_y);
	
	current_weather_density = weather_get_density_from_ratios(weather_ratios);

	// we compute the weather color at the actor position
	weather_get_color_from_ratios(weather_color, weather_ratios);
	
	// we update the weather types
	for (i = 1; i < MAX_WEATHER_TYPES; ++i)
		update_weather_type(i, -camera_x, -camera_y, 0.0, ticks);
	
	last_update = cur_time;
}
Esempio n. 3
0
static int el_load_map(const char * file_name)
{
	int ret;

	init_map_loading(file_name);
	ret = load_map(file_name, &updat_func);
	if (!ret)
		// don't try to build pathfinder maps etc. when loading 
		// the map failed...
		return ret;


	if (strstr(file_name, "underworld") != NULL)
	{
		skybox_set_type(SKYBOX_UNDERWORLD);
		skybox_update_colors();
	}
	else if (dungeon)
	{
		skybox_set_type(SKYBOX_NONE);
		skybox_update_colors();
	}
	else
	{
		skybox_set_type(SKYBOX_CLOUDY);
		skybox_init_defs(file_name);
	}
	build_path_map();
	init_buffers();
	
	// reset light levels in case we enter or leave an inside map
	new_minute();

	destroy_loading_win();
	return ret;
}