diff --git a/Input/inputHandler.c b/Input/inputHandler.c index ef68195..59f7904 100644 --- a/Input/inputHandler.c +++ b/Input/inputHandler.c @@ -58,7 +58,7 @@ void mouseInput(Game *game){ InputHandler *inputHandler = game->inputHandler; List *sprites = game->sprites; Camera2D *camera = game->camera; - IsometricMap **layers = *(game->layers); + IsometricMap **layers = *game->layers; Texture2D *texture = game->worker +4; inputHandler->cursorPos.x = GetMousePosition().x; @@ -127,12 +127,17 @@ void mouseInput(Game *game){ } // Berechnung, welche Sprites ausgewählt wurden, scuffed + // TODO: ist wirklich sehr scuffed wegen negativen koordinaten etc + // Problem: Theoretisch einfach nur schauen ob unprojected Sprite coords im Rect liegen + // Muss aber unterschieden werden ob width negativ oder so ist, aber einfach abs funktioniert nicht + // So wie es aktuell ist, funktioniert die Auswahl, aber nur solange die Kamera nicht bewegt wird Vector2 rect = GetRectangle(inputHandler->rectStart); width = abs(width); height = abs(height); printf("Auswahl: x: %f, y: %f, w: %f, h: %f\n", rect.x, rect.y, width, height); + // TODO: update to World Coordinates float deltaX; float deltaY; Node *current = sprites->head; @@ -140,8 +145,8 @@ void mouseInput(Game *game){ Vector2 currPos = {current->data.x, current->data.y}; IsometricMapUnproject(layers[0], camera, currPos.x, currPos.y, &currPos); - deltaX = currPos.x + current->data.texture->width/2 - (rect.x + camera->target.x); - deltaY = currPos.y + current->data.texture->height/2 - (rect.y + camera->target.y); + deltaX = currPos.x - camera->target.x - (rect.x + camera->target.x); + deltaY = currPos.y - camera->target.y - (rect.y + camera->target.y); printf("deltaX: %f, deltaY: %f\n", deltaX, deltaY); diff --git a/README.md b/README.md index 5a8ce92..32451f7 100644 --- a/README.md +++ b/README.md @@ -18,5 +18,6 @@ Fantasy Welt oder Realistisch? + LinkedList erweitern + Sprites Animationen etc improven + Die Sprites brauchen evtl eine z-Koordinate, die anzeigt auf welchem Layer sie sind, wird aber recht kompliziert. Macht es sinn das Spiel an sich auf ein Layer zu begrenzen und die höheren Layer nur für größere Gebäude zu nutzen, wie z.B. Türme? ++ Die Inputs sollten den Kamera Zoom beachten, aktuell geht noch alles kaputt wenn man den zoom umstellt ### WiP \ No newline at end of file