|
Projeto IDJ - Towers Of Madness
TowerDefenseLovecraftnianoZombicida
|
Classe responsável por modelar um tileset. Mais...
#include <Tileset.h>
Métodos Públicos | |
| TileSet (int tileWidth, int tileHeight, string file) | |
| Instancia um tileSet. Mais... | |
| void | Render (unsigned int index, Vec2 pos, bool highlighted=false) |
| Renderiza tile. Mais... | |
| int | GetTileWidth (void) |
| Obtém largura de um tile. Mais... | |
| int | GetTileHeight (void) |
| Obtém altura de um tile. Mais... | |
Atributos Privados | |
| Sprite | tileSet |
| int | rows |
| int | columns |
| int | tileWidth |
| int | tileHeight |
Classe responsável por modelar um tileset.
Um tileSet é uma imagem que contém várias subimagens, que são idexadas por sua posição no arquivo.
| TileSet::TileSet | ( | int | tileWidth, |
| int | tileHeight, | ||
| string | file | ||
| ) |
Instancia um tileSet.
| tileWidth | Espessura de uma subimagem do tileSet. |
| tileHeight | Altura de uma subimagem do tileSet. |
| file | Nome do arquivo de imagem com o TileSet. |
Instancia o sprite interno com o arquivo informado, inicializa tileWidth e tileHeight com os argumentos dados. Depois, através do quociente da largura do spirte pelo tileWidth obtém-se o valor inicial de columns e similarmente usando a altura do sprite e o tileHeight, o valor inicial para rows.
| int TileSet::GetTileHeight | ( | void | ) |
Obtém altura de um tile.
Retorna tileHeight.
| int TileSet::GetTileWidth | ( | void | ) |
Obtém largura de um tile.
Retorna tileWidth.
| void TileSet::Render | ( | unsigned int | index, |
| Vec2 | pos, | ||
| bool | highlighted = false |
||
| ) |
Renderiza tile.
| index | Índice do tile no tileSet. |
| pos | Posição x,y onde o tile deve ser renderizado. |
| highlighted | Verdadeiro se for para o tile sofrer um Highlight. |
Usando aritmética de módulo conseguimos associar o index à uma posição (linha, coluna) na matriz de tiles. Essa informação é usada para entaão obter o x e y do tile no sprite. Após isso calcula-se o rect onde essa imagem será renderizada utilizando o x e y enviados como argumento e atribuindo a w e h tileWidth e tileHeight. Nesse momento, solicita-se para a câmera transformar a posição no mundo para a posição na tela. Após isso, renderiza-se o tile informado na posição calculada da tela.
|
private |
Número de colunas de tiles existentes no tileSet.
|
private |
Número de lilhas de tiles existentes no tileSet.
|
private |
Altura de um tile.
|
private |
Espessura de um tile.
1.8.8