예제 #1
0
static void on_flow(const Level *level, FlowEvent *ev)
{
    int d;
    Type t = level_get_block(level, ev->x, ev->y, ev->z);

    if (!is_fluid(t)) return;

    for (d = 0; d < 6; ++d)
    {
        int nx, ny, nz;

        if (DY[d] > 0) continue;  /* don't flow upward */

        nx = ev->x + DX[d];
        ny = ev->y + DY[d];
        nz = ev->z + DZ[d];
        if (level_index_valid(level, nx, ny, nz))
        {
            Type u = level_get_block(level, nx, ny, nz);
            if ( u == BLOCK_EMPTY &&
                 !type_nearby(level, nx, ny, nz, BLOCK_SPONGE, 3))
            {
                /* Propagate fluid */
                update_block(nx, ny, nz, t);
            }
            else
            if ((is_water(t) && is_lava(u)) || (is_lava(t) && is_water(u)))
            {
                /* Water and lava make stone */
                update_block(nx, ny, nz, BLOCK_STONE_GREY);
            }
        }
    }
}
예제 #2
0
void colour_aridity (Planet_colours& c, const Planet& p, const Season& s) {
	static const Colour water = Colour(1.0, 1.0, 1.0);

	static const Colour col[4] = {
		Colour(1.0, 0.0, 0.0),
		Colour(1.0, 1.0, 0.0),
		Colour(0.0, 1.0, 0.0),
		Colour(0.0, 0.5, 0.0)};
		
	float limits[4] = {2.0f, 1.0f, 0.5f, 0.0f};

	for (const Tile& t : tiles(p)) {
		if (is_water(nth_tile(terrain(p) ,id(t))))
			c.tiles[id(t)] = water;
		else {
			float ar = aridity(nth_tile(s, id(t)));
			c.tiles[id(t)] = col[3];
			for (int i=1; i<4; i++) {
				if (ar > limits[i]) {
					double d = std::min(1.0f, (ar - limits[i]) / (limits[i-1] - limits[i]));
					c.tiles[id(t)] = interpolate(col[i], col[i-1], d);
					break;
				}
			}
		}
	}
}
예제 #3
0
void colour_vegetation (Planet_colours& c, const Planet& p, const Season& s) {
	static const Colour snow = Colour(1.0, 1.0, 1.0);
	static const Colour water_deep = Colour(0.05, 0.05, 0.20);
	static const Colour water_shallow = Colour(0.04, 0.22, 0.42);
	static const Colour land_low = Colour(0.95, 0.81, 0.53);
	static const Colour land_high = Colour(0.1, 0.1, 0.1);
	static const Colour vegetation = Colour(0.176, 0.32, 0.05);

	for (const Tile& t : tiles(p)) {
		if (is_water(nth_tile(terrain(p) ,id(t)))) {
			double d = std::min(1.0f, water_depth(nth_tile(terrain(p), id(t)))/400);
			c.tiles[id(t)] = interpolate(water_shallow, water_deep, d);
		}
		else {
			auto& climate = nth_tile(s, id(t));
			if (temperature(climate) <= freezing_point())
				c.tiles[id(t)] = snow;
			else {
				double d = std::min(1.0, (elevation(nth_tile(terrain(p), id(t))) - sea_level(p))/2500);
				Colour ground = interpolate(land_low, land_high, d);
				double v = std::min(1.0f, aridity(climate)/1.5f);
				c.tiles[id(t)] = interpolate(vegetation, ground, v);
			}
		}
	}
}
예제 #4
0
void _set_humidity (const Planet& planet, const Climate_parameters& par, Climate_generation_season& season) {
	for (auto& t : tiles(planet)) {
		float humidity = 0.0;		
		if (is_water(nth_tile(terrain(planet), id(t)))) {
			humidity = saturation_humidity(season.tiles[id(t)].temperature);
		}
		season.tiles[id(t)].humidity = humidity;
	}
	_iterate_humidity(planet, par, season);
}
예제 #5
0
	bool has_water( u16 x, u16 y )
	{
      Core::StaticList vec;
	  vec.clear();
      Core::readstatics( vec, x, y );
	  for ( const auto &rec : vec )
	  {
		if ( is_water( rec.graphic ) )
		  return true;
	  }
	  return false;
	}
