#include "isometricMap.h" #include IsometricMap * IsometricMapInit(int x, int y){ IsometricMap *map = (IsometricMap *) malloc(sizeof(IsometricMap)); Texture textures[10]; textures[0] = LoadTexture("assets/grass.png"); textures[1] = LoadTexture("assets/tower.png"); map->tileTextures = &textures; //Tile *tiles[x][y]; Tile **tiles = (Tile **)malloc(x * sizeof(Tile *)); int n = 0; for(n = 0; n < x; ++n){ tiles[n] = (Tile *)malloc(y * sizeof(Tile)); } map->sizeX = x; map->sizeY = y; int i = 0; int j = 0; for(i=0; i < x; i++){ for(i=0; i < y; i++){ if(i != j){ Tile tmp = {0, i, j}; tiles[i][j] = tmp; } else{ Tile tmp = {1, i, j}; tiles[i][j] = tmp; } } } map->tiles = tiles; return map; } Vector2 * IsometricMapCalcOffsetForTileAt(int x, int y, int textureSize){ Vector2 offset = {0, 0}; offset.x = x * textureSize/2; offset.y = x * textureSize/4; offset.x -= y * textureSize/2; offset.y += y * textureSize/4; return &offset; }