Exemplo n.º 1
0
		virtual int init(unsigned int width, unsigned int height)
		{
			STX_INIT_SEGVCATCH;
			STX_TRY;
			g_pIndieLib = mI = CIndieLib::Instance();
	// ----- IndieLib intialization -----

#if 0
	//CIndieLib * mI = CIndieLib::Instance();
	if (!mI->Init ()) return 0;
#else
	
//CIndieLib * mI = CIndieLib::Instance();
	if (!mI->
		Init (
		"IndieLib-Animation-Collision"
		)) return -1;
#endif
	//IND_Entity2d Beetle

	// Loading Background
	//IND_Entity2d Beetle
	if (!mI->SurfaceManager->Add (&mSurfaceBack, "/IndieLib-Animation-Collision/cave.png", IND_ALPHA, IND_32))
		return 0;

	// Loading Beetleship
	//IND_Entity2d Beetle
	if (!mI->SurfaceManager->Add (&mSurfaceBeetle, "/IndieLib-Animation-Collision/beetleship.png", IND_ALPHA, IND_32))
		return 0;

	// ----- Animations loading -----

	// Characters animations
	//IND_Entity2d Beetle
	if (!mI->AnimationManager->AddToSurface (&AnimationCharacter, "/IndieLib-Animation-Collision/mario.xml", IND_ALPHA, IND_32))
		return 0;



	// ----- Set the surface and animations into 2d entities -----

	// Creating 2d entity for the background
	//IND_Entity2d Beetle
	mI->Entity2dManager->Add (&mBack);						// Entity adding (layer 0)
	mBack.SetSurface (&mSurfaceBack);						// Set the surface into the entity

	// Character 1
	//IND_Entity2d Beetle
	mI->Entity2dManager->Add (1, &Player);					// Entity adding (layer 1)
	Player.SetAnimation (&AnimationCharacter);				// Set the animation into the entity

	// Beetle
	//IND_Entity2d Beetle
	mI->Entity2dManager->Add (0, &Beetle);					// (layer 1)
	Beetle.SetSurface (&mSurfaceBeetle);					// Set the surface into the entity
	Beetle.SetPosition(500, 460, 0);
	Beetle.SetHotSpot (0.5f, 0.5f);
	Beetle.SetMirrorX (1);
	Beetle.SetBoundingTriangle ("beetle_head", 160, 105, 160, 170, 190, 135);
	Beetle.SetBoundingCircle ("beetle_boy_head", 85, 52, 55);



	MiddleScreenX = mI->Window->GetWidth() / 2;
	MiddleScreenY = mI->Window->GetHeight() / 2;
	CamPosX = MiddleScreenX;
	Cameras2d=IND_Camera2d(MiddleScreenX, MiddleScreenY);

	// ----- Main Loop -----

	timer.Start();



	// Init Player
	Player.SetSequence (0);			// standing
	Player.SetPosition (x , y, 0);
	Player.SetHotSpot (0.5f, 0.5f);
	Player.SetMirrorX (0);
	Player.SetBoundingRectangle("entire", 0, 0, 48, 48);
	STX_CATCH;
	return 0;

	}