예제 #6
0
bool has_water( u16 x, u16 y )
{
    StaticList vec;
    vec.clear();
    readstatics( vec, x, y );
    for( StaticList::iterator itr = vec.begin(), end = vec.end(); itr != end; ++itr )
    {
        const StaticRec& rec = *itr;
        if (is_water(rec.graphic))
            return true;
    }
    return false;
}
예제 #7
0
파일: special.c 프로젝트: callaa/luola
/* If ground!=0, only y+ axis is searched */
static int find_turret_xy (int *tx, int *ty,int ground)
{
    int x[4]={*tx,*tx,*tx,*tx}, y[4]={*ty,*ty,*ty,*ty};
    int dx[4]={0,1,0,-1}, dy[4]={1,0,-1,0};
    int r,loops=0;
    while(++loops<400) {
        for(r=0;r<4;r++) {
            if((ground&&r!=0) || is_water(x[r],y[r])) continue;
            x[r] += dx[r];
            y[r] += dy[r];
            if(is_solid(x[r],y[r])) {
                *tx = x[r];
                *ty = y[r];
                return 1;
            }
        }
    }
    return 0;
}
예제 #8
0
파일: critter.c 프로젝트: callaa/luola
/* Air/water critter timer function: search a new target to go to */
static void ac_searchtarget(struct Critter *critter) {
    unsigned int loops=0;
    int newx,newy,tmp;
    int oldx = Round(critter->physics.x);
    int oldy = Round(critter->physics.y);

    /* Search for a new target that doesn't go thru solid terrain */
    do {
        newx = oldx + 200-rand()%400;
        newy = oldy + 200-rand()%400;
    } while(((critter->type==AIRCRITTER?is_water(newx,newy):is_free(newx,newy))
            || hit_solid_line(oldx,oldy,newx,newy,&tmp,&tmp)
            != (critter->type==AIRCRITTER?TER_FREE:TER_WATER))
            && loops++<100);

    critter->flyer.targx = newx;
    critter->flyer.targy = newy;
    
    critter->timer = 2*GAME_SPEED + rand()%(5*GAME_SPEED);
}
예제 #9
0
void colour_topography (Planet_colours& c, const Planet& p) {
	static const Colour water_deep = Colour(0.0, 0.0, 0.25);
	static const Colour water = Colour(0.0, 0.12, 0.5);
	static const Colour water_shallow = Colour(0.0, 0.4, 0.6);

	static const Colour land[6] = {
		Colour(0.0, 0.4, 0.0),
		Colour(0.0, 0.7, 0.0),
		Colour(1.0, 1.0, 0.0),
		Colour(1.0, 0.5, 0.0),
		Colour(0.7, 0.0, 0.0),
		Colour(0.1, 0.1, 0.1)};
	double land_limits[7] = {-500, 0, 500, 1000, 1500, 2000, 2500};
	for (const Tile& t : tiles(p)) {
		const Terrain_tile& ter = nth_tile(terrain(p), id(t));
		double elev = elevation(ter) - sea_level(p);
		if (is_water(ter)) {
			if (elev < -1000) {
				c.tiles[id(t)] = water_deep;
			}
			else if (elev < -500) {
				double d = (elev+500)/(-500);
				c.tiles[id(t)] = interpolate(water, water_deep, d);
			}
			else {
				double d = elev/(-500);
				c.tiles[id(t)] = interpolate(water_shallow, water, d);
			}
		}
		else {
			c.tiles[id(t)] = land[5];
			for (int i=0; i<5; i++) {
				if (elev <= land_limits[i+1]) {
					double d = std::max(0.0, std::min(1.0, (elev - land_limits[i]) / (land_limits[i+1] - land_limits[i])));
					c.tiles[id(t)] = interpolate(land[i], land[i+1], d);
					break;
				}
			}
		}
	}
}
예제 #10
0
void colour_humidity (Planet_colours& c, const Planet& p, const Season& s) {
	static const Colour water = Colour(1.0, 1.0, 1.0);
	static const Colour land_dry = Colour(1.0, 1.0, 0.5);
	static const Colour land_mid = Colour(1.0, 1.0, 0.0);
	static const Colour land_humid = Colour(0.0, 0.7, 0.0);
	
	for (const Tile& t : tiles(p)) {
		double h = humidity(nth_tile(s, id(t))) / saturation_humidity(temperature(nth_tile(s, id(t))));
		if (is_water(nth_tile(terrain(p), id(t)))) {
			c.tiles[id(t)] = water;
		}
		else {
			if (h <= 0.5) {
				double d = h / 0.5;
				c.tiles[id(t)] = interpolate(land_dry, land_mid, d);
			}
			else {
				double d = (h-0.5)/0.5;
				c.tiles[id(t)] = interpolate(land_mid, land_humid, d);
			}
		}
	}
}
예제 #11
0
void colour_precipitation (Planet_colours& c, const Planet& p, const Season& s) {
	static const Colour water = Colour(1.0, 1.0, 1.0);
	static const Colour dry = Colour(1.0, 1.0, 0.5);
	static const Colour medium = Colour(0.0, 1.0, 0.0);
	static const Colour wet = Colour(0.0, 0.0, 1.0);

	for (const Tile& t : tiles(p)) {
		double high = 7e-8;
		double low = high/10;
		if (is_water(nth_tile(terrain(p), id(t))))
			c.tiles[id(t)] = water;
		else {
			float prec = precipitation(nth_tile(s, id(t)));
			if (prec < low) {
				double d = prec / low;
				c.tiles[id(t)] = interpolate(dry, medium, d);
			}
			else {
				double d = std::min(1.0, (prec - low) / (high - low));
				c.tiles[id(t)] = interpolate(medium, wet, d);
			}
		}
	}
}