Esempio n. 1
0
bool init()
{
    //Initialize all SDL subsystems
    if( SDL_Init( SDL_INIT_EVERYTHING ) == -1 )
    {
        return false;
    }


    //Set up the screen
    screen = SDL_SetVideoMode( SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP, SDL_SWSURFACE );

    //If there was an error in setting up the screen
    if( screen == NULL )
    {
        return false;
    }

	 //Initialize SDL_ttf
    if( TTF_Init() == -1 )
    {
        return false;    
    }


	//Initialize controller
	if(false) 
		{} //TODO: Use conditioning to determine whether to use keyboard, gamepad or other input. -JVL
	else 
		controller = new KeyboardMouse;

	if(!controller->init())
		return false;

	animationTest = new Animation();
	if(!animationTest->init(3, 5,64,64, load_image( "Sprites//giraffe.png" )))
		return false;

	if(!clock.init()) //initialize the clock.
		return false;

	//Initialize Death
	deathPlayer = new Death(700, 700, load_image( "Sprites//giraffe.png" ), controller);
	testMonster = new TestMonster(load_image( "Sprites//giraffe.png" ));

    //Set the window caption
    SDL_WM_SetCaption( "Controller BETA Joshua Liong", NULL );

	//Other test stuff
	blackTest = load_image("Sprites//BlackTest.png");

    //If everything initialized fine
    return true;
}
/**
 * \brief Start-Funktion der Testumgebung
 *
 * Diese Funktion wird einmal beim Starten der Testumgebung
 * aufgerufen.
 */
TEFUNC
void initialize(int /*argc*/, char** /*argv*/) {

	// --------- Ein wenig Testkram, ist unbedeutetnd -------------

	orientationInit.normalize();
	Quaternion test(0,M_PI/2,M_PI/2);
	cout << test << endl
		 << M_PI/2 << endl
		 << test.getEulerRotation() << endl;

//		exit (0);


	//----------------- uhr initialisieren --------------------
	timer.init();
	
	// --- Anlegen der Zeiger und Objekte mit denen gearbeitet werden soll ----

	RigidBodyPtr body;
	GeometryPtr boxGeo;

	// Erste id ist null. Wird dann hochgezählt.
	Id id(Id::typeBox,0);


	// -------------- Einfache Rotation -----------
	//Euler
	id.setNumber(0);
	
	body = rigidBodySystemEuler.create(id);
	
	body->setPosition(positionInit);
	body->setMass(massInit);
	body->setOrientation(orientationInit);
	body->setVelocity(velocityInit);
	body->setAngularVelocity(angularVelocityInit);
		
 	boxGeo = geometrySystem.createBox(body, boxScaleInit);
 	boxGeo->setBounciness(0.6);
 	boxGeo->setColor(Graphics::red);
  

	//Runge-Kutta
	id.setNumber(1);
	
	body = rigidBodySystemRunge.create(id);
	body->setPosition(Vec3(-300.0, 0.0, 0.0));
	
	body->setPosition(positionInit);
	body->setMass(massInit);
	body->setOrientation(orientationInit);
	body->setVelocity(velocityInit);
	body->setAngularVelocity(angularVelocityInit);
		
	boxGeo = geometrySystem.createBox(body, boxScaleInit);
   	boxGeo->setBounciness(0.6);
	boxGeo->setColor(Graphics::blue);

	// Verlet-Baltman
	 id.setNumber(2);

 	body = rigidBodySystemVerlet.create(id);
 	body->setPosition(positionInit);

 	body->setMass(massInit);
 	body->setOrientation(orientationInit);
 	body->setVelocity(velocityInit);
 	body->setAngularVelocity(angularVelocityInit);

		
   	boxGeo = geometrySystem.createBox(body, boxScaleInit);
   	boxGeo->setBounciness(0.6);
   	boxGeo->setColor(Graphics::green);


	referenceBody->setPosition(positionInit);
	referenceBody->setMass(massInit);
	referenceBody->setOrientation(orientationInit);
	referenceBody->setVelocity(velocityInit);
	referenceBody->setAngularVelocity(angularVelocityInit);
		
	boxGeo = geometrySystem.createBox(referenceBody, boxScaleInit);
	boxGeo->setBounciness(0.6);
	boxGeo->setColor(Graphics::yellow);

	// ------------- Keine Visosity -------------
	rigidBodySystemEuler.disableViscosity();
	rigidBodySystemRunge.disableViscosity();
	rigidBodySystemVerlet.disableViscosity();
	
			
}