You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

68 lines
1.2 KiB

#include "isometricMap.h"
#include <stdio.h>
#include <stdlib.h>
IsometricMap * IsometricMapInit(int x, int y){
IsometricMap* map = (IsometricMap *) malloc(sizeof(IsometricMap));
//Texture2D textures[10];
map->tileTextures[0] = LoadTexture("assets/grass.png");
map->tileTextures[1] = LoadTexture("assets/tower.png");
//map->tileTextures = textures;
Tile* tiles[x];
int n = 0;
for(n=0; n<x; n++){
tiles[n] = (Tile*)malloc(y*sizeof(Tile));
}
//printf("%ld\n", sizeof(tiles));
map->sizeX = x;
map->sizeY = y;
int i = 0;
int j = 0;
for(i=0; i < x; i++){
for(j=0; j < y; j++){
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};
Vector2* offset = (Vector2 *)malloc(sizeof(Vector2));
offset->x = x * textureSize/2;
offset->y = x * textureSize/4;
offset->x -= y * textureSize/2;
offset->y += y * textureSize/4;
return offset;
}