parent
6178a9fc57
commit
358d5e3481
@ -1,5 +1,6 @@
|
|||||||
{
|
{
|
||||||
"files.associations": {
|
"files.associations": {
|
||||||
"inputhandling.h": "c"
|
"inputhandling.h": "c",
|
||||||
|
"isometricmap.h": "c"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Binary file not shown.
@ -0,0 +1,62 @@
|
|||||||
|
#include "isometricMap.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
IsometricMap * IsometricMapInit(int x, int y){
|
||||||
|
IsometricMap *map = (IsometricMap *) malloc(sizeof(IsometricMap));
|
||||||
|
Texture textures[10];
|
||||||
|
textures[0] = LoadTexture("assets/grass.png");
|
||||||
|
textures[1] = LoadTexture("assets/tower.png");
|
||||||
|
map->tileTextures = &textures;
|
||||||
|
|
||||||
|
//Tile *tiles[x][y];
|
||||||
|
Tile **tiles = (Tile **)malloc(x * sizeof(Tile *));
|
||||||
|
int n = 0;
|
||||||
|
for(n = 0; n < x; ++n){
|
||||||
|
tiles[n] = (Tile *)malloc(y * sizeof(Tile));
|
||||||
|
}
|
||||||
|
|
||||||
|
map->sizeX = x;
|
||||||
|
map->sizeY = y;
|
||||||
|
|
||||||
|
int i = 0;
|
||||||
|
int j = 0;
|
||||||
|
|
||||||
|
for(i=0; i < x; i++){
|
||||||
|
for(i=0; i < y; i++){
|
||||||
|
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};
|
||||||
|
|
||||||
|
offset.x = x * textureSize/2;
|
||||||
|
offset.y = x * textureSize/4;
|
||||||
|
|
||||||
|
offset.x -= y * textureSize/2;
|
||||||
|
offset.y += y * textureSize/4;
|
||||||
|
|
||||||
|
return &offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -0,0 +1,24 @@
|
|||||||
|
#ifndef ISOMETRICMAP_H_
|
||||||
|
#define ISOMETRICMAP_H_
|
||||||
|
#include "raylib.h"
|
||||||
|
#include "tile.c"
|
||||||
|
|
||||||
|
typedef struct IsometricMap{
|
||||||
|
Texture *tileTextures;
|
||||||
|
//tiles -> two dimensional Array
|
||||||
|
Tile *tiles;
|
||||||
|
int sizeX;
|
||||||
|
int sizeY;
|
||||||
|
} IsometricMap;
|
||||||
|
|
||||||
|
void IsometricMapAddTile(IsometricMap isometricMap);
|
||||||
|
|
||||||
|
Tile IsometricMapGetTileFromArrayPosition(int x, int y);
|
||||||
|
|
||||||
|
Tile IsometricMapGetTileFromWorldCoordinates(float x, float y);
|
||||||
|
|
||||||
|
Vector2 * IsometricMapCalcOffsetForTileAt(int x, int y, int textureSize);
|
||||||
|
|
||||||
|
IsometricMap * IsometricMapInit(int x, int y);
|
||||||
|
|
||||||
|
#endif
|
||||||
@ -1,11 +1,14 @@
|
|||||||
#ifndef ISOMETRICRENDERER_H_
|
#ifndef ISOMETRICRENDERER_H_
|
||||||
#define ISOMETRICRENDERER_H_
|
#define ISOMETRICRENDERER_H_
|
||||||
#include "raylib.h"
|
#include "raylib.h"
|
||||||
|
#include "isometricMap.h"
|
||||||
|
|
||||||
typedef struct IsometricRenderer{
|
typedef struct IsometricRenderer{
|
||||||
Texture texture;
|
Texture *texture;
|
||||||
} IsometricRenderer;
|
} IsometricRenderer;
|
||||||
|
|
||||||
void renderMap(int width, int height);
|
void IsometricRendererDrawMap(IsometricRenderer *renderer, int height);
|
||||||
|
|
||||||
|
void IsometricRendererRenderIsometricMap(IsometricMap *map);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
Binary file not shown.
Loading…
Reference in new issue