示例#1
0
文件: Script.c 项目: maxmitti/SGGP
func Damage()
{
	if(GetDamage() > 200)
	{
		CastObjects(ROCK,3,15);
		CastObjects(BONE,6,15);
	    var pZombie;
	    pZombie = CreateObject(ZCLK,0,0,-1);
	    pZombie -> SetColorDw(HSL(Random(256),255,127));
    	pZombie -> Zombize();
    	pZombie -> SetComDir(COMD_Left);
	    pZombie = CreateObject(ZCLK,0,0,-1);
	    pZombie -> SetColorDw(HSL(Random(256),255,127));
    	pZombie -> Zombize();
    	pZombie -> SetComDir(COMD_Left);
	    pZombie = CreateObject(ZCLK,0,0,-1);
	    pZombie -> SetColorDw(HSL(Random(256),255,127));
    	pZombie -> Zombize();
    	pZombie -> SetComDir(COMD_Left);
	    pZombie = CreateObject(ZCLK,0,0,-1);
	    pZombie -> SetColorDw(HSL(Random(256),255,127));
    	pZombie -> Zombize();
    	pZombie -> SetComDir(COMD_Left);
		RemoveObject();	
	}
}
示例#2
0
文件: Script.c 项目: maxmitti/SGGP
global func BlackWhite()
{
	var pO;
	for(pO in FindObjects(Find_NoContainer()))
	{
		SetClrModulation(HSL(0,0,0),pO);
	}
示例#3
0
HSL Color::getHSL() const {

  // h,s,l ranges are in 0.0 - 1.0
  auto hsl = HSL();

  const float max = Math::max( r, g, b );
  const float min = Math::min( r, g, b );

  float hue = 0.f, saturation = 0.f;
  auto lightness = ( min + max ) / 2.0f;

  if ( min != max ) {
    auto delta = max - min;

    saturation = lightness <= 0.5f ? delta / ( max + min ) : delta / ( 2 - max - min );

    if(max == r) {
      hue = ( g - b ) / delta + ( g < b ? 6.f : 0.f );
    } else if (max == g) {
      hue = ( b - r ) / delta + 2.f;
    } else if (max == b) {
      hue = ( r - g ) / delta + 4.f;
    }

    hue /= 6;
  }

  hsl.h = hue;
  hsl.s = saturation;
  hsl.l = lightness;

  return hsl;

}
示例#4
0
文件: Script.c 项目: maxmitti/SGGP
func Create()
{
	Zahl++;
	if(Zahl > 200 - GetPlayerCount()*10) Zahl = 1;
	if(Can && Zahl == 1) 
	{
	    if(ObjectCount(ZCLK) > 100 * GetPlayerCount()) return();
	    var pZombie;
	    pZombie = CreateObject(ZCLK,0,0,-1);
	    pZombie -> SetColorDw(HSL(Random(256),255,127));
    	pZombie -> Zombize();
    	pZombie -> SetComDir(COMD_Left);
    }
}
示例#5
0
文件: Script.c 项目: ev1313/gze
func SetGrowthStage() {
	if (growth >= 170) {
		SetCon(100 - (growth*3 - 340));
		if (GetCon() < 10) RemoveObject();
	} else {
		SetCon(Min(100, growth));
	}
	
	if (growth <= 90) {
		// go from hue 80 to hue 60  with con 0 - 90
		
		// turn number 0-90 into 0-20
		var huediff = (growth * 10) / 45;
		
		SetColorDw(HSL(80 - huediff, 250, 128));
	}
	if (growth > 90 && growth < 100) {
		// go from hue 60 to hue 0  within con 90-100
	
		// turn 90-100 into 0-10 into 0-60
		var huediff = (growth - 90) * 6;
		
		SetColorDw(HSL(60 - huediff, 250, 128));
	}
	if (growth >= 100 && growth <= 140) {
		SetColorDw(HSL(0, 250, 128));
	}

	if (growth > 120 && GetCategory() == 1) {
		Drop();
	}
	
	if (growth > 140) {
		var chng = growth - 140;
		SetColorDw(HSL(chng/2, 250 - chng, 128 - chng/2));
	}
}
示例#6
0
int main()
{
	int i;
	float r,g,b;
	float hue;
	float hsvalue;
	float rgain = 1; //this is green
	float ggain = 0.75; //this is red
	float bgain = 1;
	

	puts("unsigned int hsvtable[256] = {\n");
	for (i=0;i<256;i++) {
//		hue = 1 - (sqrt(i)/16); //first try
//		hue = 1 - (2.5 - log10(255-float()i+0.001))/2.5; //not very good, small range
//		hue = sin((float)i/128); //smoothish, reasonably nice with Mark playing guitar. Low dynamic range, though
//		hsvalue = (float)i/255; - 0.05;
		hue = (float)i/600; //Chosen value for Mark's performnce in reds
//		hue = (float)i/300; //nominal value for Mark's performance, CO.lab and Unify
//		hsvalue = (float)i/255;
//		hue = (float)log10(i)/1.5; //out of ~2.5 range
//		hue = (float)sqrt(i + 0.1); //pretty good candidate for Apo (May 19th)
		hsvalue = sin((float)i/255); //This was the function used at Unify and CO.lab
		if (hue < 0) {hue = 0;}
		if (hsvalue < 0) {hsvalue = 0;}
		//HSL( (0.7+(float)log(i)/4.5), 0.99, (float)log(2*i)/10.0,r,g,b); //burning man 2012
//		HSL( (0.7+(float)log(i)/4.5), 0.99, hsvalue,r,g,b); /255/burning man 2012
		HSL( (0.975 + hue), 0.99, hsvalue,r,g,b); //"blue / aqua" color mapping for Mark's performance
//		HSL( (0.975 + hue), 0.99, hsvalue,r,g,b); //"blue / aqua" color mapping for Mark's performance
//		HSL( (0.0+(float)log(i)/5.0), 0.99, (float)log(4*i)/12.0,r,g,b); // greens and yellows
//		HSL( (0.2+(float)log(i)/2.0), 0.99, (float)i/16.0,r,g,b);
		r = r * rgain; //swapping channels to fix the mapping
		g = g * ggain;
		b = b * bgain;
		int ur =(int)g;
		int ug =(int)r;
		int ub =(int)b;
		CLAMP(ur);
		CLAMP(ug);
		CLAMP(ub);

		printf("0x%02x%02x%02x00", ((unsigned)ur>>1)|0x80,
			   ((unsigned)ug>>1)|0x80,((unsigned)ub>>1)|0x80);
		if (i!=255)
			putchar(',');
		putchar('\n');
	}
	puts("};\n");
}
示例#7
0
//converts rgb values to Hsl values
vector<double> Hsl::rgb2hsl(double red, double green, double blue)
{
	double r,g,b;
	double min, max;
	double delta;
	vector<double> HSL(3,0);
	r = red/255;
	g = green/255;
	b = blue/255;
	min = minRGB(r,g,b);
	max = maxRGB(r,g,b);
	L = (max+min)/2;
	delta = max-min;
	if(delta==0)
	{
		H=0; S=0;
	}
	else
	{
		if(L>0.5)
		{
			S = (max-min)/(2.0-max-min);
		}
		else
		{
			S = (max-min)/(max+min);
		}
		if(max==r)
		{
			H = ((g-b)/delta);
		}
		else if(max==g)
		{
			H = ((b-r)/delta) + 2;
		}
		else
		{
			H = ((r-g)/delta) + 4;
		}
		H *= 60;
		if(H<0) H+=360;
	}
	HSL[0] = round(H); HSL[1] = S; HSL[2] = L;
	return HSL;
}
示例#8
0
func Place(int amount, proplist area, proplist settings)
{
	var max_tries = 2 * amount;
	var loc_area = nil;
	if (area) loc_area = Loc_InArea(area);
	
	while ((amount > 0) && (--max_tries > 0))
	{
		var spot = FindLocation(Loc_Material("Water"), Loc_Wall(CNAT_Bottom | CNAT_Top | CNAT_Left | CNAT_Right), loc_area);
		if (!spot) continue;
		
		var plant = CreateObject(this, spot.x, spot.y, NO_OWNER);
		plant->SetClrModulation(HSL(Random(255), 255, 200));
		plant->AddFork(nil, true);

		--amount;
	}
	return true;
}
示例#9
0
func Initialize()
{
	SetCategory(0);
	
	AddTimer("SwimAround", 15);
	SetAction("Swim");
	SetComDir(COMD_None);
	
	var particles = 
	{
		Size = PV_Sin(PV_Step(PV_Random(1, 2)), PV_Random(0, 1), PV_Random(1,2)),
		Attach = ATTACH_MoveRelative,
		Alpha = 100
	};
	particles = Particles_Colored(particles, HSL(Random(255), 100, 75));
	
	var amount = RandomX(5, 10);
	CreateParticle("SphereSpark", PV_Random(-3, 3), PV_Random(-3, 3), 0, 0, 0, particles, amount);
}
示例#10
0
文件: Script.c 项目: maxmitti/SGGP
}

