Ejemplo n.º 1
0
int main( int argc, char **argv )
{
	ProbTable pt;
	VelocityTable vt;
	//RailTable rt;

	double length = 2.4384;               //the length of the table in metres
	double width = 1.2192;                //the width of the table in metres
	double cornerPocketWidth = 0.1061;    //the width of corner pockets (horn to horn) in metres
	double sidePocketWidth = 0.15;        //the width of the side pockets (horn to horn) in metres
	double muS = 0.2;                     //the coefficient of sliding friction (dimensionless)
	double muR = 0.01;                    //the coefficient of rolling friction (dimensionless)
	double muSp = 0.044;                  //the coefficient of spinning friction (dimensionless)
	double railHeight = 0.05715;          //the height of the top of the rail above the table in metres
	double cueLength = 1.0;               //the length of the cue in metres
	double railVelDamping = 0.6;          //damping factor of the banks
	double railSpinDamping = 0.1;         //spin damping factor of the banks
	double railZSpinAngleAdj = 0.0005;    // z-spin angle of deflection factor of the banks
	double railVelAngleAdj = 0.001;       //velocity deflection factor of the banks
	//onRobot indicates whether the game is being played on the robotic table (optional, default = false)

	fizGShot myShot;
	fizGTable myTable(length,
						width,
						cornerPocketWidth,
						sidePocketWidth,
						muS,
						muR,
						muSp,
						railHeight,
						cueLength,
						railVelDamping,
						railSpinDamping,
						railZSpinAngleAdj,
						railVelAngleAdj);

	string s;
	s = getPoolfizVersion();
	cout << s;

	printf("length %f width %f headstring %f\n",myTable.getLength(),myTable.getWidth(),myTable.getHeadString());

	//computeBreak(myShot, myTable);

	if(!vt.load("velocity2.tbl"))
	{
		vt.fill(myTable, myShot);
		vt.save("velocity2.tbl");
	}

	pt.fill(&vt, myTable, myShot);
	pt.save("probtable2.tbl");


	/*
	rt.fill(myTable,myShot);
	rt.save("railtable.tbl");
	*/
	return 0;
}
Ejemplo n.º 2
0
void script_enviroment::BindSquirrel() 
{
	
	vm_squirrel_ = sq_open(1024); //creates a VM with initial stack size 1024

	Sqrat::DefaultVM::Set(vm_squirrel_);

	Sqrat::Table myTable(vm_squirrel_);
	myTable.Func("MyFunc", &myFunc);
	
	Sqrat::RootTable(vm_squirrel_).SetValue("myVal",0);

	//this sets the print function :)
	Sqrat::RootTable(vm_squirrel_).Func<void (*)(std::string)>("print", &print_zax);
		
	/*Sqrat::Class<enemigo> class_enemigo(vm_squirrel_);
	class_enemigo.Var("status",&enemigo::status_);

	*/
	Sqrat::Class<MyClass> myClass(vm_squirrel_);
	myClass.Func("Foo", &MyClass::Foo);
	myClass.Var("bar", &MyClass::bar);

	Sqrat::Class<console_manager> Console_Manager(vm_squirrel_);
	Console_Manager.Func("print", &console_manager::add_message);



	//RootTable(vm).BindValue("other_var", &var_test);

		
	Sqrat::RootTable(vm_squirrel_).Bind("MyTable", myTable);
	Sqrat::RootTable(vm_squirrel_).Bind("MyClass", myClass);
	//Sqrat::RootTable(vm_squirrel_).Bind("enemigo", class_enemigo);
	Sqrat::RootTable(vm_squirrel_).Bind("console_manager", Console_Manager);
	Sqrat::RootTable(vm_squirrel_).SetInstance("console_test", g_console); /* now the variable c in C++ appears as the variable c in the root table in Squirrel */


    Sqrat::Class<global_vars_> _global_vars;
	_global_vars.Var("var_test", &global_vars_::var_test);
    Sqrat::RootTable(vm_squirrel_).Bind("global_vars_", _global_vars);
	Sqrat::RootTable(vm_squirrel_).SetInstance("global_vars", &global_vars); /* now the variable c in C++ appears as the variable c in the root table in Squirrel */


	/*Sqrat::Script *t = new Sqrat::Script();
	sq_scripts_.push_back(t);
		
	//script1->CompileString("MyTable.MyFunc(); myVal = myVal + 1;");
	t->CompileString("global_vars.var_test += 1; print(\"Val: Well this is my script running (I'm testing) \" + global_vars.var_test); function Add_FuncTest(a, b) { return a + b; }");

	Sqrat::Script *script2 = new Sqrat::Script();
	script2->CompileString("function Add_FuncTest(a, b) { return (a * b * 0)+test(); }function test(){ return 15;}");
	script2->Run();
	funcA2 = new Sqrat::Function(Sqrat::RootTable(vm_squirrel_), "Add_FuncTest"); // Via the constructor
	sq_scripts_.push_back(script2);
	//delete(script2);*/

	/*Sqrat::Script *temp = new Sqrat::Script();
	temp->CompileString("console_test.print(\"There was a respawn\"); function test(){ return 25;}console_test.print(\"n:\"+test()); function on_respawn_enemy(enem_){console_test.print(\"There is from the default function \"+enem_.status);enem_.status = 4;}");
	unit_event *temp2 = new unit_event();
	temp2->script_ = temp;
	temp2->event_id_ = get_event_by_name("enemy_respawn");
	set_function(temp2);

	enemy_scripts_.push_back(temp2);*/

}