diff --git a/DepthSorting/bucket.c b/DepthSorting/bucket.c deleted file mode 100644 index 80b1500..0000000 --- a/DepthSorting/bucket.c +++ /dev/null @@ -1,68 +0,0 @@ -#include "bucket.h" -#include "stdio.h" -#include "stdlib.h" -#include "../sprite.h" -#include "../IsometricMap/tile.h" - -Bucket * BucketInit(void *data, int type){ - Bucket *bucket = malloc(sizeof(Bucket)); - - if(type == SPRITE){ - bucket->sprite = (Sprite *) data; - bucket->tile = 0; - bucket->depth = bucket->sprite->x + bucket->sprite->y + bucket->sprite->z; - } - else if(type == TILE){ - bucket->sprite = 0; - bucket->tile = (Tile *) data; - bucket->depth = bucket->tile->x * 32 + bucket->tile->y * 32 + bucket->tile->z; - } - else{ - printf("WARNING: BucketInit called with unknown type! Undefined behavior expected\n"); - } - - bucket->type = type; - - bucket->left = 0; - bucket->right = 0; - - return bucket; - -} - -void BucketInsert(Bucket *head, Bucket *new){ - Bucket *current = head; - - while(current != 0){ - if(current->depth > new->depth){ - // Rechter Teilbaum - if(current->right != 0){ - current = current->right; - } - else{ - current->right = new; - break; - } - } - else{ - // Linker Teilbaum - if(current->left != 0){ - current = current->left; - } - else{ - current->left = new; - break; - } - } - } -} - -void BucketRemove(Bucket *head, Bucket *new){ - if(new->left == 0){ - - } -} - -void BucketChanged(Bucket *head, Bucket *changed){ - -} diff --git a/DepthSorting/bucket.h b/DepthSorting/bucket.h deleted file mode 100644 index 949276d..0000000 --- a/DepthSorting/bucket.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef BUCKET_H_ -#define BUCKET_H_ -#include "raylib.h" - -#define SPRITE 0 -#define TILE 1 - -typedef struct Sprite Sprite; -typedef struct Tile Tile; - -typedef struct Bucket{ - int type; - Sprite *sprite; - Tile *tile; - float depth; - - struct Bucket *left; - struct Bucket *right; -} Bucket; - -Bucket * BucketInit(void *data, int type); - -void BucketInsert(struct Bucket *head, struct Bucket *new); - -void BucketRemove(struct Bucket *head, struct Bucket *new); - -void BucketChanged(struct Bucket *head, struct Bucket *changed); - -#endif \ No newline at end of file diff --git a/IsometricMap/isometricMap.c b/IsometricMap/isometricMap.c index 5213bbf..7515b21 100644 --- a/IsometricMap/isometricMap.c +++ b/IsometricMap/isometricMap.c @@ -4,7 +4,6 @@ #include "tile.h" #include "raymath.h" #include "raylib.h" -#include "../DepthSorting/bucket.h" #include "../game.h" #include "../List/list.h" @@ -51,7 +50,6 @@ IsometricMap * IsometricMapInit(int layer){ tmp->offsetX = offset->x; tmp->offsetY = offset->y; free(offset); - tmp->sortable = BucketInit(tmp, TILE); tiles[i][j] = tmp; } } @@ -154,10 +152,6 @@ void IsometricMapChangeTextureIdOfTile(IsometricMap **map, int x, int y, int lay } void IsometricMapDraw(Game *game){ - // TODO: Implement as List - Bucket *buckets[100000]; - int counter = 0; - int windowWidth = GetScreenWidth(); int windowHeight = GetScreenHeight(); Vector2 topleft = {0, 0}; @@ -179,6 +173,8 @@ void IsometricMapDraw(Game *game){ 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, j = 0; for (n = 0; n < 10; n++){ for (j = jtmp; j < maxJ; j++){ @@ -192,44 +188,8 @@ void IsometricMapDraw(Game *game){ } } } + */ //printf("\n\n\n"); - Node *current = game->sprites->head; - int extraPixels = 0; - // drawing some extra corner pixels - // if extraPixels == 0 you can see flickering in the corners - itmp = (int)(topleft.x) - extraPixels; - jtmp = (int)(topright.y) - extraPixels; - maxI = (int)(botright.x) + extraPixels; - maxJ = (int)(botleft.y) + extraPixels; - while(current != 0){ - // Only drawing the Sprites which are within Camera view - if( current->data->x > itmp && - current->data->y > jtmp && - current->data->x < maxI && - current->data->y < maxJ){ - buckets[counter] = current->data->sortable; - ++counter; - } - current = current->next; - } - - int hmmm = counter; - // Merge Sort ist scuffed - //MergeSort(buckets, hmmm); - - int k = 0; - for(k = 0; k < counter; k++){ - if(buckets[k]->type == 1){ - DrawTexture( - game->layers[0]->tileTextures[buckets[k]->tile->textureId], - buckets[k]->tile->offsetX, - buckets[k]->tile->offsetY, - WHITE); - } - else if(buckets[k]->type == 0){ - DrawSpriteToWorld(buckets[k]->sprite, game->layers, game->camera); - } - } -} \ No newline at end of file +} diff --git a/IsometricMap/tile.h b/IsometricMap/tile.h index 455f2ac..ccb2018 100644 --- a/IsometricMap/tile.h +++ b/IsometricMap/tile.h @@ -1,7 +1,6 @@ #ifndef TILE_H_ #define TILE_H_ #include "raylib.h" -#include "../DepthSorting/bucket.h" // Tile with textureid = -1 wouldn't be drawed, would just be a placeholder tile typedef struct Tile{ @@ -11,7 +10,6 @@ typedef struct Tile{ int z; int offsetX; int offsetY; - Bucket *sortable; } Tile; -#endif \ No newline at end of file +#endif diff --git a/Makefile b/Makefile index 9e23ea7..7581793 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ CC = gcc FLAGS = -lraylib -lGL -lm -lpthread -ldl -lrt -lX11 -OBJS = main.o sprite.o inputHandler.o isometricMap.o list.o game.o textureatlas.o animation.o animationHandler.o bucket.o button.o uiContainer.o debug.o +OBJS = main.o sprite.o inputHandler.o isometricMap.o list.o game.o textureatlas.o animation.o animationHandler.o button.o uiContainer.o debug.o spiel: $(OBJS) $(CC) -o spiel $(OBJS) $(FLAGS) @@ -32,9 +32,6 @@ animation.o: Textures/animation.c animationHandler.o: Textures/animationHandler.c $(CC) -c Textures/animationHandler.c $(FLAGS) -bucket.o: DepthSorting/bucket.c - $(CC) -c DepthSorting/bucket.c $(FLAGS) - button.o: Ui/button.c $(CC) -c Ui/button.c $(FLAGS) diff --git a/main.c b/main.c index e74c061..475afd3 100644 --- a/main.c +++ b/main.c @@ -8,7 +8,6 @@ #include "List/list.h" #include "IsometricMap/isometricMap.h" #include "game.h" -#include "DepthSorting/bucket.h" #include "Ui/screenIDs.h" #include "Ui/button.h" #include "Ui/uiContainer.h" @@ -120,4 +119,4 @@ int main(){ return 0; -} \ No newline at end of file +} diff --git a/sprite.c b/sprite.c index 48d21a0..3d2b0c7 100644 --- a/sprite.c +++ b/sprite.c @@ -8,7 +8,6 @@ #include "Textures/animation.h" #include "Textures/textureatlas.h" #include "IsometricMap/tile.h" -#include "DepthSorting/bucket.h" void DrawSpriteToWorld(Sprite *sprite, IsometricMap **map, Camera2D *camera){ @@ -71,7 +70,5 @@ Sprite * SpriteCreate(TextureAtlas *atlas, int textureID, int x, int y){ newSprite->selected = 0; newSprite->depth = newSprite->x + newSprite->y; - newSprite->sortable = BucketInit(newSprite, SPRITE); - return newSprite; } diff --git a/sprite.h b/sprite.h index 7da288c..6dc36ec 100644 --- a/sprite.h +++ b/sprite.h @@ -4,7 +4,6 @@ #include "IsometricMap/isometricMap.h" #include "Textures/animationHandler.h" #include "Textures/textureatlas.h" -#include "DepthSorting/bucket.h" typedef struct Sprite { AnimationHandler *animationHandler; @@ -17,7 +16,6 @@ typedef struct Sprite { int hasDestination; int selected; float depth; - Bucket *sortable; } Sprite; void DrawSpriteToWorld(Sprite *sprite, IsometricMap **map, Camera2D *camera);