|
|
|
|
@ -20,13 +20,7 @@ void mouseInput(InputHandler *inputHandler, Sprite *sprites, int *spriteAmount,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(inputHandler->pressed){
|
|
|
|
|
float width = GetMousePosition().x - inputHandler->rectStart.x;
|
|
|
|
|
float height = GetMousePosition().y - inputHandler->rectStart.y;
|
|
|
|
|
if(width + height > 1){
|
|
|
|
|
//TODO: Fallunterscheidung für negative width / height?
|
|
|
|
|
// Auslagern in eigene Funktion
|
|
|
|
|
DrawRectangleLines(inputHandler->rectStart.x, inputHandler->rectStart.y, width, height, GREEN);
|
|
|
|
|
}
|
|
|
|
|
DrawRect(inputHandler->rectStart, &(inputHandler->cursorPos));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(IsMouseButtonReleased(MOUSE_BUTTON_LEFT)){
|
|
|
|
|
@ -61,4 +55,27 @@ void keyboardInput(InputHandler *inputHandler, Camera2D *camera){
|
|
|
|
|
if(IsKeyDown(KEY_A)){
|
|
|
|
|
(*camera).target.x -= 100.0f * GetFrameTime();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DrawRect(Vector2 rectStart, Vector2 *mousePosition){
|
|
|
|
|
|
|
|
|
|
float width = GetMousePosition().x - rectStart.x;
|
|
|
|
|
float height = GetMousePosition().y - rectStart.y;
|
|
|
|
|
|
|
|
|
|
if(width < 0 && height >= 0){
|
|
|
|
|
width *= -1;
|
|
|
|
|
rectStart.x -= width;
|
|
|
|
|
}
|
|
|
|
|
else if(height < 0 && width >= 0){
|
|
|
|
|
height *= -1;
|
|
|
|
|
rectStart.y -= height;
|
|
|
|
|
}
|
|
|
|
|
else if(height < 0 && width < 0){
|
|
|
|
|
height *= -1;
|
|
|
|
|
width *= -1;
|
|
|
|
|
rectStart.x -= width;
|
|
|
|
|
rectStart.y -= height;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DrawRectangleLines(rectStart.x, rectStart.y, width, height, GREEN);
|
|
|
|
|
}
|