I am trying to use more than one texture image when drawing tiles to my game screen.
I have a map file with 1’s and 0’s which correspond to the 2 textures i have.
I created an array of two slick2d textures, like so: Texture[2] tex; …And loaded the into tex[0] and tex[1].
When i load the map file to an array and then try passing the texture with the array index being the current index of the map array which passes either 1 or 0 as the texture index.
for (int yTile = 0; yTile < 640 / 64; yTile++) {
for (int xTile = 0; xTile < 768 / 64; xTile++) {
int i = 0;
Tile tile = (Tile)tiles.get(i);
tile.render(tex[map[i]], xTile * Tile.TILE_WIDTH, yTile * Tile.TILE_HEIGHT);
i++;
}
}
All i get is one of the tile textures rendered.
Here is the tile class’s render method:
public void render(Texture bindTex, int xOff, int yOff) {
bindTex.bind();
glBegin(GL_QUADS);
glTexCoord2f(0.0f, 0.0f);
glVertex2i(xOff, yOff);
glTexCoord2f(1.0f, 0.0f);
glVertex2i(xOff + TILE_WIDTH, yOff);
glTexCoord2f(1.0f, 1.0f);
glVertex2i(xOff +TILE_WIDTH, yOff + TILE_HEIGHT);
glTexCoord2f(0.0f, 1.0f);
glVertex2i(xOff, yOff +TILE_HEIGHT);
glEnd();
}
What is happening?