|
|
|
@ -135,18 +135,11 @@ void mouseInput(Game *game){
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Berechnung, welche Sprites ausgewählt wurden, scuffed
|
|
|
|
// Berechnung, welche Sprites ausgewählt wurden
|
|
|
|
// 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);
|
|
|
|
Vector2 rect = GetRectangle(inputHandler->rectStart);
|
|
|
|
width = abs(width);
|
|
|
|
width = abs(width);
|
|
|
|
height = abs(height);
|
|
|
|
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 deltaX;
|
|
|
|
float deltaY;
|
|
|
|
float deltaY;
|
|
|
|
Node *current = sprites->head;
|
|
|
|
Node *current = sprites->head;
|
|
|
|
@ -157,8 +150,6 @@ void mouseInput(Game *game){
|
|
|
|
deltaX = currPos.x - camera->target.x - (rect.x + camera->target.x);
|
|
|
|
deltaX = currPos.x - camera->target.x - (rect.x + camera->target.x);
|
|
|
|
deltaY = currPos.y - camera->target.y - (rect.y + camera->target.y);
|
|
|
|
deltaY = currPos.y - camera->target.y - (rect.y + camera->target.y);
|
|
|
|
|
|
|
|
|
|
|
|
//printf("deltaX: %f, deltaY: %f\n", deltaX, deltaY);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(deltaX > 0 && deltaX < width && deltaY > 0 && deltaY < height){
|
|
|
|
if(deltaX > 0 && deltaX < width && deltaY > 0 && deltaY < height){
|
|
|
|
current->data.selected = 1;
|
|
|
|
current->data.selected = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -180,16 +171,16 @@ void mouseInput(Game *game){
|
|
|
|
float destY = inputHandler->cursorWorldPos.y;
|
|
|
|
float destY = inputHandler->cursorWorldPos.y;
|
|
|
|
int maxWidth = (game->layers[0]->width-1) * game->layers[0]->textureWidth;
|
|
|
|
int maxWidth = (game->layers[0]->width-1) * game->layers[0]->textureWidth;
|
|
|
|
int maxHeight = (game->layers[0]->height-1) * game->layers[0]->textureHeight;
|
|
|
|
int maxHeight = (game->layers[0]->height-1) * game->layers[0]->textureHeight;
|
|
|
|
if(destX < 0){ printf("OutOfBoundsDestination"); continue; }
|
|
|
|
if(destX < 0){ printf("OutOfBoundsDestination\n"); goto skip; }
|
|
|
|
if(destY < 0){ printf("OutOfBoundsDestination"); continue; }
|
|
|
|
if(destY < 0){ printf("OutOfBoundsDestination\n"); goto skip; }
|
|
|
|
if(destX > maxWidth){ printf("OutOfBoundsDestination"); continue; }
|
|
|
|
if(destX > maxWidth){ printf("OutOfBoundsDestination\n"); goto skip; }
|
|
|
|
if(destY > maxHeight){ printf("OutOfBoundsDestination"); continue; }
|
|
|
|
if(destY > maxHeight){ printf("OutOfBoundsDestination\n"); goto skip; }
|
|
|
|
|
|
|
|
|
|
|
|
current->data.destX = destX;
|
|
|
|
current->data.destX = destX;
|
|
|
|
current->data.destY = destY;
|
|
|
|
current->data.destY = destY;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
current = current->next;
|
|
|
|
skip: current = current->next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|