global func Invisib()
{
	SetMatAdjust(HSLa(0,0,0,255));
}

global func BlackWhite()
{
	var pO;
	for(pO in FindObjects(Find_NoContainer()))
	{
		SetClrModulation(HSL(0,0,0),pO);
	}
	SetMatAdjust(HSLa(0,0,0,0));
	SetSkyAdjust(HSLa(0,0,255,0),HSL(0,0,255));
}

global func ReColor()
{
	var pO;
	for(pO in FindObjects(Find_NoContainer()))
	{
		SetClrModulation(RGB(RandomX(128,255),RandomX(128,255),RandomX(128,255)),pO);
	}
	var i;
	var szMat;
	SetMatAdjust(RGBa(RandomX(0,255),RandomX(0,255),RandomX(0,255),RandomX(0,255)));
	SetSkyAdjust(RGBa(RandomX(0,255),RandomX(0,255),RandomX(0,255),RandomX(0,255)),RGBa(RandomX(0,255),RandomX(0,255),RandomX(0,255),RandomX(0,255)));
}
示例#11
0
int main(void)
{
	std::cout << "Starting engine" << std::endl;

	pastry::initialize();

	auto dr = std::make_shared<pastry::deferred::DeferredRenderer>();
	pastry::scene_add(dr);

	// scene (need this first!)
	auto scene = std::make_shared<pastry::deferred::Scene>();
	dr->setScene(scene);

	// skybox
	{
		auto go = pastry::deferred::FactorSkyBox();
		go->skybox->setTexture("assets/stormydays_cm.jpg");
		go->skybox->setGeometry("assets/sphere_4.obj");
		scene->setMainSkybox(go);
	}

	// camera
	{
		auto go = pastry::deferred::FactorCamera();
		go->camera->setProjection(90.0f, 1.0f, 100.0f);
		go->camera->setView({4,14,6},{2,3,0},{0,0,-1});
		scene->setMainCamera(go);
	}

	constexpr float SPACE = 3.0f;

	// geometry
	{
		constexpr int R = 3;
		for(int x=-R; x<=+R; x++) {
			for(int y=-R; y<=+R; y++) {
				auto go = pastry::deferred::FactorGeometry();
				go->geometry->load("assets/suzanne.obj");
				Eigen::Affine3f pose = Eigen::Translation3f(Eigen::Vector3f(SPACE*x,SPACE*y,0))
					* Eigen::AngleAxisf(0.0f,Eigen::Vector3f{0,0,1});
				go->geometry->setPose(pose.matrix());
				float p = static_cast<float>(x+R)/static_cast<float>(2*R);
				go->geometry->setRoughness(0.2f + 0.8f*p);
				scene->add(go);				
			}
		}
	}

	// lights
	// {
	// 	auto light = std::make_shared<pastry::deferred::PointLight>();
	// 	light->setLightPosition({+3,3,4});
	// 	light->setLightColor(20.0f*Eigen::Vector3f{1,1,1});
	// 	scene->add(light);
	// }
	// {
	// 	auto light = std::make_shared<pastry::deferred::PointLight>();
	// 	light->setLightPosition({-4,1,4});
	// 	light->setLightColor(20.0f*Eigen::Vector3f{1,0.5,0.5});
	// 	scene->add(light);
	// }
	{
		auto go = pastry::deferred::FactorEnvironmentLight();
		scene->add(go);
	}
	{
		constexpr int R = 3;
		for(int x=-R; x<=+R; x++) {
			for(int y=-R; y<=+R; y++) {
				auto go = pastry::deferred::FactorPointLight();
				((pastry::deferred::PointLight*)(go->light.get()))->setLightPosition({SPACE*x,SPACE*y,1.5});
				((pastry::deferred::PointLight*)(go->light.get()))->setLightColor(35.0f*HSL(std::atan2(y,x)/6.2831853f,0.5f,0.5f));
				((pastry::deferred::PointLight*)(go->light.get()))->setLightFalloff(0.05f);
				scene->add(go);
			}
		}
	}

	std::cout << "Running main loop" << std::endl;

	pastry::run();

	std::cout << "Graceful quit" << std::endl;

	return 0;
}