tile texture matching

This commit is contained in:
David Husicka 2021-12-14 17:47:10 +01:00
parent 516155670a
commit fcb13db79e
1 changed files with 10 additions and 2 deletions

View File

@ -48,7 +48,7 @@ void gui_init() {
// load up textures
tile_texture = texture_from_png("res/tile.png");
tile_textures[0] = tile_textures;
tile_textures[0] = tile_texture;
tile_textures[1] = texture_from_png("res/2.png");
tile_textures[3] = texture_from_png("res/4.png");
tile_textures[4] = texture_from_png("res/8.png");
@ -98,7 +98,15 @@ void gui_loop(Game *game) {
tile_rect.x = i * 175;
for (int j = 0; j < game->field_size_y; j++) {
tile_rect.y = j * 175;
SDL_RenderCopy( window_renderer, tile_texture, NULL, &tile_rect);
// get texture index from value
for (int k = 0; k < 13; k++) {
if (!(game->field[i][j] >> k)) {
SDL_RenderCopy( window_renderer, tile_textures[k], NULL, &tile_rect);
break;
}
}
// SDL_RenderCopy( window_renderer, tile_texture, NULL, &tile_rect);
}
}
SDL_RenderPresent(window_renderer);