void TBox::SetScale(const float fScaleX,const float fScaleY)
{
	m_fScale = fScaleY;
	if (m_pSprite != nullptr)
		GfxSpriteSetScale(m_pSprite, fScaleX, fScaleY);
	if (m_pTextSprite != nullptr)
		GfxSpriteSetScale(m_pTextSprite, fScaleX, fScaleY);
}
void TBox::SetScale(const float fScale)
{
	m_fScale = fScale;
	if (m_pSprite != nullptr)
		GfxSpriteSetScale(m_pSprite, m_fScale, m_fScale);
	if (m_pTextSprite != nullptr)
		GfxSpriteSetScale(m_pTextSprite, m_fScale, m_fScale);

}
Esempio n. 3
0
TGfxSprite * CreateTile(const TGfxTexture * g_pTexture, const int iPosX, const int iPosY, const int iTileX, const int iTileY)
{

	TGfxSprite * pSprite = GfxSpriteCreate(g_pTexture);    // On crée pSprite et on y met la la variable de la texture chargée 
	GfxSpriteSetScale(pSprite, float(SCALE), float(SCALE));    // On choisis la taille du sprite appellé pSprite 
	GfxSpriteSetFilteringEnabled(pSprite, false);             // On désactive le filtering ( à laisse )
	GfxSpriteSetCutout(pSprite, iPosX * TILE_SIZE, iPosY * TILE_SIZE, TILE_SIZE, TILE_SIZE);    // On choisis ce qui sera affiché sur un sprite, ici on choisis la taille et la position du sprite dans la texture
	GfxSpriteSetPosition(pSprite, float(SCALE) * TILE_SIZE * iTileX, float(SCALE) * TILE_SIZE * iTileY);     // On choisis où l'afficher 

	return pSprite;  // toujours mettre le return à la fin car ça sort de la fonction.
}
Esempio n. 4
0
void TPlayer::Initialize(int x, int y, int TILE_SIZE, int SCALE)
{
	TGfxTexture * pTexture = GfxTextureLoad("gfx/tileset.tga");
	m_pSpritePlayer = GfxSpriteCreate(pTexture);
	GfxSpriteSetScale(m_pSpritePlayer, float(SCALE), float(SCALE));
	GfxSpriteSetFilteringEnabled(m_pSpritePlayer, false);
	GfxSpriteSetCutout(m_pSpritePlayer, x * TILE_SIZE, y * TILE_SIZE, TILE_SIZE, TILE_SIZE);
	GfxSpriteSetPosition(m_pSpritePlayer, 
		((GfxGetDisplaySizeX() / 2) - ((GfxSpriteGetSizeX(m_pSpritePlayer)*(GfxSpriteGetScaleX(m_pSpritePlayer)) / 2))), 
		((GfxGetDisplaySizeY() / 2) - ((GfxSpriteGetSizeY(m_pSpritePlayer)*(GfxSpriteGetScaleY(m_pSpritePlayer)) / 2))));
}      
Esempio n. 5
0
TGfxSprite * CreateTile(const TGfxTexture * g_pTexture, const int g_iPosX, const int g_iPosY, const int iTileX, const int iTileY)
{

    TGfxSprite * pSprite = GfxSpriteCreate(g_pTexture);
    GfxSpriteSetScale(pSprite, float(SCALE), float(SCALE));
    GfxSpriteSetFilteringEnabled(pSprite, false);
    GfxSpriteSetCutout(pSprite, g_iPosX * TILE_SIZE, g_iPosY * TILE_SIZE, TILE_SIZE, TILE_SIZE);
    GfxSpriteSetPosition(pSprite, float(SCALE) * TILE_SIZE * iTileX, float(SCALE) * TILE_SIZE * iTileY);
    GfxSpriteSetPivot(pSprite, TILE_SIZE / 2, TILE_SIZE / 2); // Change le point de collision de tout les tile créés comme ça

    return pSprite;  // toujours mettre le return à la fin car ça sort de la fonction.
}
Esempio n. 6
0
void Initialize()
{
	int sizeX = (GfxGetDisplaySizeX() / 2);
	int sizeY = (GfxGetDisplaySizeY() / 2);
	g_pLines = GfxLineSpriteCreate();
	g_pLines2 = GfxLineSpriteCreate();

	ArcheoStuffs::DrawCircle(g_pLines, TGfxVec2(0, 0), 8, GfxColor(255, 255, 0, 255), true); // Player creation

	for (int i = 0; i < g_iNbrCave; i++)
	{
		g_bCaveSearched[i] = false;
	}


	g_pImage = GfxImageCreate(1,1);
	unsigned int * pData = GfxImageGetData(g_pImage);
	*pData = EGfxColor_White;
	g_pTexture = GfxTextureCreate(g_pImage);

	g_pSpritePlayer = GfxSpriteCreate(g_pTexture);
	g_pSpriteBase = GfxSpriteCreate(g_pTexture);

	GfxSpriteSetScale(g_pSpritePlayer, 16, 16);
	GfxSpriteSetColor(g_pSpritePlayer, GfxColor(255, 255, 0, 255));
	g_TPlayerData.iPos = TGfxVec2(sizeX - 8, sizeY - 8);
	g_TPlayerData.iPosX = sizeX - 8;
	g_TPlayerData.iPosY = sizeY - 8;

	GfxSpriteSetScale(g_pSpriteBase, 32, 32);
	GfxSpriteSetColor(g_pSpriteBase, GfxColor(0, 255, 0, 255));
	GfxSpriteSetPosition(g_pSpriteBase, sizeX-16, sizeY-16);

	for (int i = 0; i < g_iNbrCave; i++)
	{
		ArcheoStuffs::CreateCave(i);
	}
	
}
Esempio n. 7
0
TFade::TFade()
{
#ifndef TFA_FRESH

	TGfxTexture * m_pFadeTexture = GfxTextureLoad("Data/Hud/Fade_Panel.tga");
	m_pFadeSprite = GfxSpriteCreate(m_pFadeTexture);

	float fScaleX = (GfxSpriteGetSizeY(m_pFadeSprite)*1.0f) / (GfxGetDisplaySizeY()*1.0f);

	GfxSpriteSetScale(m_pFadeSprite, 1.0f / fScaleX, 1.0f / fScaleX);

	float  offset = GfxSpriteGetSizeX(m_pFadeSprite)*(1.0f / fScaleX) - GfxGetDisplaySizeX();
	GfxSpriteSetPosition(m_pFadeSprite, -offset / 2.0f, 0);


#endif
	m_fFadingDurationToBlack = 0.75f;
	m_fFadingDurationToClear = 0.5f;
	m_eFadeState = FADE_CLEAR;
	m_fOpacity = 0;
}
Esempio n. 8
0
	void CreateCave(int ActCave)
	{
		g_pCave[ActCave].iScale = GfxMathGetRandomInteger(32, 64);
		bool Collisioned = true;
		do
		{
			g_pCave[ActCave].iPosX = (GfxMathGetRandomInteger(g_pCave[ActCave].iScale, GfxGetDisplaySizeX() - g_pCave[ActCave].iScale));
			g_pCave[ActCave].iPosY = (GfxMathGetRandomInteger(g_pCave[ActCave].iScale, GfxGetDisplaySizeY() - g_pCave[ActCave].iScale));
			Collisioned = false;
			for (int e = 0; e < ActCave; e++)
			{
				if (!(g_pCave[ActCave].iPosX > g_pCave[e].iPosX + g_pCave[e].iScale + 20)
					&& !(g_pCave[ActCave].iPosX < g_pCave[e].iPosX - g_pCave[ActCave].iScale - 20)
					&& !(g_pCave[ActCave].iPosY < g_pCave[e].iPosY - g_pCave[ActCave].iScale - 20)
					&& !(g_pCave[ActCave].iPosY > g_pCave[e].iPosY + g_pCave[e].iScale + 20))
				{
					Collisioned = true;
				}
			}
			if (ActCave == 0)
			{
				Collisioned = false;
			}
		} while (Collisioned == true);


		g_pCave[ActCave].pLines = GfxLineSpriteCreate();
		ArcheoStuffs::DrawCircle(g_pCave[ActCave].pLines, TGfxVec2(0, 0), g_pCave[ActCave].iScale / 2, EGfxColor_Blue, false);
		GfxSpriteSetPosition(g_pCave[ActCave].pLines, g_pCave[ActCave].iPosX, g_pCave[ActCave].iPosY);

		g_pCave[ActCave].g_pSpriteCave = GfxSpriteCreate(g_pTexture);
		GfxSpriteSetPivot(g_pCave[ActCave].g_pSpriteCave, 0.5, 0.5);
		GfxSpriteSetScale(g_pCave[ActCave].g_pSpriteCave, g_pCave[ActCave].iScale, g_pCave[ActCave].iScale);
		GfxSpriteSetColor(g_pCave[ActCave].g_pSpriteCave, GfxColor(0, 0, 255, 255));
		GfxSpriteSetPosition(g_pCave[ActCave].g_pSpriteCave, g_pCave[ActCave].iPosX, g_pCave[ActCave].iPosY);
		g_iNbrCaveCreated++;
	}
