2013-11-24 23:30:05 +04:00
|
|
|
/*******************************************************************************************
|
|
|
|
*
|
2014-09-21 16:26:42 +04:00
|
|
|
* raylib [text] example - raylib bitmap font (rbmf) loading and usage
|
|
|
|
*
|
|
|
|
* NOTE: raylib is distributed with some free to use fonts (even for commercial pourposes!)
|
|
|
|
* To view details and credits for those fonts, check raylib license file
|
2013-11-24 23:30:05 +04:00
|
|
|
*
|
2015-08-30 18:46:37 +03:00
|
|
|
* This example has been created using raylib 1.3 (www.raylib.com)
|
2013-11-24 23:30:05 +04:00
|
|
|
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
|
|
|
*
|
2015-08-30 18:46:37 +03:00
|
|
|
* Copyright (c) 2015 Ramon Santamaria (@raysan5)
|
2013-11-24 23:30:05 +04:00
|
|
|
*
|
|
|
|
********************************************************************************************/
|
|
|
|
|
2013-12-27 03:17:39 +04:00
|
|
|
#include "raylib.h"
|
2013-11-24 23:30:05 +04:00
|
|
|
|
|
|
|
int main()
|
|
|
|
{
|
2013-11-28 22:59:56 +04:00
|
|
|
// Initialization
|
|
|
|
//--------------------------------------------------------------------------------------
|
2015-08-27 17:13:31 +03:00
|
|
|
int screenWidth = 800;
|
|
|
|
int screenHeight = 450;
|
2013-11-28 22:59:56 +04:00
|
|
|
|
2014-09-21 16:26:42 +04:00
|
|
|
InitWindow(screenWidth, screenHeight, "raylib [text] example - rBMF fonts");
|
2014-09-30 01:41:05 +04:00
|
|
|
|
2013-11-24 23:30:05 +04:00
|
|
|
// NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required)
|
2015-08-27 17:13:31 +03:00
|
|
|
SpriteFont fonts[8];
|
|
|
|
|
|
|
|
fonts[0] = LoadSpriteFont("resources/fonts/alagard.rbmf"); // rBMF font loading
|
|
|
|
fonts[1] = LoadSpriteFont("resources/fonts/pixelplay.rbmf"); // rBMF font loading
|
|
|
|
fonts[2] = LoadSpriteFont("resources/fonts/mecha.rbmf"); // rBMF font loading
|
|
|
|
fonts[3] = LoadSpriteFont("resources/fonts/setback.rbmf"); // rBMF font loading
|
|
|
|
fonts[4] = LoadSpriteFont("resources/fonts/romulus.rbmf"); // rBMF font loading
|
|
|
|
fonts[5] = LoadSpriteFont("resources/fonts/pixantiqua.rbmf"); // rBMF font loading
|
|
|
|
fonts[6] = LoadSpriteFont("resources/fonts/alpha_beta.rbmf"); // rBMF font loading
|
|
|
|
fonts[7] = LoadSpriteFont("resources/fonts/jupiter_crash.rbmf"); // rBMF font loading
|
|
|
|
|
|
|
|
const char *messages[8] = { "ALAGARD FONT designed by Hewett Tsoi",
|
|
|
|
"PIXELPLAY FONT designed by Aleksander Shevchuk",
|
|
|
|
"MECHA FONT designed by Captain Falcon",
|
|
|
|
"SETBACK FONT designed by Brian Kent (AEnigma)",
|
|
|
|
"ROMULUS FONT designed by Hewett Tsoi",
|
|
|
|
"PIXANTIQUA FONT designed by Gerhard Grossmann",
|
|
|
|
"ALPHA_BETA FONT designed by Brian Kent (AEnigma)",
|
|
|
|
"JUPITER_CRASH FONT designed by Brian Kent (AEnigma)" };
|
|
|
|
|
|
|
|
const int spacings[8] = { 2, 4, 8, 4, 3, 4, 4, 1 };
|
|
|
|
|
|
|
|
Vector2 positions[8];
|
|
|
|
|
|
|
|
for (int i = 0; i < 8; i++)
|
|
|
|
{
|
2015-08-30 18:46:37 +03:00
|
|
|
positions[i].x = screenWidth/2 - MeasureTextEx(fonts[i], messages[i], fonts[i].size*2, spacings[i]).x/2;
|
|
|
|
positions[i].y = 60 + fonts[i].size + 50*i;
|
2015-08-27 17:13:31 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
Color colors[8] = { MAROON, ORANGE, DARKGREEN, DARKBLUE, DARKPURPLE, LIME, GOLD };
|
2013-11-28 22:59:56 +04:00
|
|
|
//--------------------------------------------------------------------------------------
|
2014-09-30 01:41:05 +04:00
|
|
|
|
2013-11-24 23:30:05 +04:00
|
|
|
// Main game loop
|
|
|
|
while (!WindowShouldClose()) // Detect window close button or ESC key
|
|
|
|
{
|
|
|
|
// Update
|
2013-11-28 22:59:56 +04:00
|
|
|
//----------------------------------------------------------------------------------
|
2013-11-24 23:30:05 +04:00
|
|
|
// TODO: Update your variables here
|
2013-11-28 22:59:56 +04:00
|
|
|
//----------------------------------------------------------------------------------
|
2014-09-30 01:41:05 +04:00
|
|
|
|
2013-11-24 23:30:05 +04:00
|
|
|
// Draw
|
2013-11-28 22:59:56 +04:00
|
|
|
//----------------------------------------------------------------------------------
|
2013-11-24 23:30:05 +04:00
|
|
|
BeginDrawing();
|
2014-09-30 01:41:05 +04:00
|
|
|
|
2013-11-24 23:30:05 +04:00
|
|
|
ClearBackground(RAYWHITE);
|
2015-08-27 17:13:31 +03:00
|
|
|
|
|
|
|
DrawText("free fonts included with raylib", 250, 20, 20, DARKGRAY);
|
|
|
|
DrawLine(220, 50, 590, 50, DARKGRAY);
|
|
|
|
|
|
|
|
for (int i = 0; i < 8; i++)
|
|
|
|
{
|
2015-08-30 18:46:37 +03:00
|
|
|
DrawTextEx(fonts[i], messages[i], positions[i], fonts[i].size*2, spacings[i], colors[i]);
|
2015-08-27 17:13:31 +03:00
|
|
|
}
|
2014-09-30 01:41:05 +04:00
|
|
|
|
2013-11-24 23:30:05 +04:00
|
|
|
EndDrawing();
|
2013-11-28 22:59:56 +04:00
|
|
|
//----------------------------------------------------------------------------------
|
2013-11-24 23:30:05 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// De-Initialization
|
2013-11-28 22:59:56 +04:00
|
|
|
//--------------------------------------------------------------------------------------
|
2015-08-27 17:13:31 +03:00
|
|
|
for (int i = 0; i < 8; i++)
|
|
|
|
{
|
|
|
|
UnloadSpriteFont(fonts[i]); // SpriteFont unloading
|
|
|
|
}
|
2014-09-30 01:41:05 +04:00
|
|
|
|
2013-12-19 15:08:06 +04:00
|
|
|
CloseWindow(); // Close window and OpenGL context
|
2013-11-28 22:59:56 +04:00
|
|
|
//--------------------------------------------------------------------------------------
|
2014-09-30 01:41:05 +04:00
|
|
|
|
2013-11-24 23:30:05 +04:00
|
|
|
return 0;
|
2014-09-21 16:26:42 +04:00
|
|
|
}
|