diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json index ba9207f..f52f716 100644 --- a/.vscode/c_cpp_properties.json +++ b/.vscode/c_cpp_properties.json @@ -9,7 +9,8 @@ "compilerPath": "/usr/bin/gcc", "cStandard": "gnu17", "cppStandard": "gnu++17", - "intelliSenseMode": "linux-gcc-x64" + "intelliSenseMode": "linux-gcc-x64", + "configurationProvider": "ms-vscode.makefile-tools" } ], "version": 4 diff --git a/inputHandler.o b/inputHandler.o new file mode 100644 index 0000000..91d79f0 Binary files /dev/null and b/inputHandler.o differ diff --git a/isometricMap.c b/isometricMap.c index cae96be..f2f8dd6 100644 --- a/isometricMap.c +++ b/isometricMap.c @@ -1,28 +1,31 @@ #include "isometricMap.h" #include +#include 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)); - } + IsometricMap* map = (IsometricMap *) malloc(sizeof(IsometricMap)); + //Texture2D textures[10]; + map->tileTextures[0] = LoadTexture("assets/grass.png"); + map->tileTextures[1] = LoadTexture("assets/tower.png"); + //map->tileTextures = textures; + + Tile* tiles[x]; + int n = 0; + for(n=0; nsizeX = x; map->sizeY = y; int i = 0; int j = 0; + for(i=0; i < x; i++){ - for(i=0; i < y; i++){ + for(j=0; j < y; j++){ if(i != j){ Tile tmp = {0, i, j}; tiles[i][j] = tmp; @@ -41,15 +44,17 @@ IsometricMap * IsometricMapInit(int x, int y){ Vector2 * IsometricMapCalcOffsetForTileAt(int x, int y, int textureSize){ - Vector2 offset = {0, 0}; + //Vector2 offset = {0, 0}; + + Vector2* offset = (Vector2 *)malloc(sizeof(Vector2)); - offset.x = x * textureSize/2; - offset.y = x * textureSize/4; + offset->x = x * textureSize/2; + offset->y = x * textureSize/4; - offset.x -= y * textureSize/2; - offset.y += y * textureSize/4; + offset->x -= y * textureSize/2; + offset->y += y * textureSize/4; - return &offset; + return offset; } diff --git a/isometricMap.h b/isometricMap.h index edadb8f..5a77fb0 100644 --- a/isometricMap.h +++ b/isometricMap.h @@ -4,9 +4,9 @@ #include "tile.c" typedef struct IsometricMap{ - Texture *tileTextures; + Texture2D tileTextures[10]; //tiles -> two dimensional Array - Tile *tiles; + Tile **tiles; int sizeX; int sizeY; } IsometricMap; diff --git a/isometricMap.o b/isometricMap.o new file mode 100644 index 0000000..a5159da Binary files /dev/null and b/isometricMap.o differ diff --git a/isometricRenderer.c b/isometricRenderer.c index e114378..ed2c6ac 100644 --- a/isometricRenderer.c +++ b/isometricRenderer.c @@ -44,16 +44,16 @@ void IsometricRendererRenderIsometricMap(IsometricMap *map){ 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; - + // TODO -> results in Segmentation fault + //int textureId = map->tiles[i][j].textureId; + int textureId = 0; + if(i + j == 9){ + textureId = 1; + } DrawTexture(map->tileTextures[textureId], x, y, WHITE); } } diff --git a/isometricRenderer.o b/isometricRenderer.o new file mode 100644 index 0000000..cfb8467 Binary files /dev/null and b/isometricRenderer.o differ diff --git a/main.c b/main.c index 9f57f96..54c0991 100644 --- a/main.c +++ b/main.c @@ -1,5 +1,6 @@ #include "raylib.h" #include "stdio.h" +#include #include "sprite.h" #include "inputHandler.h" #include "raymath.h" @@ -31,7 +32,7 @@ int main(){ SpriteAdd(sprites, &spriteAmount, &texture, 0, 0); - IsometricMap *map = IsometricMapInit(10, 10); + IsometricMap *map = IsometricMapInit(20, 10); SetTargetFPS(60); while(!WindowShouldClose()){ diff --git a/main.o b/main.o new file mode 100644 index 0000000..04d3f5e Binary files /dev/null and b/main.o differ diff --git a/spiel b/spiel new file mode 100755 index 0000000..5b3d1c4 Binary files /dev/null and b/spiel differ diff --git a/sprite.o b/sprite.o new file mode 100644 index 0000000..a7d1287 Binary files /dev/null and b/sprite.o differ diff --git a/tile.o b/tile.o new file mode 100644 index 0000000..ec204ad Binary files /dev/null and b/tile.o differ