1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
|
int TextureArray[NUM_TEXTURE_TYPES];
void DrawBackground(int Textures[], int Background[10][10], int screenWidth, int screenHight);
void DrawBackground()
{
int Background[10][10] = { {1, 1, 0, 0, 0, 0, 0, 0, 1, 1},
{1, 1, 0, 0, 0, 0, 0, 0, 1, 1},
{2, 2, 0, 0, 0, 0, 0, 0, 2, 2},
{2, 2, 0, 0, 0, 0, 0, 0, 2, 2},
{3, 3, 0, 0, 0, 0, 0, 0, 3, 3},
{3, 3, 0, 0, 0, 0, 0, 0, 3, 3},
{4, 4, 0, 0, 0, 0, 0, 0, 4, 4},
{4, 4, 0, 0, 0, 0, 0, 0, 4, 4},
{5, 5, 0, 0, 0, 0, 0, 0, 5, 5},
{5, 5, 0, 0, 0, 0, 0, 0, 5, 5} };
//Lets open the window and initialise opengl
InitGL(1024,768);
TextureArray[WHITE] = LoadTexture("./images/white.png");
TextureArray[BLUE] = LoadTexture("./images/blue.png");
TextureArray[ORANGE] = LoadTexture("./images/orange.png");
TextureArray[PURPLE] = LoadTexture("./images/purple.png");
TextureArray[WATER] = LoadTexture("./images/water.png");
//Before you exit, clean up after yourself
for(int i = 0;i < NUM_TEXTURE_TYPES; ++i)
{
FreeTexture(TextureArray[i]);
}
}
void DrawBackground(int Textures[], int Background[10][10], int screenWidth, int screenHeight)
{
int iWidth = screenWidth / 10;
int iHeight = screenHeight / 10;
for(int y = 0;y < 10; ++y)
{
for(int x = 0;x < 10; ++x)
{
int iTextureType = Background[y][x];
DrawSprite(Textures[iTextureType], (float)(x * iWidth), (float)(y * iHeight),(float) (iWidth), (float(iHeight)));
}
}
}
|