Ejemplo n.º 1
0
// checks if score is greater than zero to decide winner //
void WinLose(int &redScore, int &blueScore, bool &winLose, bool &quit)
{
	static char cWinText[128] = {'\n'};
	static char cOptionsText[128] = {'\n'};
	if(redScore >= 5)
	{
		winLose = true;
		sprintf_s(cWinText, "You Won! Play again?");
		sprintf_s(cOptionsText, "Y / N");
		DrawString(cWinText, 520, 300, SColour(0,255,0,255));
		DrawString(cOptionsText, 620, 345, SColour(0,255,0,255));
	}
	else if(blueScore >= 5)
	{
		winLose = true;
		sprintf_s(cWinText, "You Lost.. Play again?");
		sprintf_s(cOptionsText, "Y / N");
		DrawString(cWinText, 520, 300, SColour(0,255,0,255));
		DrawString(cOptionsText, 620, 345, SColour(0,255,0,255));
	}
	if(IsKeyDown('Y'))
	{
		winLose = false;
		redScore = 0;
		blueScore = 0;
	}
	else if(IsKeyDown('N'))
	{
		quit = true;
	}


}
Ejemplo n.º 2
0
// draws each frame of the game
void drawGame() {
	static char outScore1[15] = {'\n'};
	static char outScore2[15] = {'\n'};

	DrawSprite(ball.sprite);
	DrawSprite(player1.sprite);
	DrawSprite(player2.sprite);

	sprintf(outScore1, "Player 1: %d", player1Score);
	sprintf(outScore2, "Player 2: %d", player2Score);
	// draw the scores
	DrawString(outScore1, 50, 50, SColour(255,0,0,255));
	DrawString(outScore2, 1000, 50, SColour(0,255,0,255));

	if(g_gameOver == true) {
		DrawString("Game Over", SCREEN_X / 2, 300);

		char score[15];
		int y = 350;
		for(int i=0; i<5; i++) {
			if(g_highScores[i] != 0) {
				sprintf(score, "player %d: %d", i, g_highScores[i]);
				DrawString(score, SCREEN_X / 2, y);
				y += 30;
			}
		}
	}

	DrawSprite(bgImage);
}
Ejemplo n.º 3
0
//draw each frame of the game
void drawGame()
{
	static char s_cOutScore1[15] = {'\n'};
	static char s_cOutScore2[15] = {'\n'};

	//DrawSprite(g_uiBgImage);

	DrawSprite(g_ball.iSprite);
	DrawSprite(g_player1.iSprite);
	DrawSprite(g_player2.iSprite);

	sprintf(s_cOutScore1, "Player 1: %d", g_iPlayer1Score);
	sprintf(s_cOutScore2, "Player 2: %d", g_iPlayer2Score);
	//draw the scores
	DrawString(s_cOutScore1, 50, 50, SColour(255,0,0,255));
	DrawString(s_cOutScore2, 1000, 50, SColour(0,255,0,255));

	if(g_iFrameCounter >= 20 && g_bPowerUpVis != true )
	{
		g_bPowerUpVis = true;
	}

	if( g_bPowerUpVis = true )
	{
		if( updatePowerUp(g_powerUp,g_ball,g_player1,g_bPowerUpVis) )
		{
			DrawSprite(g_powerUp.iSprite);
		}
	}

	if(g_bGameOver == true)
	{
		DrawString("Game Over", SCREEN_X / 2, 300);

		char acScore[15];
		int iY = 350;
		for(int i = 0; i < 5; i++)
		{
			if(g_aiHighScores[i] != 0 )
			{
				sprintf(acScore, "player %d: %d", i+1, g_aiHighScores[i]);
				DrawString(acScore, SCREEN_X / 2, iY);
				iY += 30;
			}
		}

		vector2 v2BallPosition = {SCREEN_X / 2, 300};
		g_ball.v2Position = v2BallPosition;
		DestroySprite(g_ball.iSprite);
		DrawSprite(g_ball.iSprite);
		g_ball.v2Speed.fX = 0;
		g_ball.v2Speed.fY = 0;

	}

	
}
Ejemplo n.º 4
0
void CEntity::RenderBars()
{
	if( !m_base->m_barsEnabled || !m_bounds || !m_visible)
		return;

	SnapToGround();
	CVector3D centre = m_graphics_position;
	centre.Y += m_base->m_barOffset;
	CVector3D up = g_Game->GetView()->GetCamera()->m_Orientation.GetUp();
	CVector3D right = -g_Game->GetView()->GetCamera()->m_Orientation.GetLeft();

	float w = m_base->m_barWidth;
	float h = m_base->m_barHeight;
	float borderSize = m_base->m_barBorderSize;

	// Draw the health and stamina bars; if the unit has no stamina, the health bar is
	// drawn centered, otherwise it's offset slightly up and the stamina bar is offset
	// slightly down so that they overlap over an area of size borderSize.

	bool hasStamina = (m_staminaMax > 0);

	float backgroundW = w+2*borderSize;
	float backgroundH = hasStamina ? 2*h+2*borderSize : h+2*borderSize;
/*
	ogl_tex_bind( g_Selection.m_unitUITextures[m_base->m_barBorder] );
	DrawRect( centre, up, right, -backgroundW/2, -backgroundH/2, backgroundW/2, backgroundH/2 );
*/
	ogl_tex_bind( 0 );

	float off = hasStamina ? h/2 : 0;
	DrawBar( centre, up, right, -w/2, off-h/2, w/2, off+h/2, 
			SColour(0,1,0), SColour(1,0,0), m_healthCurr, m_healthMax );

	if( hasStamina ) 
	{
		DrawBar( centre, up, right, -w/2, -h, w/2, 0, 
				SColour(0,0,1), SColour(0.4f,0.4f,0.1f), m_staminaCurr, m_staminaMax );
	}

	// Draw the rank icon

/*
	CSelectedEntities::MapFilenameToHandle::iterator it = g_Selection.m_unitUITextures.find( m_rankName );
	if( it != g_Selection.m_unitUITextures.end() )
	{
		float size = 2*h + borderSize;
		ogl_tex_bind( it->second );
		DrawRect( centre, up, right, w/2+borderSize, -size/2, w/2+borderSize+size, size/2 );
		ogl_tex_bind( 0 );
	}
*/
}
Ejemplo n.º 5
0
// draws objects and text to screen each frame //
void DrawGame(DynamObject &redPaddle, DynamObject &bluePaddle, DynamObject &ball, int &redScore, int &blueScore)
{
	static char cOutScoreBlue[15] = {'\n'};
	static char cOutScoreRed[15] = {'\n'};
	DrawSprite(bgImage);
	DrawSprite(redPaddle.sprite);
	DrawSprite(bluePaddle.sprite);
	DrawSprite(ball.sprite);
	sprintf_s(cOutScoreRed, "Player RED: %d", redScore);
	sprintf_s(cOutScoreBlue, "Player BLUE: %d", blueScore);
	DrawString(cOutScoreBlue, 1000, 50, SColour(0,255,0,255));
	DrawString(cOutScoreRed, 50, 50, SColour(255,0,0,255));
}
Ejemplo n.º 6
0
void HermiteSpline::Draw()
{
	DrawString("Hermite Spline Demo", screenWidth * 0.5f - 200, screenHeight * 0.9f);

	SColour color = SColour(0, 255, 0, 255);

	Vector2 p0 = GetSprite("start")->position;
	Vector2 p1 = GetSprite("end")->position;
	Vector2 t0 = GetSprite("p01")->position;
	Vector2 t1 = GetSprite("p02")->position;

	//draw curve
	for (int i = 0; i < 100; i++)
	{
		float t = i / 100.0f;
		float nextT = (i + 1) / 100.0f;

		Vector2 start = Vector2::HermiteSpline(p0, p1, t0, t1, t);
		Vector2 end = Vector2::HermiteSpline(p0, p1, t0, t1, nextT);

		DrawLine(start.x, start.y, end.x, end.y, color);
	}

	//draw sprites
	for (int i = 0; i < objectList.size(); i++)
	{
		Sprite* object = objectList[i];
		MoveSprite(object->ID, object->position.x, object->position.y);
		DrawSprite(object->ID);
	}

	DrawString("<M> to return to MENU", screenWidth * 0.5f - 200, 50);
}
Ejemplo n.º 7
0
//////////////////////////////////////////////////////////////////////////
// Call this function to Set the background colour
//////////////////////////////////////////////////////////////////////////
PyObject* AIE_SetBackgroundColour(PyObject *self, PyObject *args)
{
	int iRed; int iBlue; int iGreen; int iAlpha;
	if (!PyArg_ParseTuple(args, "iiii", &iRed, &iBlue, &iGreen, &iAlpha)) 
	{
		ParsePyTupleError( __func__, __LINE__ );
		return nullptr;
	}
	SetBackgroundColour(SColour( iRed, iBlue, iGreen, iAlpha ));
	Py_RETURN_NONE;
}
Ejemplo n.º 8
0
void UpdateGameState(){
	float fDeltaT = GetDeltaTime();
	//draw cannon to screen
	DrawSprite(player.spriteId);
	MoveSprite(player.spriteId, player.x, player.y);

	//draw scores to screen
	DrawString("SCORE < 1 >", iScreenWidth * 0.025f, iScreenHeight - 2);
	DrawString("HIGH SCORE", iScreenWidth * 0.4f, iScreenHeight - 2);
	DrawString("SCORE < 2 >", iScreenWidth * 0.75f, iScreenHeight - 2);
	DrawString("CREDIT 00", iScreenWidth *.7f, iScreenHeight * .05f);
	DrawString("Lives", iScreenWidth *.075f, iScreenHeight * .05f);
	DrawLine(32.f, 45.f, 640.f, 45.f, SColour(0x00, 0xFC, 0x00, 0xFF));

	//draw aliens to screen
	for (int i = 0; i < 18; i++)
	{
		DrawSprite(Aliens[i].spriteId);
		Aliens[i].Move(fDeltaT, 1);
		if (Aliens[i].x <= Aliens[i].min + Aliens[i].width * .5f)
		{
			for (int a = 0; a < 6; a++)
			{
				Aliens[i + a].y = Aliens[i].y;
				DrawSprite(Aliens[i + a].spriteId);
				Aliens[i + a].direction = Aliens[i].direction;
				//Aliens[i + a].speed += 100;
				//Aliens[i + a].Move(fDeltaT, 1);
			}
			i += 6;
			//Aliens[i].tracker == false;
		}
		Aliens[i].SetMoveExtremes(32.f, 625.f);
		//cout << Aliens[i].max;
		if (Aliens[i].x >= Aliens[i].max /*+ Aliens[i].width * .5f*/)
		{
			for (int a = 0; a < 6; a++)
			{
				Aliens[i - a].y = Aliens[i].y;
				DrawSprite(Aliens[i - a].spriteId);
				Aliens[i - a].direction = Aliens[i].direction;
				//Aliens[i + a].speed += 100;
				//Aliens[i + a].Move(fDeltaT, 1);
			}
			i += 6;
		}
	}
}
Ejemplo n.º 9
0
int main(int argc, char* argv[])
{

	//\ Lets initialise the AIE Framework and give the window it creates an appropriate title
	Initialise(iScreenWidth, iScreenHeight, false, "One of Piece");
	SetBackgroundColour(SColour(0x00, 0x00, 0x00, 0xFF));
	AddFont("./fonts/invaders.fnt");

	g_AssetManager.Load("Player", "./images/invaders/luffyPlayer.png", 40, 64);
	g_AssetManager.Load("Bullet", "./images/invaders/chopperBullet.png", 24, 36);
	g_AssetManager.Load("Enemy", "./images/invaders/tumblrEnemy.png", 36, 42);
	g_AssetManager.Load("BG", "./images/invaders/OPbackground.png", iScreenWidth, iScreenHeight);
	g_AssetManager.Load("GameBG", "./images/invaders/Logo (2).png", iScreenWidth, iScreenHeight);
	g_AssetManager.Load("VicBG", "./images/invaders/Luffy_One_Piece_Chibi.png", 400, 500);

	new Player();
	Entity::init();
	GameState ecurrentState = gs_MENU;
	ScoreDB &ref = ScoreDB::getInstance();


	ref.Open();
	//ScoreData myScore = { 0, "Your Timer: " };


	do
	{
		ClearScreen();
		float fDeltaT = GetDeltaTime();

		SetFont("./fonts/invaders.fnt");
		Playgame(fDeltaT);
		
		std::string timeFrame = "DeltaTime: ";
		timeFrame.append(std::to_string(fDeltaT));
		SetFont(nullptr);

	} while (FrameworkUpdate() == false && running);

	ref.Close();
	g_AssetManager.FreeAll();
	Shutdown();

	return 0;
}
Ejemplo n.º 10
0
BeerPongGame::BeerPongGame()
{
	settings = FileSettings::Instance();
	
	//\ Lets initialise the AIE Framework and give the window it creates an appropriate title
	Initialise( settings->GetInt("SCREEN_W"), settings->GetInt("SCREEN_H"), false, "BEER PONG SIMULATOR 2015" );
	SetBackgroundColour( SColour( 0x00, 0x00, 0x00, 0xFF ) );
	//AddFont( "./fonts/invaders.fnt" );
	//\Now lets create the sprite for our players cannon. That's right in space invaders we control a cannon
	//\So lets create that with an appropriate variable name and move it to a suitable location (say the middle of our screen)
	stateSelection = 0;
	currentState = new Menu();

	inputHelper.RegisterCallback(&MyKeyEvent, this);
	inputHelper.AddKey(KEY_ESCAPE);
	inputHelper.AddKey(KEY_SPACE);
	inputHelper.AddKey(KEY_ENTER);
}
Ejemplo n.º 11
0
int main( int argc, char* argv[] )
{	

	Initialise( iScreenWidth, iScreenHeight, false, "Just Another Retro Pew Pew" );
	SetBackgroundColour( SColour( 000, 000, 000, 000 ) );

//	player.SetSpriteID(CreateSprite( "./images/player.png", player.GetWidth(), player.GetHeight(), true));

	GameStates eCurrentState = eMAIN_MENU;

	do 
	{
		ClearScreen();
		float fDeltaT = GetDeltaTime();
		switch (eCurrentState)
		{
	case eMAIN_MENU:
		UpdateMainMenu();
			if( IsKeyDown( KEY_ENTER) )
			{
				eCurrentState = eGAMEPLAY;
				
			
			}
			break;
	case eGAMEPLAY:
		UpdateGameState();
		if( IsKeyDown( KEY_ESCAPE) )
			{
				eCurrentState = eMAIN_MENU;

			}

		break;
	default:
		break;
		}
			
	} while ( FrameworkUpdate() == false );

	Shutdown();

	return 0;
}
Ejemplo n.º 12
0
void DrawGameState() {
	//draw sprites
	player.draw();

	for (int i = 0; i < enemyArrLength; i++) {
		alienShips[i].draw();
	}

	DrawLine(0, 40, ScreenWidth, 40, SColour(0x00, 0xFC, 0x00, 0xFF)); //doesn't acctually draw anything?

	//drawstrings
	SetFont(pInvadersFont);
	DrawString("SCORE < 1 >", ScreenWidth * 0.025f, ScreenHeight - 2);
	DrawString("0000", ScreenWidth * 0.11f, ScreenHeight - 32);
	DrawString("HI-SCORE", ScreenWidth * 0.35f, ScreenHeight - 2);
	DrawString("0020", ScreenWidth * (0.05f + 0.35f), ScreenHeight - 32);
	DrawString("SCORE < 2 >", ScreenWidth * 0.65f, ScreenHeight - 2);
	DrawString("0000", ScreenWidth * (0.05f + 0.65f), ScreenHeight - 32);
}
Ejemplo n.º 13
0
void LERPState::Draw()
{
	DrawString("LERP Demo", screenWidth * 0.5f - 100, screenHeight * 0.9f);

	SColour color = SColour(0, 255, 0, 255);

	Vector2 p0 = objectList[0]->position;
	Vector2 p1 = objectList[1]->position;

	DrawLine(p0.x, p0.y, p1.x, p1.y, color);

	//draw sprites
	for (int i = 0; i < objectList.size(); i++)
	{
		Sprite* object = objectList[i];
		MoveSprite(object->ID, object->position.x, object->position.y);
		DrawSprite(object->ID);
	}

	DrawString("<M> to return to MENU", screenWidth * 0.5f - 200, 50);

}
Ejemplo n.º 14
0
void UpdateGameState(float deltaTime) {

	player.Move(deltaTime, SPEED);
	MoveEnemies(deltaTime);

	//draw sprites
	DrawSprite(player.iSpriteID);

	for (int i = 0; i < enemyArr1Length; i++) {
		for (int j = 0; j < enemyArr2Length; j++) {
			DrawSprite(alienShips[i][j].iSpriteID);
		}
	}

	DrawLine(0, 40, iScreenWidth, 40, SColour(0x00, 0xFC, 0x00, 0xFF)); //doesn't acctually draw anything?

	//drawstrings
	SetFont(pInvadersFont);
	DrawString("SCORE < 1 >", iScreenWidth * 0.025f, iScreenHeight - 2);
	DrawString("0000", iScreenWidth * 0.11f, iScreenHeight - 32);
	DrawString("HI-SCORE", iScreenWidth * 0.35f, iScreenHeight - 2);
	DrawString("0020", iScreenWidth * (0.05f + 0.35f), iScreenHeight - 32);
	DrawString("SCORE < 2 >", iScreenWidth * 0.65f, iScreenHeight - 2);
}
Ejemplo n.º 15
0
int main( int argc, char* argv[] )
{	

	Initialise(iScreenWidth, iScreenHeight, false, "Space Invaders");
    
	SetBackgroundColour(SColour(0x00, 0x00, 0x00, 0xFF));

	//player settings
	player.SetSize(64.0f, 32.0f);
	player.iSpriteID = CreateSprite("./images/cannon.png", player.fWidth, player.fHeight, true);
	player.SetMovementExtremes(0.0f, iScreenWidth);
	player.SetMovementKeys(65, 68);
	player.x = iScreenWidth * 0.5f;
	player.y = 88.0f;

	//create Marquee sprite
	iArcadeMarquee = CreateSprite("./images/Space-Invaders-Marquee.png", iScreenWidth, iScreenHeight, true);

	//enemy creation
	CreateEnemies();
	enemyDirection = eRIGHT;
	nextDirection = eRIGHT;

	//font setting
	AddFont(pInvadersFont);

	//game state declaration
	GAMESTATES eCurrentState = eMAIN_MENU;

    //Game Loop
    do
    {
		float fDeltaT = GetDeltaTime();

		switch (eCurrentState) {
		case eMAIN_MENU:

			UpdateMainMenu();

			//input
			if (IsKeyDown(257) && !IsKeyDown(256)) {
				eCurrentState = eGAMEPLAY;
				ResetEnemies();
			}

			break;

		case eGAMEPLAY:

			UpdateGameState(fDeltaT);

			//ChangeState
			if (IsKeyDown(256)) {
				eCurrentState = eMAIN_MENU;
			}

			break;

		default:
			break;
		}

		//clear screen
		ClearScreen();


    } while(!FrameworkUpdate());

	Shutdown();

    return 0;
}
Ejemplo n.º 16
0
int main( int arc, char* argv[] )
{	
	// First we need to create our Game Framework
	Initialise( width, height, false );
// Now load some sprites
	unsigned int BackgroundSprite = CreateSprite( "images/background.png", 1280, 780, false );
	unsigned int PaddleLeftSprite = CreateSprite( "images/Paddle.png", 32, 64, true );
	unsigned int PaddleRightSprite = CreateSprite( "images/Paddle.png", 32, 64, true );
	unsigned int BallSprite = CreateSprite( "images/Ball.png", 32, 32, true );
	unsigned int Header = CreateSprite( "images/Header.png", 444, 128, true );

//setup all the variables
	int paddleleftx = 100;
	int paddlelefty = height/2;
	int paddleleftyvar = 0;

	int paddlerightx = width-100;
	int paddlerighty = height/2;
	int paddlerightyvar = 0;
	
	if (xspeed<0){
		bPaddle = 0;}
	else if (xspeed>0){
		bPaddle = 1;
	}
	int iOption = 1;
	int iOptiony = height/2;

//if the ball is in the up/down area, reset it again
	while (xspeed>-2 && xspeed <2){
		srand((unsigned)time(0));	
		xspeed = -5 +(rand() % 10);	
	}
	while (yspeed>-2 && yspeed <2){
		srand((unsigned)time(0));	
		yspeed = -5 +(rand() % 10);	
	}

	glClearColor(0.0f,0.0f,0.0f,0);
	do{

		fDeltaTime = (clock() - fLastTime)/(float)CLOCKS_PER_SEC;
		fLastTime = clock();

		if (!IsKeyDown(GLFW_KEY_SPACE)){
			bCanCheck[0]=true;
		}
		if (!IsKeyDown(GLFW_KEY_ENTER)){
			bCanCheck[1]=true;
		}
		if (!IsKeyDown(GLFW_KEY_BACKSPACE)){
			bCanCheck[2]=true;
		}
		if (!IsKeyDown(GLFW_KEY_UP)){
			bCanCheck[3]=true;
		}
		if (!IsKeyDown(GLFW_KEY_DOWN)){
			bCanCheck[4]=true;
		}
		switch (Menu){
/////////////////////////////////////////////////////////////////////////////////////////////////////GAME CASE////////////////////////////////////////////////////////////////////////////////////////////////////////////
		case 0:
//make sure the game doesnt "flash" with keypress's on menus by clearing all old objects
		ClearScreen();
//controls & movement
		if ( IsKeyDown('W') && paddlelefty>64)      {paddleleftyvar--;}
		if ( IsKeyDown('S') && paddlelefty<height-64) {paddleleftyvar++;}
		
		if ( IsKeyDown(GLFW_KEY_UP) && paddlerighty>64 )      {paddlerightyvar--;} 
		if ( IsKeyDown(GLFW_KEY_DOWN) && paddlerighty<height-64){paddlerightyvar++;}
//left
		if (paddlelefty>=64 && paddlelefty<=height-64){
			paddlelefty += paddleleftyvar * 10.0f * fDeltaTime;
		}else {
			paddleleftyvar = 0; if (paddlelefty>height/2) {paddlelefty=height-64;}else{paddlelefty=64;}
			}
//right
		if (paddlerighty>=64 && paddlerighty<=height-64){
			paddlerighty += paddlerightyvar * 10.0f * fDeltaTime;
		}else {
			paddlerightyvar=0; if (paddlerighty>height/2) {paddlerighty=height-64;}else{paddlerighty=64;}
		}
		ballx += xspeed * 100.0f * fDeltaTime;
		bally += yspeed * 100.0f * fDeltaTime;

//ball collisions
//outside left/right and top/bottom bounce
//add to score
		if (ballx>=width){iScore[1]++;} 
		if (ballx<=0)    {iScore[0]++;}
//reset room
		if (ballx<=0 || ballx>=width){ 
			BallReset();
		}
		if (bally<=0 || bally>=height){
			yspeed *= -1;
		}
//stop the ball going to fast
		if (xspeed>10) {xspeed=10; }
		if (xspeed<-10){xspeed=-10;}
		if (yspeed>10) {yspeed=10; }
		if (yspeed<-10){yspeed=-10;}
//paddle left
		if (ballx<=paddleleftx+16 && bPaddle == 0){
			if       (bally<paddlelefty-28 && bally>paddlelefty-64){
				xspeed *= -3 * 100.0f * fDeltaTime;
				yspeed *= 2 * 100.0f * fDeltaTime;
			}else if (bally<paddlelefty+28 && bally>paddlelefty-28){
				yspeed *= -1 * 100.0f * fDeltaTime;
				xspeed *= -1 * 100.0f * fDeltaTime;
			}else if (bally<paddlelefty+64 && bally>paddlelefty+28){
				xspeed *= -3 * 100.0f * fDeltaTime;
				yspeed *= -2 * 100.0f * fDeltaTime;
			}
		bPaddle = 1;
		}
//paddle right
		if (ballx>=paddlerightx-16 && bPaddle == 1){
			if       (bally<paddlerighty-28 && bally>paddlerighty-64){
				xspeed *= -3;
				yspeed *= 2;
			}else if (bally<paddlerighty+28 && bally>paddlerighty-28){
				yspeed *= -1;
				xspeed *= -1;
			}else if (bally<paddlerighty+64 && bally>paddlerighty+28){
				xspeed *= -3;
				yspeed *= -2;
			}
		bPaddle = 0;
		}
//draw the instances
		DrawSprite(BackgroundSprite);
		MoveSprite( BackgroundSprite, 0, 0);
		DrawSprite(PaddleLeftSprite);
		DrawSprite(PaddleRightSprite);
		DrawSprite(BallSprite);
//draw the middle
		DrawLine(width/2,  0,  width/2,  height,  SColour(0x00,0x00,0x00,0xAA) );
//move the instances
		MoveSprite( PaddleLeftSprite, paddleleftx, paddlelefty );
		MoveSprite( PaddleRightSprite, paddlerightx, paddlerighty);
		MoveSprite( BallSprite, ballx, bally );
//convert the int's to strings and draw thw score
		DrawInt(iScore[0],(width/4)*3, 32);
		DrawInt(iScore[1],(width/4), 32);
//if someone has won, change the screen to say so.
		for (int i = 0; i<=1; i++){
			if (iScore[i] >= 10){
				winner = i;
				Menu = 2;
			}
		}
//debug information
		if (debug==true){
//hitlines
		DrawHitline(paddleleftx+16,paddlelefty);
		DrawHitline(paddlerightx-16,paddlerighty);
//vars	
		std::cout << "paddlelefty : " << paddlelefty<< std::endl;
		std::cout << "paddleleftyvar : " << paddleleftyvar<< std::endl;
		std::cout << "paddlerighty : " << paddlerighty<< std::endl;
		std::cout << "paddlerightyvar : " << paddlerightyvar<< std::endl;
		std::cout << "ballx : " << ballx<< std::endl;
		std::cout << "bally : " << bally<< std::endl;
		std::cout << "xspeed : " << xspeed<< std::endl;
		std::cout << "yspeed : " << yspeed<< std::endl;
		}
//Checks to set the debug to show or no
		if (IsKeyDown(GLFW_KEY_BACKSPACE) && bCanCheck[2] == true){
			if (debug==true ){
				debug=false;
				bCanCheck[2]=false;
			}else if (debug==false){
				debug=true;
				bCanCheck[2]=false;
			}
		}
		//add to the timer
		break;
///////////////////////////////////////////////////////////////////////////////////////////////////MAIN MENU//////////////////////////////////////////////////////////////////////////////////////////////////////////////
		case 1:
			ClearScreen();
			//sets the screen to black
			//draws the information
			DrawSprite(BackgroundSprite);
			MoveSprite( BackgroundSprite, 0, 0);
			DrawSprite(Header);
			MoveSprite( Header, width/2, height/8 );
//fake objects
			MoveSprite( BallSprite, width/2, iOptiony );
			DrawSprite(BallSprite);
			MoveSprite( PaddleLeftSprite, 100, height/2 );
			DrawSprite(PaddleLeftSprite);
			MoveSprite( PaddleRightSprite, width-100, height/2 );
			DrawSprite(PaddleRightSprite);
			DrawString( "Scores", width/2+32, height/2-48 );
			DrawString( "Play Game", width/2+32, height/2-16 );
			DrawString( "Quit",  width/2+32, height/2+16 );
			DrawString( "Controls", (width/2)+32, height/2+48 );

			switch (iOption){
			case 0:
				iOptiony = (height/2)-32;
				break;
			case 1:
				iOptiony = (height/2);
				break;
			case 2:
				iOptiony = (height/2)+32;
				break;
			case 3:
				iOptiony = (height/2)+64;
				break;
			default:
				break;
			}
			if (IsKeyDown(GLFW_KEY_DOWN) && bCanCheck[4] == true){
				bCanCheck[4]=false;
				iOption++;
				if (iOption>3){iOption=0;}
			}
			if (IsKeyDown(GLFW_KEY_UP) && bCanCheck[3] == true){
				bCanCheck[3]=false;
				iOption--;
				if (iOption<0){iOption=3;}
			}
			if (IsKeyDown(GLFW_KEY_ENTER) && bCanCheck[1] == true){
				bCanCheck[1] = false;
				switch (iOption){
				case 0:
					Menu = 2;//goto the highscores
					break;
				case 1:
					//reset the winner and score
					winner=-1;
					iScore[0]=0;
					iScore[1]=0;
					//reset the ball
					BallReset();
					//reset the paddles
					paddlelefty = height/2;
					paddleleftyvar = 0;
					paddlerighty = height/2;
					paddlerightyvar = 0;
					Menu = 0;//goto the game
					break;
				case 2:
					bQuitGame = true;
					break;
				case 3:
					Menu = 3;//goto the Controls Page
					break;
				}
			}			
			//go to game when pressed
		break;
////////////////////////////////////////////////////////////////////////////////////////////////////////WIN SCREEN////////////////////////////////////////////////////////////////////////////////////////////////////////
		case 2:
//draw the win screen
			ClearScreen();
			DrawSprite(BackgroundSprite);
			MoveSprite( BackgroundSprite, 0, 0);
			DrawSprite(Header);
			MoveSprite( Header, width/2, height/8 );
//draw the background pong items
			MoveSprite( BallSprite, width/2, height/2-32 );
			DrawSprite(BallSprite);
			MoveSprite( PaddleLeftSprite, 100, height/2 );
			DrawSprite(PaddleLeftSprite);
			MoveSprite( PaddleRightSprite, width-100, height/2 );
			DrawSprite(PaddleRightSprite);
//draw old menu
			DrawString( "Play Game", width/2+32, height/2-16 );
			DrawString( "Controls", (width/2)+32, height/2+48 );
			DrawString( "Quit", (width/2)+32, height/2+16 );
//draw new items with some indentation
			DrawString( "  Scores", width/2+32, height/2-48 );
			switch (winner){
			case 0:
			DrawString("  Player One Wins", (width/2)+32, height/2-112 );
			break;
			case 1:
			DrawString("  Player Two Wins", (width/2)+32, height/2-112 );
			break;
			}
		DrawString("  Enter to return to the main menu.", (width/2)+32, height/2-80 );
//back to the main menu
		if (IsKeyDown(GLFW_KEY_ENTER) && bCanCheck[1] == true){
				//goto the main menu
				Menu = 1;
				iOptiony = 1;
				bCanCheck[1] = false;
			}
		if (IsKeyDown(GLFW_KEY_DOWN) && bCanCheck[4] == true){
				//goto the main menu
				Menu = 1;
				iOptiony = 1;
				bCanCheck[4] = false;
			}
		break;
///////////////////////////////////////////////////////////////////////////////////////////////////////////CONTROLS//////////////////////////////////////////////////////////////////////////////////////////////////////
		case 3:
		ClearScreen();
//draw the pong background
			DrawSprite(BackgroundSprite);
			MoveSprite( BackgroundSprite, 0, 0);
			DrawSprite(Header);
			MoveSprite( Header, width/2, height/8 );
			
			MoveSprite( BallSprite, width/2, iOptiony );
			DrawSprite(BallSprite);
			MoveSprite( PaddleLeftSprite, 100, height/2 );
			DrawSprite(PaddleLeftSprite);
			MoveSprite( PaddleRightSprite, width-100, height/2 );
			DrawSprite(PaddleRightSprite);
//draw old menu
			DrawString( "Scores", width/2+32, height/2-48 );
			DrawString( "Play Game", width/2+32, height/2-16 );
			DrawString( "Quit", (width/2)+32, height/2+16 );
//draw new items with some indentation
			DrawString( "  Controls", (width/2)+32, height/2+48 );
			DrawString( "  Payer Left, W is up, S is down.", (width/2)+32, height/2+80 );

			DrawString( "  Player Right, Arrow Up is up, Arrow Down is down.",width/2+32, height/2+112 );
			DrawString( "  Enter to return to main menu.", width/2+32, height/2+144 );
//check if up or enter is pressed to go back
		if (IsKeyDown(GLFW_KEY_ENTER) && bCanCheck[1] == true){
				//goto the main menu
				Menu = 1;
				iOptiony = 1;
				bCanCheck[1] = false;
			}
		if (IsKeyDown(GLFW_KEY_UP) && bCanCheck[3] == true){
				//goto the main menu
				Menu = 1;
				iOptiony = 1;
				bCanCheck[3] = false;
			}
		break;
/////////////////////////////////////////////////////////////////////////////////////////////////////DESTROY EVERYTHING//////////////////////////////////////////////////////////////////////////////////////////////////
}
	} while ( FrameworkUpdate() == false && !bQuitGame == true);
//destroy all objects clearing them on game exit
	DestroySprite(PaddleLeftSprite);
	DestroySprite(PaddleRightSprite);
	DestroySprite(BallSprite);
	DestroySprite(Header);
	DestroySprite(BackgroundSprite);
	Shutdown();
//programming signature
	std::cout << "So long, and thanks for all the fish!";
	return 0;
}
Ejemplo n.º 17
0
	void Load( PyObject* a_pModule )
	{
		//"./images/crate_sideup.png", 64.0, 64.0, 0.5, 0.5, 0.0, 0.0, 1.0, 1.0, 255, 255, 255, 255
		float fv2Size[2] = { 64.f, 64.f };
		float fv2Origin[2] = { 0.5f, 0.5f };
		float fv4UVCoords[4] = { 0.f, 0.f, 1.f, 1.f };
		float vColour[4] = { 1.f, 1.f, 1.f, 1.f };

		unsigned int uiSpriteID = CreateSprite( "./images/crate_sideup.png", fv2Size, fv2Origin, fv4UVCoords, SColour(vColour[0]/255, vColour[1]/255, vColour[2]/255, vColour[3]/255) );
	
		PyObject* pLoad = GetHandleToPythonFunction( a_pModule, "PyLoad" );
		if( pLoad )
		{
			PyObject* pReturnValue = CallPythonFunction( pLoad, nullptr );
			if( pReturnValue )
			{
				Py_DECREF(pReturnValue);
			}
			Py_XDECREF(pLoad);
			
		}
	}
