Replace tabs by spaces
This commit is contained in:
parent
895f9613d2
commit
b83d165764
2 changed files with 38 additions and 38 deletions
|
@ -65,13 +65,13 @@ int main(void)
|
||||||
// Main game loop
|
// Main game loop
|
||||||
while (!WindowShouldClose()) // Detect window close button or ESC key
|
while (!WindowShouldClose()) // Detect window close button or ESC key
|
||||||
{
|
{
|
||||||
// Update
|
// Update
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
Vector2 mousePos = GetMousePosition();
|
Vector2 mousePos = GetMousePosition();
|
||||||
|
|
||||||
// Switch between colors
|
// Switch between colors
|
||||||
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_UP)) colorSelected -= 3;
|
||||||
else if (IsKeyPressed(KEY_DOWN)) colorSelected += 3;
|
else if (IsKeyPressed(KEY_DOWN)) colorSelected += 3;
|
||||||
|
|
||||||
|
@ -91,41 +91,41 @@ int main(void)
|
||||||
colorSelectedPrev = colorSelected;
|
colorSelectedPrev = colorSelected;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (colorSelected >= MAX_COLORS_COUNT) colorSelected = MAX_COLORS_COUNT - 1;
|
if (colorSelected >= MAX_COLORS_COUNT) colorSelected = MAX_COLORS_COUNT - 1;
|
||||||
else if (colorSelected < 0) colorSelected = 0;
|
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;
|
||||||
if (brushSize > 50) brushSize = 50;
|
if (brushSize > 50) brushSize = 50;
|
||||||
|
|
||||||
if (IsKeyPressed(KEY_C))
|
if (IsKeyPressed(KEY_C))
|
||||||
{
|
{
|
||||||
// Clear render texture to clear color
|
// Clear render texture to clear color
|
||||||
BeginTextureMode(target);
|
BeginTextureMode(target);
|
||||||
ClearBackground(colors[0]);
|
ClearBackground(colors[0]);
|
||||||
EndTextureMode();
|
EndTextureMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IsMouseButtonDown(MOUSE_LEFT_BUTTON))
|
if (IsMouseButtonDown(MOUSE_LEFT_BUTTON))
|
||||||
{
|
{
|
||||||
// Paint circle into render texture
|
// Paint circle into render texture
|
||||||
// NOTE: To avoid discontinuous circles, we could store
|
// NOTE: To avoid discontinuous circles, we could store
|
||||||
// previous-next mouse points and just draw a line using brush size
|
// previous-next mouse points and just draw a line using brush size
|
||||||
BeginTextureMode(target);
|
BeginTextureMode(target);
|
||||||
if (mousePos.y > 50) DrawCircle(mousePos.x, mousePos.y, brushSize, colors[colorSelected]);
|
if (mousePos.y > 50) DrawCircle(mousePos.x, mousePos.y, brushSize, colors[colorSelected]);
|
||||||
EndTextureMode();
|
EndTextureMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IsMouseButtonDown(MOUSE_RIGHT_BUTTON))
|
if (IsMouseButtonDown(MOUSE_RIGHT_BUTTON))
|
||||||
{
|
{
|
||||||
colorSelected = 0;
|
colorSelected = 0;
|
||||||
|
|
||||||
// Erase circle from render texture
|
// Erase circle from render texture
|
||||||
BeginTextureMode(target);
|
BeginTextureMode(target);
|
||||||
if (mousePos.y > 50) DrawCircle(mousePos.x, mousePos.y, brushSize, colors[0]);
|
if (mousePos.y > 50) DrawCircle(mousePos.x, mousePos.y, brushSize, colors[0]);
|
||||||
EndTextureMode();
|
EndTextureMode();
|
||||||
}
|
}
|
||||||
else colorSelected = colorSelectedPrev;
|
else colorSelected = colorSelectedPrev;
|
||||||
|
|
||||||
// Check mouse hover save button
|
// Check mouse hover save button
|
||||||
|
@ -152,16 +152,16 @@ int main(void)
|
||||||
saveMessageCounter = 0;
|
saveMessageCounter = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
|
||||||
// Draw
|
// Draw
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
BeginDrawing();
|
BeginDrawing();
|
||||||
|
|
||||||
ClearBackground(RAYWHITE);
|
ClearBackground(RAYWHITE);
|
||||||
|
|
||||||
// NOTE: Render texture must be y-flipped due to default OpenGL coordinates (left-bottom)
|
// NOTE: Render texture must be y-flipped due to default OpenGL coordinates (left-bottom)
|
||||||
DrawTextureRec(target.texture, (Rectangle){ 0, 0, target.texture.width, -target.texture.height }, (Vector2){ 0, 0 }, WHITE);
|
DrawTextureRec(target.texture, (Rectangle){ 0, 0, target.texture.width, -target.texture.height }, (Vector2){ 0, 0 }, WHITE);
|
||||||
|
|
||||||
// Draw drawing circle for reference
|
// Draw drawing circle for reference
|
||||||
if (mousePos.y > 50)
|
if (mousePos.y > 50)
|
||||||
|
@ -194,8 +194,8 @@ int main(void)
|
||||||
DrawText("IMAGE SAVED: my_amazing_texture_painting.png", 150, 180, 20, RAYWHITE);
|
DrawText("IMAGE SAVED: my_amazing_texture_painting.png", 150, 180, 20, RAYWHITE);
|
||||||
}
|
}
|
||||||
|
|
||||||
EndDrawing();
|
EndDrawing();
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
}
|
}
|
||||||
|
|
||||||
// De-Initialization
|
// De-Initialization
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue