コード例 #1
0
ファイル: Menu.cpp プロジェクト: Adamska/Bomberman
void	Menu::cup_ia_(gdl::Image tmp)
{
  tmp.bind();
  glEnable(GL_BLEND);
  glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
  glPushMatrix();
  glTranslatef(0,-700,0);
  glBegin(GL_QUADS);
  glTexCoord2d(0, 1); glVertex3f(-500, -500, 0);
  glTexCoord2d(0, 0); glVertex3f(-500, 500, 0);
  glTexCoord2d(1, 0); glVertex3f(500, 500, 0);
  glTexCoord2d(1, 1); glVertex3f(500, -500, 0);
  glEnd();
  glDisable(GL_BLEND);
  glPopMatrix();    
}
コード例 #2
0
ファイル: Bonus.cpp プロジェクト: tolsac/bomberman
void	Bonus::draw(gdl::Image& texture)
{
  texture.bind();
  glPushMatrix();
  glTranslatef(this->position.x, this->position.y, 0.0f);
  glRotatef(turn, 0.0f, 0.0f, 1.0f);
  glBegin(GL_QUADS);
  turn += 0.2;
  glTexCoord2f(0.0f, 0.0f);
  glVertex3f(-((BLOCKSIZE - 5) / 3), ((BLOCKSIZE - 5) / 3), ((BLOCKSIZE - 5) / 3));
  glTexCoord2f(0.0f, 1.0f);
  glVertex3f(-((BLOCKSIZE - 5) / 3), -((BLOCKSIZE - 5) / 3), ((BLOCKSIZE - 5) / 3));
  glTexCoord2f(1.0f, 1.0f);
  glVertex3f(((BLOCKSIZE - 5) / 3), -((BLOCKSIZE - 5) / 3), ((BLOCKSIZE - 5) / 3));
  glTexCoord2f(1.0f, 0.0f);
  glVertex3f(((BLOCKSIZE - 5) / 3), ((BLOCKSIZE - 5) / 3), ((BLOCKSIZE - 5) / 3));

  glTexCoord2f(0.0f, 0.0f);
  glVertex3f(((BLOCKSIZE - 5) / 3), ((BLOCKSIZE - 5) / 3), -((BLOCKSIZE - 5) / 3));
  glTexCoord2f(0.0f, 1.0f);
  glVertex3f(((BLOCKSIZE - 5) / 3), -((BLOCKSIZE - 5) / 3), -((BLOCKSIZE - 5) / 3));
  glTexCoord2f(1.0f, 1.0f);
  glVertex3f(-((BLOCKSIZE - 5) / 3), -((BLOCKSIZE - 5) / 3), -((BLOCKSIZE - 5) / 3));
  glTexCoord2f(1.0f, 0.0f);
  glVertex3f(-((BLOCKSIZE - 5) / 3), ((BLOCKSIZE - 5) / 3), -((BLOCKSIZE - 5) / 3));

  glTexCoord2f(0.0f, 0.0f);
  glVertex3f(((BLOCKSIZE - 5) / 3), ((BLOCKSIZE - 5) / 3), ((BLOCKSIZE - 5) / 3));
  glTexCoord2f(0.0f, 1.0f);
  glVertex3f(((BLOCKSIZE - 5) / 3), -((BLOCKSIZE - 5) / 3), ((BLOCKSIZE - 5) / 3));
  glTexCoord2f(1.0f, 1.0f);
  glVertex3f(((BLOCKSIZE - 5) / 3), -((BLOCKSIZE - 5) / 3), -((BLOCKSIZE - 5) / 3));
  glTexCoord2f(1.0f, 0.0f);
  glVertex3f(((BLOCKSIZE - 5) / 3), ((BLOCKSIZE - 5) / 3), -((BLOCKSIZE - 5) / 3));

  glTexCoord2f(0.0f, 0.0f);
  glVertex3f(-((BLOCKSIZE - 5) / 3), ((BLOCKSIZE - 5) / 3), ((BLOCKSIZE - 5) / 3));
  glTexCoord2f(0.0f, 1.0f);
  glVertex3f(-((BLOCKSIZE - 5) / 3), ((BLOCKSIZE - 5) / 3), -((BLOCKSIZE - 5) / 3));
  glTexCoord2f(1.0f, 1.0f);
  glVertex3f(-((BLOCKSIZE - 5) / 3), -((BLOCKSIZE - 5) / 3), -((BLOCKSIZE - 5) / 3));
  glTexCoord2f(1.0f, 0.0f);
  glVertex3f(-((BLOCKSIZE - 5) / 3), -((BLOCKSIZE - 5) / 3), ((BLOCKSIZE - 5) / 3));

  glTexCoord2f(0.0f, 0.0f);
  glVertex3f(-((BLOCKSIZE - 5) / 3), -((BLOCKSIZE - 5) / 3), ((BLOCKSIZE - 5) / 3));
  glTexCoord2f(0.0f, 1.0f);
  glVertex3f(-((BLOCKSIZE - 5) / 3), -((BLOCKSIZE - 5) / 3), -((BLOCKSIZE - 5) / 3));
  glTexCoord2f(1.0f, 1.0f);
  glVertex3f(((BLOCKSIZE - 5) / 3), -((BLOCKSIZE - 5) / 3), -((BLOCKSIZE - 5) / 3));
  glTexCoord2f(1.0f, 0.0f);
  glVertex3f(((BLOCKSIZE - 5) / 3), -((BLOCKSIZE - 5) / 3), ((BLOCKSIZE - 5) / 3));

  glTexCoord2f(0.0f, 0.0f);
  glVertex3f(-((BLOCKSIZE - 5) / 3), ((BLOCKSIZE - 5) / 3), ((BLOCKSIZE - 5) / 3));
  glTexCoord2f(0.0f, 1.0f);
  glVertex3f(((BLOCKSIZE - 5) / 3), ((BLOCKSIZE - 5) / 3), ((BLOCKSIZE - 5) / 3));
  glTexCoord2f(1.0f, 1.0f);
  glVertex3f(((BLOCKSIZE - 5) / 3), ((BLOCKSIZE - 5) / 3), -((BLOCKSIZE - 5) / 3));
  glTexCoord2f(1.0f, 0.0f);
  glVertex3f(-((BLOCKSIZE - 5) / 3), ((BLOCKSIZE - 5) / 3), -((BLOCKSIZE - 5) / 3));

  glEnd();
  glPopMatrix();
}
コード例 #3
0
ファイル: main.cpp プロジェクト: Lameguy64/mtek-gdl-examples
// 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);

}