Examples reviewed
This commit is contained in:
parent
8745d733f9
commit
997170a317
10 changed files with 107 additions and 136 deletions
|
@ -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();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue