コード例 #1
0
void DrawTitleScreen(TitleScreen *title)
{
	int border = 10;

	Iw2DSetColour(0xffffffff);
	Iw2DFillRect(title->btnTopLeft, title->btnDim);

	Iw2DSetColour(0xff000000);
	Iw2DFillRect(CIwFVec2(title->btnTopLeft.x + border, title->btnTopLeft.y + border),
				 CIwFVec2(title->btnDim.x - 2 * border, title->btnDim.y - 2 * border));
	
	Iw2DSetFont(fontLarge);
	int fh = fontLarge->GetHeight();
	int sw = Iw2DGetStringWidth("P L A Y");

	Iw2DSetColour(0xffffffff);
	Iw2DDrawString("P L A Y", CIwFVec2(title->btnTopLeft.x + border, title->btnTopLeft.y + border),
		CIwFVec2(title->btnDim.x - 2 * border, title->btnDim.y - 2 * border), IW_2D_FONT_ALIGN_CENTRE, IW_2D_FONT_ALIGN_TOP);
	Iw2DDrawString("Patriot Missile Defense", CIwFVec2(0.f, 0.f), CIwFVec2(screen.x, screen.y / 2),
		IW_2D_FONT_ALIGN_CENTRE, IW_2D_FONT_ALIGN_CENTRE);
}
コード例 #2
0
void TextSprite::RenderImage(uint32 gameTime)
{
    if(textColorSource != null) textColor = textColorSource->GetColor(gameTime);
    if(borderColorSource != null) borderColor = borderColorSource->GetColor(gameTime);
    if(backgroundColorSource != null) backgroundColor = backgroundColorSource->GetColor(gameTime);
    if(marginXSource != null) margin = SCREEN_TO_SUBPIXEL(CIwVec2(marginXSource->GetInt(gameTime), marginYSource->GetInt(gameTime)));
    if(paddingXSource != null) padding = SCREEN_TO_SUBPIXEL(CIwVec2(paddingXSource->GetInt(gameTime), paddingYSource->GetInt(gameTime)));
    if(borderXSource != null) borderThickness = SCREEN_TO_SUBPIXEL(CIwVec2(borderXSource->GetInt(gameTime), borderYSource->GetInt(gameTime)));

    if(marginXSource != null || paddingXSource != null || borderXSource != null)
    {
        UpdatePositionData();
    }

    CIw2DFont *prevFont = null;
    CIwColour prevColor = Iw2DGetColour();

    if(textFont != null)
    {
        prevFont = Iw2DGetFont();
        Iw2DSetFont(textFont);
    }

    if(backgroundColor.a > 0)
    {
        Iw2DSetColour(backgroundColor);
        Iw2DFillRect(CIwSVec2(backgroundPosition), CIwSVec2(backgroundSize));
    }

    if(borderColor.a > 0)
    {
        Iw2DSetColour(borderColor);
        Iw2DFillRect(CIwSVec2(borderPosition), CIwSVec2(borderSize));

        Iw2DSetColour(backgroundColor);
        Iw2DFillRect(CIwSVec2(innerBorderPosition), CIwSVec2(innerBorderSize));
    }

    Iw2DSetColour(textColor);
    
    const char *textPtr = text.c_str();

    Iw2DDrawString(textPtr, CIwSVec2(textPosition), CIwSVec2(textSize), horizontalAlignment, IW_2D_FONT_ALIGN_TOP);

    Iw2DSetColour(prevColor);

    if(prevFont != null)
    {
        Iw2DSetFont(prevFont);
    }
}
コード例 #3
0
void DrawBootSequence()
{
	Iw2DSetFont(font);

	int h = font->GetHeight();

	for (unsigned i = 0; i < g_Current_Line; i++) {
		int w = Iw2DGetStringWidth(g_Bootup_Sequence[i]);

		Iw2DSetColour(0xffffffff);
		Iw2DDrawString(g_Bootup_Sequence[i], CIwFVec2(0, i*h),
			CIwFVec2(w, h), IW_2D_FONT_ALIGN_LEFT, IW_2D_FONT_ALIGN_TOP);
	}
}
コード例 #4
0
void DrawGameOverScreen()
{
	int border = 10;
	CIwFVec2 dialogDim(480.f, 120.f);

	CIwFVec2 outerTopLeft((screen.x - dialogDim.x)/2, (screen.y - dialogDim.y)/2);
	CIwFVec2 innerTopLeft((screen.x - dialogDim.x)/2 + border, (screen.y - dialogDim.y)/2 + border);

	Iw2DSetColour(0xffffffff);
	Iw2DFillRect(outerTopLeft, dialogDim);
	Iw2DSetColour(0xff000000);
	Iw2DFillRect(innerTopLeft, CIwFVec2(dialogDim.x - 2 * border, dialogDim.y - 2 * border));

	Iw2DSetColour(0xffffffff);
	Iw2DSetFont(fontLarge);

	Iw2DDrawString("G A M E   O V E R", outerTopLeft, dialogDim, IW_2D_FONT_ALIGN_CENTRE, IW_2D_FONT_ALIGN_CENTRE);
}
コード例 #5
0
ファイル: Inventory.cpp プロジェクト: MichaelVacirca/ADL-STEM
void CInventory::Draw()
{
	// Only display inventory in certain game states
	if (g_Game.getGameState() == GS_Playing || g_Game.getGameState() == GS_Paused || g_Game.getGameState() == GS_LevelCompletedFailure || g_Game.getGameState() == GS_LevelCompletedSuccess)
	{
		// Set the current font
		Iw2DSetFont(g_Game.getFont());

		// Reset the visual transform
		Iw2DSetTransformMatrix(CIwMat2D::g_Identity);

		// Set the texts colour to black
		//Iw2DSetColour(0xff000000);
		// HASAN - switched to white since there's a background now
		Iw2DSetColour(0xffffffff);

		// Convert the atom count number to text
		char str[32];
		for (int i = 0; i < inventoryCount; i++)
		{
			// skip to the next if count is zero - and atom is hidden (i.e. - it was originally in the inventory, but now is fully used and no longer available)
			if (atomCount[i] <= 0)
				continue;

			snprintf(str, 32, "%d", atomCount[i]);

			// horizontal center, same as inventory graphic
			int posX = (Iw2DGetSurfaceWidth() / 2) - ( IMAGE_SIZE_WIDTH / 2 ) + 19;
			int posY = Iw2DGetSurfaceHeight() - ( IMAGE_SIZE_HEIGHT / 2);

			// offset inventory vertically to fit in the container
			posX = posX + (10 + (64 / 2));  // NOTE: 64 = atom size, 10 = border + spacing
			if (i > 0)
			{
				posX = posX + (i * (64 + 15));  // NOTE: 64 = atom size, 15 = spacing + border + spacing
			}

			// Draw the atom count in the appropriate location
			Iw2DDrawString(str, CIwSVec2(posX, posY), CIwSVec2(30, 30), IW_2D_FONT_ALIGN_LEFT, IW_2D_FONT_ALIGN_TOP);
		}
	}
}
コード例 #6
0
int main(int argc, char* argv[])
{
	g_pointerdown = false;
	FillDefaultLocalScores();
	// Initialisation of Airplay Studio modules
	Iw2DInit();			// Initialise support for rendering with the standard SW renderer
	IwGxLightingOff();
	IwResManagerInit();
	Load();

	int16 sw = (int16)Iw2DGetSurfaceWidth();
	int16 sh = (int16)Iw2DGetSurfaceHeight();

	PAL_InitData_t palInitData;
	SC_Error_t retCode = SC_Client_New(&g_client, &palInitData, SC_TEST_GAME_ID,
			SC_TEST_GAME_SECRET, "AIW");

	if (retCode != SC_OK) 
		s3eDebugAssertShow(S3E_MESSAGE_CONTINUE_STOP, "Failed to create SC_Client");
	
	IwGetResManager()->LoadGroup("fonts.group");
	LoadGlobalImages();

	LoadMainControls();
	game = new CGame();
	mainmenu = new CMainMenu();
	profile = new CProfile();
	scores = new CScores();


	mainmenu->Load();
	game->Load();
	profile->Load();
	scores->Load();
	CBaseScene *curscene = (CBaseScene *)mainmenu;
	g_curSceneType = stMainMenu;


	uint32 timer = (uint32)s3eTimerGetMs();

	g_AccelerometerEnabled = (s3eAccelerometerStart() == S3E_RESULT_SUCCESS);

	

	while(curscene)
	{

		s3eDeviceYield(0);


		//// Check for user quit
		if (s3eDeviceCheckQuitRequest())
			break;


		int delta = uint32(s3eTimerGetMs()) - timer;
		timer += delta;

		// Make sure the delta-time value is safe
		if (delta < 0)
			delta = 0;
		if (delta > 100)
			delta = 100;

		if (g_AccelerometerEnabled)
		{

			if (!g_waiting)
			{
				if (g_errorDialog->Get_Visible())
				{
					if (UpdatePointer() == petDown)
						CloseErrorDlg();
					else
						g_errorDialog->Update(delta);
				}
				else
				{
					switch (UpdatePointer())
					{
						case petNone: break;
						case petDown: curscene->PointerDown(g_pointerx, g_pointery); break;
						case petUp: curscene->PointerUp(g_pointerx, g_pointery); break;
						case petMove: curscene->PointerMove(g_pointerx, g_pointery); break;
					}
					curscene->Update(delta);
				}
			}
			curscene->Render();
			if (g_waiting)
			{
				Iw2DSetColour(0xeeffffff);
				Iw2DFillRect(CIwSVec2(0, 0), CIwSVec2(sw, sh));

				Iw2DSetColour(0xff000000);
		
				Iw2DSetFont(g_font);
				Iw2DDrawString(g_waitcaption, CIwSVec2(0, 0), CIwSVec2(sw, sh), IW_2D_FONT_ALIGN_CENTRE, IW_2D_FONT_ALIGN_CENTRE);
			}
			if (g_errorDialog->Get_Visible())
			{
				g_errorDialog->Render();
			}
		}


		Iw2DSurfaceShow();

		switch (g_curSceneType)
		{
			case stNone: curscene = 0; break;
			case stMainMenu: 
			{
				if (curscene != (CBaseScene *)mainmenu)
				{
					curscene = (CBaseScene *)mainmenu; 
					curscene->Show();
				}
			}	break;
			case stGame: 
			{
				if (curscene != (CBaseScene *)game)
				{
					curscene = (CBaseScene *)game;
					curscene->Show();
				}
			}break;

			case stProfile: 
			{
				if (curscene != (CBaseScene *)profile)
				{
					curscene = (CBaseScene *)profile;
					curscene->Show();
				}
			}break;
			case stScores: 
			{
				if (curscene != (CBaseScene *)scores)
				{
					curscene = (CBaseScene *)scores;
					curscene->Show();
				}
			}break;
		}
	}
	Save();
	delete game;
	delete mainmenu;
	delete profile;
	delete scores;

	SC_Client_Release(g_client);
	UnloadGlobalImages();
	UnloadMainControls();
	if (g_AccelerometerEnabled)
		s3eAccelerometerStop();
	// Terminate system modules
	IwResManagerTerminate();
	Iw2DTerminate();

	return 0;
}