Exemplo n.º 2
0
		virtual int init(unsigned int width, unsigned int height)
		{
			STX_INIT_SEGVCATCH;
			STX_TRY;
			g_pIndieLib = mI = CIndieLib::Instance();

	// ----- IndieLib intialization -----

#if 0
	//CIndieLib * mI = CIndieLib::Instance();
	if (!mI->Init ()) return 0;
#else
	
	mI = g_pIndieLib = CIndieLib::Instance();
	if (!mI->
		Init (
		"IndieLib-TankFollowsMouseFires"
		)) return -1;
#endif

	//////////////////////////////////////IND_Entity2d mTextSmallWhite;

	// Characters animations
	//////////////////////////////////////IND_Entity2d mTextSmallWhite;
	if (!mI->SurfaceManager->Add(&surfaceSky, "/IndieLib-TankFollowsMouseFires/images/frigistan_sky.png", IND_OPAQUE, IND_32)) return 0;

	//////////////////////////////////////IND_Entity2d mTextSmallWhite;
	if (!mI->SurfaceManager->Add(&surfaceGnd, "/IndieLib-TankFollowsMouseFires/images/frigistan_ground.png", IND_OPAQUE, IND_32)) return 0;

	//////////////////////////////////////IND_Entity2d mTextSmallWhite;
	if (!mI->AnimationManager->AddToSurface (&animTank, "/IndieLib-TankFollowsMouseFires/images/tank.xml", IND_ALPHA, IND_32)) return 0;

	//////////////////////////////////////IND_Entity2d mTextSmallWhite;
	if (!mI->SurfaceManager->Add(&surfaceBarrel, "/IndieLib-TankFollowsMouseFires/images/barrel.png", IND_ALPHA, IND_32)) return 0;

	//////////////////////////////////////IND_Entity2d mTextSmallWhite;
	if (!mI->SurfaceManager->Add(&surfaceCursor, "/IndieLib-TankFollowsMouseFires/images/crosshairs1.png", IND_ALPHA, IND_32)) return 0;

	//////////////////////////////////////IND_Entity2d mTextSmallWhite;
	if (!mI->SurfaceManager->Add(&surfaceBullet, "/IndieLib-TankFollowsMouseFires/images/bullet.png", IND_ALPHA, IND_32)) return 0;

	//////////////////////////////////////IND_Entity2d mTextSmallWhite;
	if (!mI->SurfaceManager->Add(&surfaceTankShadow, "/IndieLib-TankFollowsMouseFires/images/tankshadow.png", IND_ALPHA, IND_32)) return 0;

	//////////////////////////////////////IND_Entity2d mTextSmallWhite;
	if (!mI->SurfaceManager->Add(&surfaceMuzzleFlash, "/IndieLib-TankFollowsMouseFires/images/muzzleflash.png", IND_ALPHA, IND_32)) return 0;


	//////////////////////////////////////IND_Entity2d mTextSmallWhite;
	mI->Entity2dManager->Add(&sky);
	sky.SetSurface(&surfaceSky);

	//////////////////////////////////////IND_Entity2d mTextSmallWhite
	mI->Entity2dManager->Add(&ground);
	ground.SetSurface(&surfaceGnd);
	ground.SetPosition(0, mI->Window->GetHeight() - surfaceGnd.GetHeight(), 0);

	//////////////////////////////////////IND_Entity2d mTextSmallWhite
	mI->Entity2dManager->Add(&tank);
	tank.SetAnimation(&animTank);
	tank.SetHotSpot(0.5f, 0.1f);
	tank.SetPosition(g_vecPlayer_Pos.x, g_vecPlayer_Pos.y, 0);  // initial position

	//////////////////////////////////////IND_Entity2d mTextSmallWhite
	mI->Entity2dManager->Add(&barrel);
	barrel.SetSurface(&surfaceBarrel);
	barrel.SetHotSpot(0.5f, 1.0f);
	barrel.SetScale(1.5f, 1.5f);

	//////////////////////////////////////IND_Entity2d mTextSmallWhite
	mI->Entity2dManager->Add(&bullet);
	bullet.SetSurface(&surfaceBullet);
	bullet.SetHotSpot(0.5f, 0.5f);
	bullet.SetShow(false);

	//////////////////////////////////////IND_Entity2d mTextSmallWhite
	mI->Entity2dManager->Add(1, &cursor);		// GUI layer
	cursor.SetSurface(&surfaceCursor);
	cursor.SetHotSpot(0.5f, 0.5f);

	//////////////////////////////////////IND_Entity2d mTextSmallWhite
	mI->Entity2dManager->Add(0, &tankShadow);
	tankShadow.SetSurface(&surfaceTankShadow);
	tankShadow.SetHotSpot(0.5f, 0.7f);

	//////////////////////////////////////IND_Entity2d mTextSmallWhite
	mI->Entity2dManager->Add(0, &muzzleFlash);
	muzzleFlash.SetSurface(&surfaceMuzzleFlash);
	muzzleFlash.SetHotSpot(0.5f, 0.5f);
	muzzleFlash.SetShow(false);


	// Font
	//////////////////////////////////////IND_Entity2d mTextSmallWhite
	if (!mI->FontManager->Add (&FontSmall, "/IndieLib-TankFollowsMouseFires/font_small.png", "/IndieLib-TankFollowsMouseFires/font_small.xml", IND_ALPHA, IND_32)) return 0;

	// ----- Font creation -----

	//////////////////////////////////////IND_Entity2d mTextSmallWhite
	mI->Entity2dManager->Add(1, &mTextSmallWhite);		// Entity adding (Layer 1)
	mTextSmallWhite.SetFont			(&FontSmall);						// Set the font into the entity
	mTextSmallWhite.SetLineSpacing	(18);
	mTextSmallWhite.SetCharSpacing	(-8);
	mTextSmallWhite.SetPosition		(5, 5, 1);
	mTextSmallWhite.SetAlign		(IND_LEFT);


	timer.Start();



	// global audio manager pointer variable automatically set
	//IAudio* pAudioManager = STX_Service::GetAudioInstance()
	STX_Service::GetAudioInstance()->Init();

#if 1
	//------------------------------
	// Load all sounds
	//------------------------------
	for (int i = 0; i < MAX_SOUNDS; i++)
	{
		STX_Service::GetAudioInstance()->Load(g_SoundNames[i].szFilename.c_str(), g_SoundNames[i].szName.c_str());
	}
#endif
	STX_CATCH;
	return 0;


	// ----- Main Loop -----
	}
