Update textures_mouse_painting.c

This commit is contained in:
raysan5 2019-07-28 19:04:30 +02:00
parent b83d165764
commit 38ee6156f8
1 changed files with 7 additions and 6 deletions

View File

@ -69,12 +69,14 @@ int main(void)
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
Vector2 mousePos = GetMousePosition(); Vector2 mousePos = GetMousePosition();
// Switch between colors // Move between colors with keys
if (IsKeyPressed(KEY_RIGHT)) colorSelected++; if (IsKeyPressed(KEY_RIGHT)) colorSelected++;
else if (IsKeyPressed(KEY_LEFT)) colorSelected--; else if (IsKeyPressed(KEY_LEFT)) colorSelected--;
else if (IsKeyPressed(KEY_UP)) colorSelected -= 3;
else if (IsKeyPressed(KEY_DOWN)) colorSelected += 3;
if (colorSelected >= MAX_COLORS_COUNT) colorSelected = MAX_COLORS_COUNT - 1;
else if (colorSelected < 0) colorSelected = 0;
// Choose color with mouse
for (int i = 0; i < MAX_COLORS_COUNT; i++) for (int i = 0; i < MAX_COLORS_COUNT; i++)
{ {
if (CheckCollisionPointRec(mousePos, colorsRecs[i])) if (CheckCollisionPointRec(mousePos, colorsRecs[i]))
@ -91,9 +93,6 @@ int main(void)
colorSelectedPrev = colorSelected; colorSelectedPrev = colorSelected;
} }
if (colorSelected >= MAX_COLORS_COUNT) colorSelected = MAX_COLORS_COUNT - 1;
else if (colorSelected < 0) colorSelected = 0;
// Change brush size // Change brush size
brushSize += GetMouseWheelMove()*5; brushSize += GetMouseWheelMove()*5;
if (brushSize < 2) brushSize = 2; if (brushSize < 2) brushSize = 2;
@ -145,6 +144,7 @@ int main(void)
if (showSaveMessage) if (showSaveMessage)
{ {
// On saving, show a full screen message for 2 seconds
saveMessageCounter++; saveMessageCounter++;
if (saveMessageCounter > 240) if (saveMessageCounter > 240)
{ {
@ -187,6 +187,7 @@ int main(void)
DrawRectangleLinesEx(btnSaveRec, 2, btnSaveMouseHover? RED : BLACK); DrawRectangleLinesEx(btnSaveRec, 2, btnSaveMouseHover? RED : BLACK);
DrawText("SAVE!", 755, 20, 10, btnSaveMouseHover? RED : BLACK); DrawText("SAVE!", 755, 20, 10, btnSaveMouseHover? RED : BLACK);
// Draw save image message
if (showSaveMessage) if (showSaveMessage)
{ {
DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), Fade(RAYWHITE, 0.8f)); DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), Fade(RAYWHITE, 0.8f));