diff --git a/Input/inputHandler.c b/Input/inputHandler.c index 5653868..b25a232 100644 --- a/Input/inputHandler.c +++ b/Input/inputHandler.c @@ -122,10 +122,11 @@ void mouseInput(Game *game){ float width = GetMousePosition().x - inputHandler->rectStart.x; float height = GetMousePosition().y - inputHandler->rectStart.y; + // Add Sprite if(abs(width) + abs(height) < 20){ - int maxWidth = (game->layers[0]->width-1) * game->layers[0]->textureWidth; - int maxHeight = (game->layers[0]->height-1) * game->layers[0]->textureHeight; + int maxWidth = (game->layers[0]->width) * game->layers[0]->textureWidth; + int maxHeight = (game->layers[0]->height) * game->layers[0]->textureHeight; if(inputHandler->cursorWorldPos.x < 0){ printf("OutOfBoundsDestination Spawn\n");} else if(inputHandler->cursorWorldPos.y < 0){ printf("OutOfBoundsDestination Spawn\n");} else if(inputHandler->cursorWorldPos.x > maxWidth){ printf("OutOfBoundsDestination Spawn\n");} @@ -145,17 +146,17 @@ void mouseInput(Game *game){ float deltaY; Node *current = sprites->head; while (current != 0){ - Vector2 currPos = {current->data.x + current->data.texture->width, current->data.y + current->data.texture->height/2}; - IsometricMapUnproject(layers, camera, currPos.x, currPos.y, current->data.z, &currPos); + Vector2 currPos = {current->data->x + current->data->texture->width, current->data->y + current->data->texture->height/2}; + IsometricMapUnproject(layers, camera, currPos.x, currPos.y, current->data->z, &currPos); deltaX = currPos.x - camera->target.x - (rect.x + camera->target.x); deltaY = currPos.y - camera->target.y - (rect.y + camera->target.y); if(deltaX > 0 && deltaX < width && deltaY > 0 && deltaY < height){ - current->data.selected = 1; + current->data->selected = 1; } else{ - current->data.selected = 0; + current->data->selected = 0; } current = current->next; @@ -166,8 +167,8 @@ void mouseInput(Game *game){ Node *current = sprites->head; while (current != 0){ - if(current->data.selected){ - current->data.hasDestination = 1; + if(current->data->selected){ + current->data->hasDestination = 1; float destX = inputHandler->cursorWorldPos.x; float destY = inputHandler->cursorWorldPos.y; int maxWidth = (game->layers[0]->width-1) * game->layers[0]->textureWidth; @@ -177,8 +178,8 @@ void mouseInput(Game *game){ if(destX > maxWidth){ printf("OutOfBoundsDestination\n"); goto skip; } if(destY > maxHeight){ printf("OutOfBoundsDestination\n"); goto skip; } - current->data.destX = destX; - current->data.destY = destY; + current->data->destX = destX; + current->data->destY = destY; } skip: current = current->next; diff --git a/IsometricMap/isometricMap.c b/IsometricMap/isometricMap.c index 98e4e20..0947bc8 100644 --- a/IsometricMap/isometricMap.c +++ b/IsometricMap/isometricMap.c @@ -219,11 +219,11 @@ void IsometricMapDraw(Game *game){ 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; + 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; diff --git a/List/list.c b/List/list.c index c19dba4..395458f 100644 --- a/List/list.c +++ b/List/list.c @@ -8,7 +8,7 @@ Node * ListCreateNode(Sprite *data){ Node *new = (Node *) malloc(sizeof(Node)); - new->data = *data; + new->data = data; new->next = 0; new->prev = 0; return new; @@ -75,7 +75,7 @@ void ListInsertSorted(List *list, Sprite *data){ inserted = 0; continue; } - else if(data->y <= current->data.y){ + else if(data->y <= current->data->y){ if(current == list->head){ free(new); ListInsertFront(list, data); @@ -124,11 +124,11 @@ void ListDrawAllSprites(List *list, IsometricMap **map, Camera2D *camera){ // drawing some extra corner pixels // if extraPixels == 0 you can see flickering in the corners // 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){ - DrawSpriteToWorld(¤t->data, map, camera); + if( current->data->x > itmp && + current->data->y > jtmp && + current->data->x < maxI && + current->data->y < maxJ){ + DrawSpriteToWorld(current->data, map, camera); } current = current->next; } @@ -144,21 +144,21 @@ void ListActAllSprites(Game *game){ int counter = 0; while (current != 0){ counter ++; - if(current->data.hasDestination == 1){ + if(current->data->hasDestination == 1){ Vector2 movement = { - current->data.destX - current->data.x, - current->data.destY - current->data.y + current->data->destX - current->data->x, + current->data->destY - current->data->y }; if(Vector2Length(movement) < movementSpeed){ - current->data.hasDestination = 0; - current->data.x = current->data.destX; - current->data.y = current->data.destY; + current->data->hasDestination = 0; + current->data->x = current->data->destX; + current->data->y = current->data->destY; } else{ movement = Vector2Normalize(movement); movement = Vector2Scale(movement, movementSpeed); - current->data.x += movement.x; - current->data.y += movement.y; + current->data->x += movement.x; + current->data->y += movement.y; // Change sprite according to direction Vector2 nullvektor = {0,0}; @@ -168,46 +168,46 @@ void ListActAllSprites(Game *game){ if(angle <= 22.5 && angle >= -22.5){ // E - AnimationChangeAnimation(current->data.animationHandler, E); + AnimationChangeAnimation(current->data->animationHandler, E); } else if(angle > 0 && angle <= 67.5){ // NE - AnimationChangeAnimation(current->data.animationHandler, NE); + AnimationChangeAnimation(current->data->animationHandler, NE); } else if(angle > 0 && angle <= 112.5){ // N - AnimationChangeAnimation(current->data.animationHandler, N); + AnimationChangeAnimation(current->data->animationHandler, N); } else if(angle > 0 && angle <= 157.5){ // NW - AnimationChangeAnimation(current->data.animationHandler, NW); + AnimationChangeAnimation(current->data->animationHandler, NW); } else if(angle < 0 && angle >= -67.5){ // SE - AnimationChangeAnimation(current->data.animationHandler, SE); + AnimationChangeAnimation(current->data->animationHandler, SE); } else if(angle < 0 && angle >= -112.5){ // S - AnimationChangeAnimation(current->data.animationHandler, S); + AnimationChangeAnimation(current->data->animationHandler, S); } else if(angle < 0 && angle >= -157.5){ // SW - AnimationChangeAnimation(current->data.animationHandler, SW); + AnimationChangeAnimation(current->data->animationHandler, SW); } else{ // W - AnimationChangeAnimation(current->data.animationHandler, W); + AnimationChangeAnimation(current->data->animationHandler, W); } } } - SpriteUpdateAnimation(¤t->data); + SpriteUpdateAnimation(current->data); // updating z-position according to the tile the sprite stands on - Tile *floorTile = IsometricMapGetTileFromWorldCoordinates(game->layers, current->data.x, current->data.y, 0); + Tile *floorTile = IsometricMapGetTileFromWorldCoordinates(game->layers, current->data->x, current->data->y, 0); Tile *topTile = IsometricMapGetMostUpperTile(game->layers, floorTile); - current->data.z = topTile->z; + current->data->z = topTile->z; current = current->next; } diff --git a/List/list.h b/List/list.h index f808ca5..e4b2c58 100644 --- a/List/list.h +++ b/List/list.h @@ -14,7 +14,7 @@ typedef struct List { } List; typedef struct Node { - Sprite data; + Sprite *data; Node *next; Node *prev; diff --git a/List/nodeData.h b/List/nodeData.h deleted file mode 100644 index d6ac082..0000000 --- a/List/nodeData.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef NODEDATA_H_ -#define NODEDATA_H_ - -#include "../sprite.h" - -typedef union NodeData { - int dataInt; - float dataFloat; - Sprite dataSprite; -} NodeData; - -#endif \ No newline at end of file diff --git a/animation.o b/animation.o new file mode 100644 index 0000000..7a57d23 Binary files /dev/null and b/animation.o differ diff --git a/animationHandler.o b/animationHandler.o new file mode 100644 index 0000000..2d4298b Binary files /dev/null and b/animationHandler.o differ diff --git a/bucket.o b/bucket.o new file mode 100644 index 0000000..7ef6b27 Binary files /dev/null and b/bucket.o differ diff --git a/game.c b/game.c index 4cd8ca1..ac2642e 100644 --- a/game.c +++ b/game.c @@ -67,7 +67,7 @@ Game *GameInit() { ((game->layers))[n] = IsometricMapInit(n); } - /* + for (n = 0; n < 10; n++) { for (i = 0; i < game->layers[n]->width; i++) @@ -122,11 +122,11 @@ Game *GameInit() } } } - */ + n = 0; - for (i = 0; i < 3; i++) + for (i = 0; i < game->layers[0]->width; i++) { - for (j = 0; j < 3; j++) + for (j = 0; j < game->layers[0]->height; j++) { IsometricMapChangeTextureIdOfTile(game->layers, i, j, n, 0); } diff --git a/game.o b/game.o new file mode 100644 index 0000000..046450b Binary files /dev/null and b/game.o differ diff --git a/inputHandler.o b/inputHandler.o new file mode 100644 index 0000000..1f193a3 Binary files /dev/null and b/inputHandler.o differ diff --git a/isometricMap.o b/isometricMap.o new file mode 100644 index 0000000..84bb686 Binary files /dev/null and b/isometricMap.o differ diff --git a/isometricRenderer.o b/isometricRenderer.o new file mode 100644 index 0000000..c43f2fe Binary files /dev/null and b/isometricRenderer.o differ diff --git a/list.o b/list.o new file mode 100644 index 0000000..a5c69b4 Binary files /dev/null and b/list.o differ diff --git a/main.c b/main.c index 2f79b34..2bddf25 100644 --- a/main.c +++ b/main.c @@ -21,7 +21,7 @@ int main(){ // Hides the operating systems own cursor HideCursor(); - //SetTargetFPS(60); + SetTargetFPS(60); /* Bucket *buckets[10]; diff --git a/main.o b/main.o new file mode 100644 index 0000000..5ec22ce Binary files /dev/null and b/main.o differ diff --git a/mergeSort.o b/mergeSort.o new file mode 100644 index 0000000..b9bf56a Binary files /dev/null and b/mergeSort.o differ diff --git a/spiel b/spiel new file mode 100755 index 0000000..df40e5e Binary files /dev/null and b/spiel differ diff --git a/sprite.o b/sprite.o new file mode 100644 index 0000000..6975c49 Binary files /dev/null and b/sprite.o differ diff --git a/textureatlas.o b/textureatlas.o new file mode 100644 index 0000000..d49a06b Binary files /dev/null and b/textureatlas.o differ diff --git a/tile.o b/tile.o new file mode 100644 index 0000000..6bc1abe Binary files /dev/null and b/tile.o differ