Exemplo n.º 3
0
		virtual int init(unsigned int width, unsigned int height)
		{
			STX_INIT_SEGVCATCH;
			STX_TRY;
			g_pIndieLib = mI = CIndieLib::Instance();
	// ----- IndieLib intialization -----

#if 0
	//CIndieLib * mI = CIndieLib::Instance();
	if (!CIndieLib::Instance()->Init ()) return 0;
#else
	
	mI = CIndieLib::Instance();
	if (!CIndieLib::Instance()->
		Init (
		"IndieLib-Transitions"
		)) return -1;
#endif

	// Loading layer 1
	//////////IND_Timer timer;
	if (!mI->SurfaceManager->Add (&SurfaceSnake, "/IndieLib-Transitions/snake_512.jpg", IND_ALPHA, IND_32)) return 0;

	// Loading layer 1
	//////////IND_Timer timer;
	if (!mI->SurfaceManager->Add (&SurfacePool, "/IndieLib-Transitions/pool_512.jpg", IND_ALPHA, IND_32)) return 0;

	// ----- Font creation -----
	// Font (layer 3)
	//////////IND_Timer timer;
	if (!mI->FontManager->Add (&FontSmall, "/IndieLib-Transitions/font_small.png", "/IndieLib-Transitions/font_small.xml", IND_ALPHA, IND_32)) return 0;

	// Create the Font
	//////////IND_Timer timer;
	mI->Entity2dManager->Add		(1, &TextSmallWhite);		// Entity adding (Layer 3)
	TextSmallWhite.SetFont			(&FontSmall);				// Set the font into the entity
	TextSmallWhite.SetLineSpacing	(18);
	TextSmallWhite.SetCharSpacing	(-8);
	TextSmallWhite.SetPosition		(5, 5, 1);
	TextSmallWhite.SetAlign		(IND_LEFT);

	// Creating 2d entity for the pool
	g_pSourceEntity2d = new IND_Entity2d();
	mI->Entity2dManager->Add (0, g_pSourceEntity2d);			// Entity adding !!! Note the first parameter is layer #
	g_pSourceEntity2d->SetSurface (&SurfacePool);				// Set the surface into the entity

	// Creating 2d entity for the snake
	g_pDestEntity2d	= new IND_Entity2d();
	mI->Entity2dManager->Add (0, g_pDestEntity2d);			// Entity adding !!! Note the first parameter is layer #
	g_pDestEntity2d->SetSurface (&SurfaceSnake);			// Set the surface into the entity
	g_pDestEntity2d->SetPosition(0, 0, 0);


	//////////IND_Timer timer;

	g_szTitle = "ALPHA2";
	
	// ----- Main Loop -----

	timer.Start();

	// Create the first transition
	g_pMainTransition = new Transition(g_pSourceEntity2d, g_pDestEntity2d, ALPHA2, g_pSourceEntity2d->GetSurface()->GetWidth(), g_pSourceEntity2d->GetSurface()->GetHeight());
	STX_CATCH;
	return 0;


	}