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.
64 lines
1.8 KiB
64 lines
1.8 KiB
#include "isometricRenderer.h"
|
|
#include "raylib.h"
|
|
#include "isometricMap.h"
|
|
#include "../Input/inputHandler.h"
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
|
|
// @param deprecated
|
|
void IsometricRendererDrawMap(IsometricRenderer *renderer, int height){
|
|
|
|
printf("WARNING: Using deprecated Function IsometricRendererDrawMap!\n");
|
|
|
|
|
|
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, InputHandler *input){
|
|
int n = 0;
|
|
int i = 0;
|
|
int j = 0;
|
|
for(n = 0; n < 10; n++){
|
|
for(i=0; i < map[n]->widthBounds; i++){
|
|
for(j=0; j < map[n]->heightBounds; j++){
|
|
if(map[n]->tiles[i][j]->textureId != -1){
|
|
Vector2 *offset = IsometricMapCalcOffsetForTileAt(i,j, map[n]->textureWidth);
|
|
|
|
int textureId = map[n]->tiles[i][j]->textureId;
|
|
|
|
float x = map[n]->originX + offset->x;
|
|
float y = map[n]->originY + offset->y;// + map[n]->textureHeight - map[n]->tileTextures[textureId].height;
|
|
|
|
|
|
DrawTexture(map[n]->tileTextures[textureId], x, y, WHITE);
|
|
free(offset);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|