Esempio n. 9
0
void ChangeColor(int iPosX, int iPosY, int iImgSizeX)
{
	GfxTextureDestroy(g_pBackgroundTexture);
	GfxSpriteDestroy(g_pBackgroundSprite);

	g_pData = GfxImageGetData(g_pBackgroundImage);

	const int iIndex = iPosX + (iPosY * iImgSizeX);

	if (g_pData[iIndex] == GfxColor(255, 0, 0, 255))
	{
		g_pData[iIndex] = EGfxColor_White;
	}
	else
	{
		g_pData[iIndex] = EGfxColor_Red;
	}

	g_pBackgroundTexture = GfxTextureCreate(g_pBackgroundImage);
	g_pBackgroundSprite = GfxSpriteCreate(g_pBackgroundTexture);

	GfxSpriteSetScale(g_pBackgroundSprite, 32, 32);
	GfxSpriteSetFilteringEnabled(g_pBackgroundSprite, false);
}
Esempio n. 10
0
void Update()
{
    const int iMPosX = int(GfxGetCurrentMouseX());
    const int iMPosY = int(GfxGetCurrentMouseY());  // Remplacer iMPosX par iiMPosX

    bool bCollide = true;

    g_iPosX = int(GfxSpriteGetPositionX(g_pSpriteHero));  // Le deuxieme int sert à forcer un int ! ça retire les virgules probable
    g_iPosY = int(GfxSpriteGetPositionY(g_pSpriteHero));

    const int iTileCountX = GfxGetDisplaySizeX() - 1;  // valeur de type INT pour ne pas garder ce qui est après la virgule
    const int iTileCountY = GfxGetDisplaySizeY() - 1;


    // MOUSE MOVE ( with collision )




    if (IsGameOver == false)
    {
        //-------------------------------------------------------------- Déplacement droite ---------------------------------------------------//
        if (GfxInputIsPressed(EGfxInputID_MouseLeft) && g_iPosX + 16 < iMPosX)
        {
            GfxSpriteSetScale(g_pSpriteHero, float(SCALE), float(SCALE));																	   //
            bCollide = true;																												   //
            for (int i = 0; i < g_iWallCount; i++)																							   //
            {   //
                if (GfxSpriteGetPositionY(g_pSpriteWall[i]) - 31 < g_iPosY && g_iPosY < GfxSpriteGetPositionY(g_pSpriteWall[i]) + 32)		   //
                {   //
                    if (GfxSpriteGetPositionX(g_pSpriteWall[i]) - 33 < g_iPosX && g_iPosX < GfxSpriteGetPositionX(g_pSpriteWall[i]) + 32)	   //
                    {   //
                        bCollide = false;																									   //
                    }																														   //
                }
            }
            for (int i = 0; i < g_iDeathWallCount; i++)																							   //
            {   //
                if (GfxSpriteGetPositionY(g_pSpriteDeathWall[i]) - 31 < g_iPosY && g_iPosY < GfxSpriteGetPositionY(g_pSpriteDeathWall[i]) + 32)		   //
                {   //
                    if (GfxSpriteGetPositionX(g_pSpriteDeathWall[i]) - 33 < g_iPosX && g_iPosX < GfxSpriteGetPositionX(g_pSpriteDeathWall[i]) + 32)	   //
                    {   //
                        GameOver();																							   //
                    }																														   //
                }
            }
            //
            if (bCollide == true)																											   //
            {   //

                g_iMove[0] -= 2;																											   //

                //g_iPosX += 2;																												   //
            }																																   //
        }																																	   //
        //-------------------------------------------------------------- Fin déplacement droite -----------------------------------------------//

        //-------------------------------------------------------------- Déplacement Gauche ----------------------------------

        if (GfxInputIsPressed(EGfxInputID_MouseLeft) && g_iPosX - 16 > iMPosX)
        {
            GfxSpriteSetScale(g_pSpriteHero, float(-SCALE), float(SCALE));
            bCollide = true;
            for (int i = 0; i < g_iWallCount; i++)
            {
                if (GfxSpriteGetPositionY(g_pSpriteWall[i]) - 31 < g_iPosY && g_iPosY < GfxSpriteGetPositionY(g_pSpriteWall[i]) + 32)
                {
                    if (GfxSpriteGetPositionX(g_pSpriteWall[i]) - 32 < g_iPosX && g_iPosX < GfxSpriteGetPositionX(g_pSpriteWall[i]) + 33)
                    {
                        bCollide = false;
                    }
                }
            }
            for (int i = 0; i < g_iDeathWallCount; i++)
            {
                if (GfxSpriteGetPositionY(g_pSpriteDeathWall[i]) - 31 < g_iPosY && g_iPosY < GfxSpriteGetPositionY(g_pSpriteDeathWall[i]) + 32)
                {
                    if (GfxSpriteGetPositionX(g_pSpriteDeathWall[i]) - 32 < g_iPosX && g_iPosX < GfxSpriteGetPositionX(g_pSpriteDeathWall[i]) + 33)
                    {
                        GameOver();
                    }
                }
            }

            if (bCollide == true)
            {
                g_iMove[0] += 2;
                //g_iPosX-= 2;
            }
        }
        //-------------------------------------------------------------- Fin déplacement gauche ----------------------------------

        //--------------------------------------------------------------- Collision Sol ---------------------------
        bCollide = true;
        for (int i = 0; i < g_iWallCount; i++)
        {
            if (GfxSpriteGetPositionX(g_pSpriteWall[i]) - 31 < g_iPosX && g_iPosX < GfxSpriteGetPositionX(g_pSpriteWall[i]) + 31)
            {
                if (g_iPosY > GfxSpriteGetPositionY(g_pSpriteWall[i]) - 33 && g_iPosY < GfxSpriteGetPositionY(g_pSpriteWall[i]) + 32)
                {
                    bCollide = false;
                    if (g_iVelocity[1] < 0)
                    {
                        g_iPosY = GfxSpriteGetPositionY(g_pSpriteWall[i]) + 32;
                    }
                    if (g_iVelocity[1] > 0)
                    {
                        g_iPosY = GfxSpriteGetPositionY(g_pSpriteWall[i]) - 31;
                    }
                    g_iVelocity[1] = 0;
                }
            }
        }
        // DEBUT GAME OVER
        for (int i = 0; i < g_iDeathWallCount; i++)
        {
            if (GfxSpriteGetPositionX(g_pSpriteDeathWall[i]) - 31 < g_iPosX && g_iPosX < GfxSpriteGetPositionX(g_pSpriteDeathWall[i]) + 31)
            {
                if (g_iPosY > GfxSpriteGetPositionY(g_pSpriteDeathWall[i]) - 33 && g_iPosY < GfxSpriteGetPositionY(g_pSpriteDeathWall[i]) + 32)
                {
                    GameOver();
                }
            }
        }
        // FIN GAME OVER


        if (bCollide == true)
        {
            g_iVelocity[1] += 0.4f; // f à la fin quand c'est un float. ça corrige l'erreur appellé "truncation"
        }

        if (GfxInputIsJustPressed(EGfxInputID_KeySpace) && g_iVelocity[1] == 0 || GfxInputIsJustPressed(EGfxInputID_KeySpace) && GfxInputIsPressed(EGfxInputID_KeyControl))
        {
            g_iVelocity[1] = -7;
        }
        if (iMPosX > g_iPosX - 16
                && iMPosX < g_iPosX + 16
                && g_iVelocity[1] == 0
                && GfxInputIsJustPressed(EGfxInputID_MouseLeft))
        {
            g_iVelocity[1] = -7;
        }
    }
    //------------------------------------------------------------- Fin Collision Sol --------------------------------

    //-------------------------------------------------------------- Actualisation déplacement ----------------------------------
    g_iMove[1] = g_iMove[1] - (g_iVelocity[1]);
    for (int i = 0; i < g_iWallCount; i++)
    {
        GfxSpriteSetPosition(g_pSpriteWall[i], float (GfxSpriteGetPositionX(g_pSpriteWall[i])) + float(g_iMove[0]), float (GfxSpriteGetPositionY(g_pSpriteWall[i])));
    }
    for (int i = 0; i < g_iDeathWallCount; i++)
    {
        GfxSpriteSetPosition(g_pSpriteDeathWall[i], float(GfxSpriteGetPositionX(g_pSpriteDeathWall[i])) + float(g_iMove[0]), float(GfxSpriteGetPositionY(g_pSpriteDeathWall[i])));
    }
    if (IsGameOver == false)
    {
        GfxSpriteSetPosition(g_pSpritesBg, float(GfxSpriteGetPositionX(g_pSpritesBg)) + (float(g_iMove[0]/2)), float(GfxSpriteGetPositionY(g_pSpritesBg)));
        GfxSpriteSetPosition(g_pSpriteHero, float(g_iPosX), float(g_iPosY) - float(g_iMove[1]));
    }
    g_iMove[0] = 0;
    g_iMove[1] = 0;
    //-------------------------------------------------------------- Fin Actualisation déplacement ----------------------------------
}
Esempio n. 11
0
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);
}
Esempio n. 12
0
void Update()
{
    //Effacer le sprite et texture de la mémoire
    if (g_pSprite != nullptr)
    {
        GfxSpriteDestroy(g_pSprite);
        g_pSprite = nullptr; // Libert l'adresse mémoire du sprite
    }

    if (g_pTexture != nullptr)
    {
        GfxTextureDestroy(g_pTexture);
        g_pTexture = nullptr;
    }

    TCamera tCamera;
    TSphere tSphere[MAX_SPHERES];
    TPlan tPlan;
    tPlan.m_tPosition = TGfxVec3(0, -5, 0);
    tSphere[0].m_tPosition = TGfxVec3(-1, 0, 8);
    tSphere[0].m_tColor = TGfxVec3(255, 0, 0);
    tSphere[1].m_tPosition = TGfxVec3(-3, 0, 8);
    tSphere[1].m_tColor = TGfxVec3(255, 255, 0);
    tSphere[2].m_tPosition = TGfxVec3(1, 0, 8);
    tSphere[2].m_tColor = TGfxVec3(0, 0, 255);
    tSphere[3].m_tPosition = TGfxVec3(3, 0, 8);
    tSphere[3].m_tColor = TGfxVec3(255, 255, 0);
    tSphere[4].m_tPosition = TGfxVec3(0, 1, 8);
    tSphere[4].m_tColor = TGfxVec3(255, 0, 0);
    tSphere[5].m_tPosition = TGfxVec3(0, -1, 8);
    tSphere[5].m_tColor = TGfxVec3(0, 0, 255);
    tSphere[6].m_tPosition = TGfxVec3(0, -3, 8);
    tSphere[6].m_tColor = TGfxVec3(255, 255, 0);
    tSphere[7].m_tPosition = TGfxVec3(0, 3, 8);
    tSphere[7].m_tColor = TGfxVec3(255, 255, 0);
    tSphere[8].m_tPosition = TGfxVec3(-2, -2, 8);
    tSphere[8].m_tColor = TGfxVec3(255, 255, 0);
    tSphere[9].m_tPosition = TGfxVec3(-2, 2, 8);
    tSphere[9].m_tColor = TGfxVec3(255, 255, 0);
    tSphere[10].m_tPosition = TGfxVec3(2, 2, 8);
    tSphere[10].m_tColor = TGfxVec3(255, 255, 0);
    tSphere[11].m_tPosition = TGfxVec3(2, -2, 8);
    tSphere[11].m_tColor = TGfxVec3(255, 255, 0);
    tCamera.m_tPosition = TGfxVec3(g_fx, g_fy, g_fz);
    tCamera.m_fFOV = 120.f;
    tCamera.Render(g_pImage, tSphere, tPlan);

    g_pTexture = GfxTextureCreate(g_pImage);
    g_pSprite = GfxSpriteCreate(g_pTexture);
    GfxSpriteSetScale(g_pSprite, float(SCALE_FACTOR), float(SCALE_FACTOR));
    GfxSpriteSetFilteringEnabled(g_pSprite, false);



    if (GfxInputIsPressed(EGfxInputID_KeyArrowUp))
    {
        g_fy += 0.1f;
    }

    if (GfxInputIsPressed(EGfxInputID_KeyArrowDown))
    {
        g_fy -= 0.1f;
    }

    if (GfxInputIsPressed(EGfxInputID_KeyArrowRight))
    {
        g_fx += 0.1f;
    }

    if (GfxInputIsPressed(EGfxInputID_KeyArrowLeft))
    {
        g_fx -= 0.1f;
    }

    if (GfxInputIsPressed(EGfxInputID_KeyCharS))
    {
        g_fz -= 0.1f;
    }

    if (GfxInputIsPressed(EGfxInputID_KeyCharZ))
    {
        g_fz += 0.1f;
    }
}