diff --git a/amulet.png b/assets/amulet.png similarity index 100% rename from amulet.png rename to assets/amulet.png diff --git a/main.c b/main.c index c24c249..c5c15fc 100644 --- a/main.c +++ b/main.c @@ -19,7 +19,7 @@ int main(){ int pressed = 0; Vector2 rectStart = {0,0}; - texture = LoadTexture("amulet.png"); + texture = LoadTexture("assets/amulet.png"); int j = 0; struct Sprite cursor = {&texture, 450, 225}; @@ -54,7 +54,7 @@ int main(){ cursor.x = GetMousePosition().x - texture.width / 2; cursor.y = GetMousePosition().y - texture.height / 2; -/* + /* if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT)){ printf("Klick\n"); addSprite(sprites, &j, &texture, cursor.x + camera.target.x, cursor.y + camera.target.y); @@ -63,8 +63,8 @@ int main(){ if(IsMouseButtonPressed(MOUSE_BUTTON_LEFT)){ if(pressed == 0){ - rectStart.x = cursor.x; - rectStart.y = cursor.y; + rectStart.x = GetMousePosition().x; + rectStart.y = GetMousePosition().y; pressed = 1; } } @@ -72,14 +72,23 @@ int main(){ if(pressed){ float width = GetMousePosition().x - rectStart.x; float height = GetMousePosition().y - rectStart.y; - - DrawRectangleLines(rectStart.x, rectStart.y, width, height, GREEN); + if(width + height > 1){ + //TODO: Fallunterscheidung für negative width / height? + // Auslagern in eigene Funktion + DrawRectangleLines(rectStart.x, rectStart.y, width, height, GREEN); + } } if(IsMouseButtonReleased(MOUSE_BUTTON_LEFT)){ pressed = 0; + float width = GetMousePosition().x - rectStart.x; + float height = GetMousePosition().y - rectStart.y; + if(width + height <= 1){ + printf("Klick\n"); + addSprite(sprites, &j, &texture, cursor.x + camera.target.x, cursor.y + camera.target.y); + } } if(IsMouseButtonPressed(MOUSE_BUTTON_RIGHT)){ diff --git a/main.o b/main.o deleted file mode 100644 index 6b235b6..0000000 Binary files a/main.o and /dev/null differ diff --git a/spiel b/spiel index f6c02a6..a6cd314 100755 Binary files a/spiel and b/spiel differ