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.

62 lines
1.6 KiB

#include "isometricRenderer.h"
#include "raylib.h"
#include "isometricMap.h"
#include <stdio.h>
//TODO: Isometric Tilemap Struct, which can be scanned for clicked Tile
// General coordinate translation function
void IsometricRendererDrawMap(IsometricRenderer *renderer, int height){
float originX = 0.0f;
float originY = 0.0f;
int i = 0;
int j = 0;
int amount = 1;
for(i=0; i<=height; i++){
for(j=0; j<amount; j++){
float x = originX - amount/2 * renderer->texture->width + j * renderer->texture->width;
if(amount%2 == 1){
x -= renderer->texture->width/2;
}
float y = i * renderer->texture->height/4;
DrawTexture(*renderer->texture, x, y, WHITE);
}
if(i < height/2){
amount++;
}
else{
amount--;
}
}
}
void IsometricRendererRenderIsometricMap(IsometricMap *map){
float originX = 0.0f;
float originY = 0.0f;
int i = 0;
int j = 0;
for(i=0; i < map->sizeX; i++){
for(j=0; j < map->sizeY; j++){
Vector2 *offset = IsometricMapCalcOffsetForTileAt(i,j, map->tileTextures[0].width);
float x = originX + offset->x;
float y = originY + offset->y;
// TODO: Komischer "Bug"
// map sollte ein 2-dimensionaler Array aus Tiles sein
// -> 2 Dimensionaler Array aus pointern
// wird in IsometricMapInit erzeugt
int textureId = (*(*map->tiles[i])[j]).textureId;
DrawTexture(map->tileTextures[textureId], x, y, WHITE);
}
}
}