|
|
|
|
@ -7,10 +7,10 @@
|
|
|
|
|
#include "../game.h"
|
|
|
|
|
|
|
|
|
|
// @param deprecated
|
|
|
|
|
void IsometricRendererDrawMap(IsometricRenderer *renderer, int height){
|
|
|
|
|
void IsometricRendererDrawMap(IsometricRenderer *renderer, int height)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
printf("WARNING: Using deprecated Function IsometricRendererDrawMap!\n");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
float originX = 0.0f;
|
|
|
|
|
float originY = 0.0f;
|
|
|
|
|
@ -19,28 +19,33 @@ void IsometricRendererDrawMap(IsometricRenderer *renderer, int height){
|
|
|
|
|
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;
|
|
|
|
|
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;
|
|
|
|
|
float y = i * renderer->texture->height / 4;
|
|
|
|
|
DrawTexture(*renderer->texture, x, y, WHITE);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if(i < height/2){
|
|
|
|
|
if (i < height / 2)
|
|
|
|
|
{
|
|
|
|
|
amount++;
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
amount--;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// parameter could be changed to only IsometricMap[]
|
|
|
|
|
void IsometricRendererRenderIsometricMap(Game *game){
|
|
|
|
|
void IsometricRendererRenderIsometricMap(Game *game)
|
|
|
|
|
{
|
|
|
|
|
/*
|
|
|
|
|
int n = 0;
|
|
|
|
|
int i = 0;
|
|
|
|
|
int j = 0;
|
|
|
|
|
@ -51,17 +56,74 @@ void IsometricRendererRenderIsometricMap(Game *game){
|
|
|
|
|
if(game->layers[n]->tiles[i][j]->textureId == -1){
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
int quarterTextureSize = game->layers[n]->textureWidth / 4;
|
|
|
|
|
int halfTextureSize = game->layers[n]->textureWidth / 2;
|
|
|
|
|
// SHOULD BE SET ONCE INITIALLY
|
|
|
|
|
Vector2 *offset = IsometricMapCalcOffsetForTileAtEfficient(i,j, halfTextureSize, quarterTextureSize);
|
|
|
|
|
// the higher the layer the higher it needs to be drawed
|
|
|
|
|
offset->y -= n * quarterTextureSize;
|
|
|
|
|
|
|
|
|
|
int textureId = game->layers[n]->tiles[i][j]->textureId;
|
|
|
|
|
|
|
|
|
|
DrawTexture(game->layers[n]->tileTextures[textureId], offset->x, offset->y, WHITE);
|
|
|
|
|
free(offset);
|
|
|
|
|
DrawTexture(
|
|
|
|
|
game->layers[n]->tileTextures[game->layers[n]->tiles[i][j]->textureId],
|
|
|
|
|
game->layers[n]->tiles[i][j]->offsetX,
|
|
|
|
|
game->layers[n]->tiles[i][j]->offsetY,
|
|
|
|
|
WHITE);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
int windowWidth = GetScreenWidth();
|
|
|
|
|
int windowHeight = GetScreenHeight();
|
|
|
|
|
|
|
|
|
|
// HARDCODED
|
|
|
|
|
Vector2 topleft = {0, 0};
|
|
|
|
|
IsometricMapProject(game->layers[0], game->camera, topleft.x, topleft.y, &topleft);
|
|
|
|
|
Vector2 topright = {windowWidth, 0};
|
|
|
|
|
IsometricMapProject(game->layers[0], game->camera, topright.x, topright.y, &topright);
|
|
|
|
|
Vector2 botleft = {0, windowHeight};
|
|
|
|
|
IsometricMapProject(game->layers[0], game->camera, botleft.x, botleft.y, &botleft);
|
|
|
|
|
Vector2 botright = {windowWidth, windowHeight};
|
|
|
|
|
IsometricMapProject(game->layers[0], game->camera, botright.x, botright.y, &botright);
|
|
|
|
|
|
|
|
|
|
printf("%f\n", topright.y);
|
|
|
|
|
// drawing some extra corner tiles
|
|
|
|
|
// if extraTiles == 0 you can see flickering in the corners
|
|
|
|
|
int extraTiles = 1;
|
|
|
|
|
int n = 0;
|
|
|
|
|
int itmp = (int)(topleft.x / game->layers[0]->textureWidth) - extraTiles;
|
|
|
|
|
int jtmp = (int)(topright.y / game->layers[0]->textureHeight) - extraTiles;
|
|
|
|
|
int maxI = (int)(botright.x / game->layers[0]->textureWidth) + extraTiles;
|
|
|
|
|
int maxJ = (int)(botleft.y / game->layers[0]->textureHeight) + extraTiles;
|
|
|
|
|
if (itmp < 0)
|
|
|
|
|
{
|
|
|
|
|
itmp = 0;
|
|
|
|
|
}
|
|
|
|
|
if (jtmp < 0)
|
|
|
|
|
{
|
|
|
|
|
jtmp = 0;
|
|
|
|
|
}
|
|
|
|
|
if (maxI > game->layers[0]->width)
|
|
|
|
|
{
|
|
|
|
|
maxI = game->layers[0]->width;
|
|
|
|
|
}
|
|
|
|
|
if (maxJ > game->layers[0]->height)
|
|
|
|
|
{
|
|
|
|
|
maxJ = game->layers[0]->height;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int i = 0;
|
|
|
|
|
int j = 0;
|
|
|
|
|
for (n = 0; n < 10; n++)
|
|
|
|
|
{
|
|
|
|
|
for (i = itmp; i < maxI; i++)
|
|
|
|
|
{
|
|
|
|
|
for (j = jtmp; j < maxJ; j++)
|
|
|
|
|
{
|
|
|
|
|
if (game->layers[n]->tiles[i][j]->textureId == -1)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
DrawTexture(
|
|
|
|
|
game->layers[n]->tileTextures[game->layers[n]->tiles[i][j]->textureId],
|
|
|
|
|
game->layers[n]->tiles[i][j]->offsetX,
|
|
|
|
|
game->layers[n]->tiles[i][j]->offsetY,
|
|
|
|
|
WHITE);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|