示例#1
0
文件: title.c 项目: akien-mga/tbftss
static void logic(void)
{
	handleKeyboard();
	
	scrollBackground(0, 0.25);
	
	doStars(0, -0.5);
	
	earth.y += 0.1;
	
	if (earth.y > SCREEN_HEIGHT + 128)
	{
		earth.x = rand() % SCREEN_WIDTH;
		earth.y = -(128 + (rand() % 128));
	}
	
	doFighters();
	
	doEffects();
	
	app.doTrophyAlerts = 1;
	
	if (show == SHOW_FIGHTER_DB)
	{
		doFighterDatabase();
	}
	
	doWidgets();
}
void LLPostProcess::apply(unsigned int width, unsigned int height)
{
	if (!initialized || width != screenW || height != screenH){
		initialize(width, height);
	}
	if (shadersEnabled()){
		doEffects();
	}
}
void LLPostProcess::apply(unsigned int width, unsigned int height)
{
	if(shadersEnabled())
	{
		if (mVBO.isNull() || width != mScreenWidth || height != mScreenHeight)
		{
			initialize(width, height);
		}
		doEffects();
	}
}
void LLPostProcess::renderEffects(unsigned int width, unsigned int height)
{
	for(std::list<LLPointer<LLPostProcessShader> >::iterator it=mShaders.begin();it!=mShaders.end();++it)
	{
		if((*it)->isEnabled())
		{
			if (mVBO.isNull() || width != mScreenWidth || height != mScreenHeight)
			{
				initialize(width, height);
			}
			doEffects();
			return;
		}
	}
}
示例#5
0
文件: title.c 项目: LibreGames/tbftss
static void logic(void)
{
	handleKeyboard();
	
	scrollBackground(0, 0.25);
	
	doStars(0, -0.5);
	
	earth.y += 0.1;
	
	if (earth.y > SCREEN_HEIGHT + 128)
	{
		earth.x = rand() % SCREEN_WIDTH;
		earth.y = -(128 + (rand() % 128));
	}
	
	doFighters();
	
	doEffects();
	
	doWidgets();
}
示例#6
0
// Main function
int main() {


	// Init and load stuff
	init();


	bool plotPressed=false;
    bool killPressed=false;
	bool exitPressed=false;
	bool doParticle=false;
	bool doneMusicPlay=false;

	float endCount=0;
	short explosion=0;


	// Put first cirra sprite
	putCirra(gdl::ScreenCenterX, gdl::ScreenCenterY, 100);


	// Main loop
	while(1) {


		// Get player input
        doPlayerInput();

		if (ending == false) {

			// Drop a Cirra into the field
			if (playerInput.mouseLB) {

				if (plotPressed==false) {

					putCirra(playerInput.pointerX, playerInput.pointerY, 100);
					//plotPressed=true;

				}

			} else {

				plotPressed=false;

			}

			// Kill a Cirra
			if (playerInput.mouseRB) {

				if (killPressed==false) {

					// Simple bounding box search, too lazy to add sorting but it works
					for (int s=0; s<numCirras; s++) {
						if (onSprite(playerInput.pointerX, playerInput.pointerY, cirra[s].x, cirra[s].y, sprites.SpriteInfo(CIRRA_DOWN))) {
							sound[1].Play2D(1.f + ((0.6f*((float)rand()/RAND_MAX))-0.2f), 100.f, cirra[s].x-gdl::ScreenCenterX, cirra[s].y-gdl::ScreenCenterY);
							killCirra(s);
							break;
						}
					}

					//killPressed=true;

				}

			} else {

				killPressed=false;

			}

		}


		// Initiate end sequence (blowing up all Cirras :) )
		#ifdef PLATFORM_PC
		if ((playerInput.exitGame) || gdl::pc::WindowShouldClose()) {
		#else
		if (playerInput.exitGame) {
		#endif

			if (exitPressed == false) {

				if (ending == false) {

					sound[2].Play(1.f, 100.f);

					tnt.active = true;
					tnt.x = gdl::ScreenCenterX;
					tnt.y = gdl::ScreenCenterY;
					tnt.a = 100;
					tnt.aMove = 0;
					tnt.duration = 0;
					ending = true;

					#ifdef PLATFORM_PC
                    glfwSetWindowShouldClose(gdl::pc::WindowContext, false);
					#endif

				} else {

					#ifdef PLATFORM_PC
					break;
					#else
					gdl::wii::Exit();
					#endif

				}

			}

			exitPressed = true;

		} else {

			exitPressed = false;

		}


		// Prepare to draw stuff
		gdl::PrepDisplay();


		// Reset sprite entry count and clear ordering table
        numSpriteEntries=0;
        memset(spriteOT, 0x00, sizeof(void*)*OT_LENGTH);


		// Do TNT animation
		if (tnt.active) {

			if (tnt.a > 0) {
				tnt.aMove += - (0.2f*gdl::Delta);
				tnt.a += (tnt.aMove*gdl::Delta);
				if (tnt.a <= 0) tnt.a = 0;
			} else {
				tnt.a = 0;
			}

			addSprite(tnt.x, tnt.y-1, 0, SHADOW);
			addSprite(tnt.x, tnt.y, tnt.a, TNT);

			doParticle ^= 1;
			if (doParticle) {
				putFireParticle(tnt.x, tnt.y, tnt.a+13);
				putFireParticle(tnt.x+1, tnt.y, tnt.a+13);
			}

			tnt.duration += (1.f*gdl::Delta);

			// Detonate!
			if (tnt.duration > 240) {

				// Kill all cirras when the TNT explodes
				while(numCirras) killCirra(0);

				sound[3].Play(1.f, 100.f);

				explosion = 2;
				endCount = 1;
				tnt.active = false;

			}

		}


		// Do Cirra entities
		doCirras();
        doEffects();


		// Draw sprites inside ordering table
        drawSpriteOT();


		// Draw pointer (only on Wii platform)
		#ifdef PLATFORM_WII
		if ((ending == false) && (playerInput.pointerOnScreen)) {
			pointer.Put(playerInput.pointerX, playerInput.pointerY, gdl::Color::White, 4, 0, 1, Wiimote[0].data.ir.angle);
		}
		#endif


		// Draw instruction text
		if (ending == false) {

			#ifdef GDL_PLATFORM_WII

			font.Printf(9, 17, 1.f, gdl::Color::Black, "Press A to plot, B to kill.");
			font.Printf(8, 16, 1.f, gdl::Color::White, "Press A to plot, B to kill.");
			font.Printf(9, 33, 1.f, gdl::Color::Black, "Press Home or Reset to exit...");
			font.Printf(8, 32, 1.f, gdl::Color::White, "Press Home or Reset to exit...");

			#else

			font.Printf(9, 7, 1.f, gdl::Color::Black, "Press LMB to plot, RMB to kill.");
			font.Printf(8, 6, 1.f, gdl::Color::White, "Press LMB to plot, RMB to kill.");
			font.Printf(9, 23, 1.f, gdl::Color::Black, "Press Escape or Close to exit...");
			font.Printf(8, 22, 1.f, gdl::Color::White, "Press Escape or Close to exit...");

			#endif // GDL_PLATFORM_WII

		}


		// Do TNT sequence
		if (endCount) {

			if ((endCount > 10) && (doneMusicPlay == false)) {

				// Play 'gameover' music
				gdl::PlayMusic("testdata/gameover.ogg", false);
				doneMusicPlay = true;

			}

			if (endCount > 60) {

				//sprites.PutX(gdl::ScreenCenterX, gdl::ScreenCenterY, GAMEOVER, gdl::Pivot, gdl::Pivot, 0, 4, gdl::Color::White);

				sprites.Put(gdl::ScreenCenterX, gdl::ScreenCenterY, GAMEOVER, gdl::Color::White, gdl::Pivot, gdl::Pivot, 4.f);

				#ifdef GDL_PLATFORM_WII
				font.Printf(gdl::Centered, gdl::ScreenYres-69, 1.f, gdl::Color::Black, "Press Home or Reset again to exit");
				font.Printf(gdl::Centered, gdl::ScreenYres-70, 1.f, gdl::Color::White, "Press Home or Reset again to exit");
				#else
				font.Printf(gdl::Centered, gdl::ScreenYres-69, 1.f, gdl::Color::Black, "Press Escape or Close again to exit");
				font.Printf(gdl::Centered, gdl::ScreenYres-70, 1.f, gdl::Color::White, "Press Escape or Close again to exit");
				#endif

			}

			if (endCount <= 60) endCount += 1.f*gdl::Delta;

		}


		// Simple flash effect for the TNT explosion
		if (explosion) {

			gdl::DrawBoxF(0, 0, gdl::ScreenXres-1, gdl::ScreenYres-1, gdl::Color::White);
			explosion--;

		}


		// Display stuff
		gdl::Display();


	}


}


// Init function
void init() {


	#ifdef GDL_PLATFORM_WII

	// Init code for Wii
	fatInitDefault();
	gdl::InitSystem(gdl::ModeAuto, gdl::AspectAuto, gdl::LowRes);

    WPAD_Init();
	InitWiimotes(1);

	#else

	// Init code for PC
	gdl::Init("Whack-a-Cirra", 427, 240, 32, 0, 0, 2);

	#endif


	// Set clear color
	gdl::SetClearColor(0, 63, 127, 255);


    #ifdef GDL_PLATFORM_WII

	// Set console mode and load pointer image
	gdl::ConsoleMode();
	if (!pointer.LoadImage("testdata/pointer.png", gdl::Nearest, gdl::RGB5A3))
		exit(0);

	#else

	// Step back a directory on PC
	chdir("../..");

	#endif


	// Load font
	if (!fontImage.LoadImage("testdata/font8x16.png", gdl::Nearest, gdl::RGB5A3))
		exit(0);

	font.BindSheet(fontImage, 8, 16);

	// Load sprites
	if (!sprites.LoadSprites("testdata/test_sprites.tsm", "testdata/", gdl::Nearest, gdl::RGB5A3))
		exit(0);

	// Load sound effects
    if (!sound[0].LoadSound("testdata/hitfloor.wav"))
		exit(0);
    if (!sound[1].LoadSound("testdata/smack.wav"))
		exit(0);
	if (!sound[2].LoadSound("testdata/fuse.wav"))
		exit(0);
	if (!sound[3].LoadSound("testdata/explode.wav"))
		exit(0);

}