forked from NathanGuilhot/Raylib_DrawTextStyle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
74 lines (56 loc) · 2.3 KB
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/*******************************************************************************************
*
* DrawTextStyle() Example by Nighten
* (Base on the raylib [core] example)
*
********************************************************************************************/
#include "raylib.h"
#include <math.h> //So we can use sin() to animate the ~wave~
Font my_main_font;
Font my_italic_font;
Font my_bold_font;
Font my_bolditalic_font;
float timer; //timer is used to animate the text
//Include the actual header file
#include "DrawTextStyle.h"
int main(void)
{
// Initialization
//--------------------------------------------------------------------------------------
const int screenWidth = 800;
const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "DrawTextStyle() Example");
SetTargetFPS(60);
//Loading our fonts
my_main_font = LoadFont("font/NotoSans-Regular.ttf");
my_italic_font = LoadFont("font/NotoSans-Italic.ttf");
my_bold_font = LoadFont("font/NotoSans-Bold.ttf");
my_bolditalic_font = LoadFont("font/NotoSans-BoldItalic.ttf");
char* text_to_display = "**Congrats!** ~You just discovered the *DrawTextStyle*!~\nYou ~~should~~ can include this *function* in **__any project__**,\nand start ~having fun!!!~ ";
//--------------------------------------------------------------------------------------
// Main game loop
while (!WindowShouldClose())
{
//Update the timer
UpdateTimer();
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(RAYWHITE);
//Style :)
DrawTextStyle(text_to_display, 20, 100, 32, DARKGRAY);
//No style :(
DrawTextEx(my_main_font ,text_to_display, (Vector2){20, 275}, 32, 1, DARKGRAY);
EndDrawing();
//----------------------------------------------------------------------------------
}
// De-Initialization
//--------------------------------------------------------------------------------------
CloseWindow();
UnloadFont(my_main_font);
UnloadFont(my_italic_font);
UnloadFont(my_bold_font);
UnloadFont(my_bolditalic_font);
//--------------------------------------------------------------------------------------
return 0;
}