diff options
| author | raysan5 <raysan5@gmail.com> | 2015-08-27 16:13:31 +0200 |
|---|---|---|
| committer | raysan5 <raysan5@gmail.com> | 2015-08-27 16:13:49 +0200 |
| commit | 997170a317bb8077cb96d3fc757c6cde0c0ea466 (patch) | |
| tree | 139171eed30f8d0f77ea4873ca1f0510dc5b0812 /examples/text_font_select.c | |
| parent | 8745d733f98e1c9a647a8bd8b85cf0781782d4b7 (diff) | |
| download | raylib-997170a317bb8077cb96d3fc757c6cde0c0ea466.tar.gz raylib-997170a317bb8077cb96d3fc757c6cde0c0ea466.zip | |
Examples reviewed
Diffstat (limited to 'examples/text_font_select.c')
| -rw-r--r-- | examples/text_font_select.c | 36 |
1 files changed, 25 insertions, 11 deletions
diff --git a/examples/text_font_select.c b/examples/text_font_select.c index 62538ebc..25825aba 100644 --- a/examples/text_font_select.c +++ b/examples/text_font_select.c @@ -5,7 +5,7 @@ * This example has been created using raylib 1.0 (www.raylib.com) * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) * -* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) +* Copyright (c) 2014 Ramon Santamaria (@raysan5) * ********************************************************************************************/ @@ -16,7 +16,7 @@ int main() // Initialization //-------------------------------------------------------------------------------------- int screenWidth = 800; - int screenHeight = 150; + int screenHeight = 450; InitWindow(screenWidth, screenHeight, "raylib [text] example - font selector"); @@ -45,12 +45,14 @@ int main() Vector2 mousePoint; - Rectangle btnNextRec = { 673, 18, 109, 44 }; // Button rectangle (useful for collision) - Color btnNextOutColor = DARKBLUE; // Button color (outside line) Color btnNextInColor = SKYBLUE; // Button color (inside) int framesCounter = 0; // Useful to count frames button is 'active' = clicked + + int positionY = 180; // Text selector and button Y position + + Rectangle btnNextRec = { 673, positionY, 109, 44 }; // Button rectangle (useful for collision) SetTargetFPS(60); // Set our game to run at 60 frames-per-second //-------------------------------------------------------------------------------------- @@ -71,6 +73,15 @@ int main() { if (currentFont > 0) currentFont--; } + + if (IsKeyPressed('0')) currentFont = 0; + else if (IsKeyPressed('1')) currentFont = 1; + else if (IsKeyPressed('2')) currentFont = 2; + else if (IsKeyPressed('3')) currentFont = 3; + else if (IsKeyPressed('4')) currentFont = 4; + else if (IsKeyPressed('5')) currentFont = 5; + else if (IsKeyPressed('6')) currentFont = 6; + else if (IsKeyPressed('7')) currentFont = 7; // Mouse-based font selection (NEXT button logic) mousePoint = GetMousePosition(); @@ -115,18 +126,21 @@ int main() BeginDrawing(); ClearBackground(RAYWHITE); + + DrawText("font selector - use arroys, button or numbers", 160, 80, 20, DARKGRAY); + DrawLine(120, 120, 680, 120, DARKGRAY); - DrawRectangle(18, 18, 644, 44, DARKGRAY); - DrawRectangle(20, 20, 640, 40, LIGHTGRAY); - DrawText(fontNames[currentFont], 30, 31, 20, BLACK); - DrawText("< >", 610, 26, 30, BLACK); + DrawRectangle(18, positionY, 644, 44, DARKGRAY); + DrawRectangle(20, positionY + 2, 640, 40, LIGHTGRAY); + DrawText(fontNames[currentFont], 30, positionY + 13, 20, BLACK); + DrawText("< >", 610, positionY + 8, 30, BLACK); DrawRectangleRec(btnNextRec, btnNextOutColor); - DrawRectangle(675, 20, 105, 40, btnNextInColor); - DrawText("NEXT", 700, 31, 20, btnNextOutColor); + DrawRectangle(675, positionY + 2, 105, 40, btnNextInColor); + DrawText("NEXT", 700, positionY + 13, 20, btnNextOutColor); DrawTextEx(fonts[currentFont], text, (Vector2){ screenWidth/2 - textSize.x/2, - 75 + (70 - textSize.y)/2 }, GetFontBaseSize(fonts[currentFont])*3, + 260 + (70 - textSize.y)/2 }, GetFontBaseSize(fonts[currentFont])*3, 1, colors[currentFont]); EndDrawing(); |