Ejemplo n.º 18
0
//////////////////////////////////////////////////////////////////////////
// Basic Sprite creation and manipulation functionality
//////////////////////////////////////////////////////////////////////////
PyObject* AIE_CreateSprite(PyObject *self, PyObject *args)
{
	const char* pTextureName; float fv2Size[2]; float fv2Origin[2]; float fv4UVCoords[4]; unsigned int vColour[4];
	if (!PyArg_ParseTuple(args, "sffffffffiiii", &pTextureName, 
												 &fv2Size[0], &fv2Size[1], 
												 &fv2Origin[0], &fv2Origin[1], 
												 &fv4UVCoords[0], &fv4UVCoords[1], &fv4UVCoords[2], &fv4UVCoords[3],
												 &vColour[0], &vColour[1], &vColour[2], &vColour[3]) ) 
	{
		ParsePyTupleError( __func__, __LINE__ );
		return nullptr;
	}
	//fv4UVCoords[0] = 0.f, fv4UVCoords[1] = 0.f, fv4UVCoords[2] = 1.f, fv4UVCoords[3] = 1.f;
	unsigned int uiSpriteID = CreateSprite( pTextureName, fv2Size, fv2Origin, fv4UVCoords, SColour(vColour[0], vColour[1], vColour[2], vColour[3]));
	//unsigned int uiSpriteID = CreateSprite( pTextureName, fv2Size[0], fv2Size[1], false );
	return Py_BuildValue("i", uiSpriteID);
}
#include <iostream>

