|
|
|
|
@ -7,26 +7,20 @@
|
|
|
|
|
#include "../Sprite/sprite.h"
|
|
|
|
|
#include "../game.h"
|
|
|
|
|
|
|
|
|
|
IsometricMap * IsometricMapInit(){
|
|
|
|
|
IsometricMap * IsometricMapInit(Game *game){
|
|
|
|
|
IsometricMap* map = malloc(sizeof(IsometricMap));
|
|
|
|
|
|
|
|
|
|
int counter = 0;
|
|
|
|
|
map->tileTextures[counter++] = LoadTexture("assets/tiles/grass.png");
|
|
|
|
|
map->tileTextures[counter++] = LoadTexture("assets/tiles/desert.png");
|
|
|
|
|
map->tileTextures[counter++] = LoadTexture("assets/tiles/desert_palm.png");
|
|
|
|
|
map->tileTextures[counter++] = LoadTexture("assets/tiles/tower.png");
|
|
|
|
|
map->tileTextures[counter++] = LoadTexture("assets/tiles/bigtower.png");
|
|
|
|
|
map->tileTextures[counter++] = LoadTexture("assets/tiles/grass_selected.png");
|
|
|
|
|
map->tileTextures[counter++] = LoadTexture("assets/tiles/ice.png");
|
|
|
|
|
map->tileTextures[counter++] = LoadTexture("assets/tiles/water.png");
|
|
|
|
|
map->tileTextures[counter++] = LoadTexture("assets/tiles/empty.png");
|
|
|
|
|
|
|
|
|
|
for(counter = 0; counter < TE_TILES_LENGTH; counter++){
|
|
|
|
|
map->tileTextures[counter] = &(game->textures->textures[TE_TILES][counter]);
|
|
|
|
|
}
|
|
|
|
|
map->width = 500;
|
|
|
|
|
map->height = 500;
|
|
|
|
|
map->textureWidth = map->tileTextures[0].width;
|
|
|
|
|
map->textureHeight = map->tileTextures[0].height;
|
|
|
|
|
map->textureWidth = map->tileTextures[0]->width;
|
|
|
|
|
map->textureHeight = map->tileTextures[0]->height;
|
|
|
|
|
map->worldPixelWidth = map->width * map->textureWidth;
|
|
|
|
|
map->worldPixelWidth = map->height * map->textureHeight;
|
|
|
|
|
map->timer = 0;
|
|
|
|
|
|
|
|
|
|
// mallocating the twodimensional Tiles Array
|
|
|
|
|
Tile*** tiles = malloc(map->width*sizeof(Tile*));
|
|
|
|
|
@ -135,6 +129,22 @@ void IsometricMapChangeTextureIdOfTile(IsometricMap *map, int x, int y, int id){
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void IsometricMapDraw(Game *game){
|
|
|
|
|
|
|
|
|
|
game->map->timer += GetFrameTime();
|
|
|
|
|
if(game->map->timer > 0.2f){
|
|
|
|
|
game->map->tileTextures[7] = &(game->textures->textures[TE_TILES][9]);
|
|
|
|
|
}
|
|
|
|
|
if(game->map->timer > 0.4f){
|
|
|
|
|
game->map->tileTextures[7] = &(game->textures->textures[TE_TILES][10]);
|
|
|
|
|
}
|
|
|
|
|
if(game->map->timer > 0.6f){
|
|
|
|
|
game->map->tileTextures[7] = &(game->textures->textures[TE_TILES][11]);
|
|
|
|
|
}
|
|
|
|
|
if(game->map->timer > 0.8f){
|
|
|
|
|
game->map->tileTextures[7] = &(game->textures->textures[TE_TILES][7]);
|
|
|
|
|
game->map->timer = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int windowWidth = GetScreenWidth();
|
|
|
|
|
int windowHeight = GetScreenHeight();
|
|
|
|
|
Vector2 topleft = {0, 0};
|
|
|
|
|
@ -164,11 +174,10 @@ void IsometricMapDraw(Game *game){
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
;
|
|
|
|
|
DrawTexture(
|
|
|
|
|
game->map->tileTextures[game->map->tiles[i][j]->textureId],
|
|
|
|
|
*(game->map->tileTextures[game->map->tiles[i][j]->textureId]),
|
|
|
|
|
game->map->tiles[i][j]->offsetX,
|
|
|
|
|
game->map->tiles[i][j]->offsetY - game->map->tileTextures[game->map->tiles[i][j]->textureId].height + 32,
|
|
|
|
|
game->map->tiles[i][j]->offsetY - game->map->tileTextures[game->map->tiles[i][j]->textureId]->height + 32,
|
|
|
|
|
WHITE);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|