bug when setting sprite dest out of world bounds fixed

main
JanEhehalt 3 years ago
parent 81a38c452f
commit b9bbec8154

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

@ -70,12 +70,16 @@ Game *GameInit()
((game->layers))[n] = IsometricMapInit(n);
}
for (n = 0; n <= 10; n++)
for (n = 0; n < 10; n++)
{
for (i = 0; i < 100; i++)
{
for (j = 0; j < 100; j++)
{
if(i > 50 && i < 70 && j == 50){
IsometricMapChangeTextureIdOfTile(game->layers, i, j, n, 0);
}
switch (n)
{
case 0:
@ -110,7 +114,7 @@ Game *GameInit()
}
}
for (n = 0; n <= 10; n++)
for (n = 0; n < 10; n++)
{
for (i = 0; i < 20 - n * 2; i++)
{

Loading…
Cancel
Save