#define NDEBUG
#include <GL/freeglut.h>

#include "../_common_libarires/CTank.h"
#include "../_common_libarires/CBullet.h"

// default constructor
CTank tank1(1.0, 0.3, 0.7, 0.2);
// specialized constructor 
CTank tank2(
	SColour(0.0, 0.0, 1.0),
	1.0, 0.3,
	SColour(0.5, 0.0, 0.5),
	0.7, 0.2
	);
CBullet bullet(0.125);

const double gravityAcceleration = 9.81;
const int gameLogicUpdateIntervalInMs = 25;

/* GLUT callback Handlers */
static void resize(int width, int height)
{
	const float ar = (float)width / (float)height;

	glViewport(0, 0, width, height);

	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
Ejemplo n.º 20
0
void DrawHitline(int x, int y){
		DrawLine(x,  y-28,  x,  y-64,  SColour(0xFF,0x00,0x00,0xAA) );
		DrawLine(x,  y+28,  x,  y-28,  SColour(0x00,0xFF,0x00,0xAA) );
		DrawLine(x,  y+28,  x,  y+64,  SColour(0x00,0x00,0xFF,0xAA) );
}
Ejemplo n.º 21
0
void UpdateGameState()
{
	SetBackgroundColour( SColour( 7, 73, 255, 254 ) );
}
Ejemplo n.º 22
0
void UpdateMainMenu()
{
	SetBackgroundColour( SColour( 000, 000, 000, 000 ) );
}