|
|
|
|
@ -5,20 +5,20 @@
|
|
|
|
|
#include "raymath.h"
|
|
|
|
|
#include "raylib.h"
|
|
|
|
|
|
|
|
|
|
IsometricMap * IsometricMapInit(int x, int y){
|
|
|
|
|
IsometricMap * IsometricMapInit(int x, int y, int layer){
|
|
|
|
|
IsometricMap* map = (IsometricMap *) malloc(sizeof(IsometricMap));
|
|
|
|
|
map->tileTextures[0] = LoadTexture("assets/grass.png");
|
|
|
|
|
map->tileTextures[1] = LoadTexture("assets/tower.png");
|
|
|
|
|
|
|
|
|
|
map->originX = 0;
|
|
|
|
|
map->originY = 0;
|
|
|
|
|
map->originY = -layer * map->tileTextures[0].width / 4;
|
|
|
|
|
map->width = x * map->tileTextures[0].width;
|
|
|
|
|
map->height = y * map->tileTextures[0].height;
|
|
|
|
|
|
|
|
|
|
Tile* tiles[x];
|
|
|
|
|
Tile*** tiles = (Tile***)malloc(x*sizeof(Tile*));
|
|
|
|
|
int n = 0;
|
|
|
|
|
for(n=0; n<x; n++){
|
|
|
|
|
tiles[n] = (Tile*)malloc(y*sizeof(Tile));
|
|
|
|
|
tiles[n] = (Tile**)malloc(y*sizeof(Tile*));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
map->sizeX = x;
|
|
|
|
|
@ -29,14 +29,11 @@ IsometricMap * IsometricMapInit(int x, int y){
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
Tile *tmp = (Tile *) malloc(sizeof(Tile));
|
|
|
|
|
tmp->textureId = 0;
|
|
|
|
|
tmp->x = i;
|
|
|
|
|
tmp->y = j;
|
|
|
|
|
tiles[i][j] = tmp;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
map->tiles = tiles;
|
|
|
|
|
@ -59,7 +56,7 @@ Vector2 * IsometricMapCalcOffsetForTileAt(int x, int y, int textureSize){
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Tile * IsometricMapGetTileFromArrayPosition(IsometricMap *map, int x, int y){
|
|
|
|
|
return &(map->tiles[x][y]);
|
|
|
|
|
return map->tiles[x][y];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void IsometricMapProject(IsometricMap *isometricMap, Camera2D *camera, int x, int y, Vector2 *tmp){
|
|
|
|
|
@ -90,6 +87,21 @@ void IsometricMapProject(IsometricMap *isometricMap, Camera2D *camera, int x, in
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void IsometricMapAddTile(IsometricMap *isometricMap, int x, int y, int textureId){
|
|
|
|
|
|
|
|
|
|
//if(x < isometricMap->sizeX && y < isometricMap->sizeY){
|
|
|
|
|
|
|
|
|
|
Tile *tile = (Tile *) malloc(sizeof(Tile));
|
|
|
|
|
tile->textureId = textureId;
|
|
|
|
|
tile->x = x;
|
|
|
|
|
tile->y = y;
|
|
|
|
|
|
|
|
|
|
//Tile tile = {textureId, x, y};
|
|
|
|
|
isometricMap->tiles[x][y] = tile;
|
|
|
|
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|