//----SET void TBox::CreateBox(unsigned int m_iColor, const bool bText, const bool bSprite, const bool bLine) { if (m_pTextSprite == nullptr && bText) { m_pTextSprite = GfxTextSpriteCreate(); GfxSpriteSetFilteringEnabled(m_pTextSprite, true); } m_bIsDrawable = true; if (bLine) { //Line m_pLineSprite = GfxLineSpriteCreate(); } if (bSprite) { //Image TGfxImage * pImage = GfxImageCreate(1, 1); GfxImageGetData(pImage)[0] = EGfxColor_White; TGfxTexture * pTexture = GfxTextureCreate(pImage); m_pSprite = GfxSpriteCreate(pTexture); GfxSpriteSetFilteringEnabled(m_pSprite, false); GfxSpriteSetPivot(m_pSprite, 0.5f, 0.5f); SetColor(m_iColor); } }
void TBox::CreateTextBox(const char * pName) { m_bIsDrawable = true; m_pTextSprite = GfxTextSpriteCreate(); GfxSpriteSetFilteringEnabled(m_pTextSprite, false); GfxTextSpritePrintf(m_pTextSprite, pName); int iSizeX = GfxSpriteGetSizeX(m_pTextSprite); int iSizeY = GfxSpriteGetSizeY(m_pTextSprite); GfxSpriteSetPivot(m_pTextSprite, iSizeX / 2.0f, iSizeY / 2.0f); SetBox(TGfxVec2(0.0f, 0.0f), (float)iSizeX, (float)iSizeY); }
void TBox::SetTexte(int iValeur) { if (m_pTextSprite == nullptr) { m_pTextSprite = GfxTextSpriteCreate(); } GfxTextSpritePrintf(m_pTextSprite, "%i\n",iValeur); m_iText = iValeur; float fSizeX = GfxSpriteGetSizeX(m_pTextSprite) / 2.0f; float fSizeY = GfxSpriteGetSizeY(m_pTextSprite) / 2.0f; GfxSpriteSetPivot(m_pTextSprite, fSizeX, fSizeY); GfxSpriteSetPosition(m_pTextSprite, m_tCenter.x, m_tCenter.y); }
void TBuilding::Create(const int iPosX, const int iPosY, const int iBuildingNumber, const int SCALE) { this->iPosX = iPosX * SCALE; this->iPosY = iPosY * SCALE; TBuilding::m_tBuildingNumberSprite = GfxTextSpriteCreate(); if (iBuildingNumber < 9) // Rajoute un 0 devant les nombres plus petit que 10 pour qu'ils aient tous la même taille { GfxTextSpritePrintf(this->m_tBuildingNumberSprite, "0%d", (iBuildingNumber+1)); } else { GfxTextSpritePrintf(this->m_tBuildingNumberSprite, "%d", (iBuildingNumber+1)); } GfxSpriteSetFilteringEnabled(this->m_tBuildingNumberSprite, false); GfxSpriteSetPosition(this->m_tBuildingNumberSprite, float((iPosX * SCALE) + ((SCALE / 2) - (GfxSpriteGetSizeX(this->m_tBuildingNumberSprite) / 2))), float((iPosY * SCALE) + ((SCALE / 2) - (GfxSpriteGetSizeY(this->m_tBuildingNumberSprite) / 2)))); GfxSpriteSetColor(this->m_tBuildingNumberSprite, GfxColor(0, 0, 0, 255)); }
void Initialize() { g_pBackgroundImage = GfxImageLoad("map.tga"); g_pData = GfxImageGetData(g_pBackgroundImage); const int iImgSizeX = GfxImageGetSizeX(g_pBackgroundImage); const int iImgSizeY = GfxImageGetSizeY(g_pBackgroundImage); for (int y = 0; y < iImgSizeY; ++y) { for (int x = 0; x < iImgSizeX; ++x) { const int iIndex = x + (y * iImgSizeX); if (g_pData[iIndex] == GfxColor(0, 0, 255, 255) || g_pData[iIndex] == GfxColor(255, 0, 0, 255) || g_pData[iIndex] == GfxColor(0, 255, 0, 255)) { g_pData[iIndex] = EGfxColor_White; } } } g_pBackgroundTexture = GfxTextureCreate(g_pBackgroundImage); g_pBackgroundSprite = GfxSpriteCreate(g_pBackgroundTexture); GfxSpriteSetScale(g_pBackgroundSprite, 32, 32); GfxSpriteSetFilteringEnabled(g_pBackgroundSprite, false); g_pSpriteIncome = GfxTextSpriteCreate(); GfxTextSpritePrintf(g_pSpriteIncome, "revenue: $%d", g_iIncome); GfxSpriteSetFilteringEnabled(g_pSpriteIncome, false); GfxSpriteSetScale(g_pSpriteIncome, 2, 2); GfxSpriteSetPosition(g_pSpriteIncome, float((GfxGetDisplaySizeX() / 2) - GfxSpriteGetSizeX(g_pSpriteIncome)), 290); GfxSpriteSetColor(g_pSpriteIncome, GfxColor(255, 255, 255, 255)); TGfxImage * pMapImage = GfxImageLoad("map.tga"); const int iSecondImgSizeX = GfxImageGetSizeX(pMapImage); const int iSecondImgSizeY = GfxImageGetSizeY(pMapImage); for (int i = 0; i < 3; i++) // Boucle créant les numéros sur les buildings { for (int y = 0; y < iSecondImgSizeY; ++y) { for (int x = 0; x < iSecondImgSizeX; ++x) { const int iIndex = x + (y * iSecondImgSizeX); if (i == 0) { if (GfxImageGetData(pMapImage)[iIndex] == GfxColor(255, 0, 0, 255)) // RED CHECKING & CREATING { g_tBuilding[g_iBuildingCount].Create(x, y, g_iBuildingCount, SCALE); g_iBuildingCount++; } } else if (i == 1) { if (GfxImageGetData(pMapImage)[iIndex] == GfxColor(0, 255, 0, 255)) // GREEN CHECKING & CREATING { g_tBuilding[g_iBuildingCount].Create(x, y, g_iBuildingCount, SCALE); g_iBuildingCount++; } } else if (i == 2) { if (GfxImageGetData(pMapImage)[iIndex] == GfxColor(0, 0, 255, 255)) // BLUE CHECKING & CREATING { g_tBuilding[g_iBuildingCount].Create(x, y, g_iBuildingCount, SCALE); g_iBuildingCount++; } } } } } GfxImageDestroy(pMapImage); }