Added some functions and Updated examples

View CHANGELOG for details
This commit is contained in:
raysan5 2013-11-28 19:59:56 +01:00
commit e9143b8a8d
35 changed files with 588 additions and 201 deletions

View file

@ -1,8 +1,25 @@
changelog changelog
--------- ---------
Current: raylib 1.0 (November 2013) Current: raylib 1.0.1 (November 2013)
-----------------------------------------------
Update: raylib 1.0.1 (28 November 2013)
-----------------------------------------------
[text] DrawText() - Removed spacing parameter
[text] MeasureText() - Removed spacing parameter
[text] DrawFps() - Renamed to DrawFPS() for coherence with similar function
[core] IsKeyPressed() - Change functionality, check if key pressed once
[core] IsKeyDown() - Added, check if key is being pressed
[core] IsKeyReleased() - Change functionality, chek if key released once
[core] IsKeyUp() - Added, check if key is being NOT pressed
[core] IsMouseButtonDown() - Added, check if mouse button is being pressed
[core] IsMouseButtonPressed() - Change functionality, check if mouse button pressed once
[core] IsMouseButtonUp() - Added, check if mouse button is NOT being pressed
[core] IsMouseButtonReleased() - Change functionality, check if mouse button released once
[textures] DrawTexturePro() - Added, texture drawing with 'pro' parameters
[examples] Function changes applied to ALL examples
----------------------------------------------- -----------------------------------------------
Release: raylib 1.0.0 (18 November 2013) Release: raylib 1.0.0 (18 November 2013)

View file

@ -13,38 +13,38 @@
int main() int main()
{ {
// Initialization
//--------------------------------------------------------------------------------------
int screenWidth = 800; int screenWidth = 800;
int screenHeight = 450; int screenHeight = 450;
// Initialization
//---------------------------------------------------------
InitWindow(screenWidth, screenHeight, "raylib example 01a - basic window"); InitWindow(screenWidth, screenHeight, "raylib example 01a - basic window");
//---------------------------------------------------------- //--------------------------------------------------------------------------------------
// 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
//----------------------------------------------------- //----------------------------------------------------------------------------------
// TODO: Update your variables here // TODO: Update your variables here
//----------------------------------------------------- //----------------------------------------------------------------------------------
// Draw // Draw
//----------------------------------------------------- //----------------------------------------------------------------------------------
BeginDrawing(); BeginDrawing();
ClearBackground(RAYWHITE); ClearBackground(RAYWHITE);
DrawText("Congrats! You created your first window!", 190, 200, 20, 1, LIGHTGRAY); DrawText("Congrats! You created your first window!", 190, 200, 20, LIGHTGRAY);
EndDrawing(); EndDrawing();
//----------------------------------------------------- //----------------------------------------------------------------------------------
} }
// De-Initialization // De-Initialization
//--------------------------------------------------------- //--------------------------------------------------------------------------------------
CloseWindow(); // Close window and OpenGL context CloseWindow(); // Close window and OpenGL context
//---------------------------------------------------------- //--------------------------------------------------------------------------------------
return 0; return 0;
} }

Binary file not shown.

View file

@ -13,42 +13,42 @@
int main() int main()
{ {
// Initialization
//--------------------------------------------------------------------------------------
int screenWidth = 800; int screenWidth = 800;
int screenHeight = 450; int screenHeight = 450;
// Initialization
//---------------------------------------------------------
InitWindow(screenWidth, screenHeight, "raylib example 02a - raylib logo"); InitWindow(screenWidth, screenHeight, "raylib example 02a - raylib logo");
//---------------------------------------------------------- //--------------------------------------------------------------------------------------
// 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
//----------------------------------------------------- //----------------------------------------------------------------------------------
// TODO: Update your variables here // TODO: Update your variables here
//----------------------------------------------------- //----------------------------------------------------------------------------------
// Draw // Draw
//----------------------------------------------------- //----------------------------------------------------------------------------------
BeginDrawing(); BeginDrawing();
ClearBackground(RAYWHITE); ClearBackground(RAYWHITE);
DrawRectangle(screenWidth/2 - 128, screenHeight/2 - 128, 256, 256, BLACK); DrawRectangle(screenWidth/2 - 128, screenHeight/2 - 128, 256, 256, BLACK);
DrawRectangle(screenWidth/2 - 112, screenHeight/2 - 112, 224, 224, RAYWHITE); DrawRectangle(screenWidth/2 - 112, screenHeight/2 - 112, 224, 224, RAYWHITE);
DrawText("raylib", 356, 273, 50, 1, BLACK); DrawText("raylib", 356, 273, 50, BLACK);
DrawText("this is NOT a texture!", 350, 370, 10, 1, GRAY); DrawText("this is NOT a texture!", 350, 370, 10, GRAY);
EndDrawing(); EndDrawing();
//----------------------------------------------------- //----------------------------------------------------------------------------------
} }
// De-Initialization // De-Initialization
//--------------------------------------------------------- //--------------------------------------------------------------------------------------
CloseWindow(); // Close window and OpenGL context CloseWindow(); // Close window and OpenGL context
//---------------------------------------------------------- //--------------------------------------------------------------------------------------
return 0; return 0;
} }

Binary file not shown.

View file

@ -13,24 +13,24 @@
int main() int main()
{ {
// Initialization
//--------------------------------------------------------------------------------------
int screenWidth = 800; int screenWidth = 800;
int screenHeight = 450; int screenHeight = 450;
// Initialization
//---------------------------------------------------------
InitWindow(screenWidth, screenHeight, "raylib example 02b - basic shapes drawing"); InitWindow(screenWidth, screenHeight, "raylib example 02b - basic shapes drawing");
//---------------------------------------------------------- //--------------------------------------------------------------------------------------
// 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
//----------------------------------------------------- //----------------------------------------------------------------------------------
// TODO: Update your variables here // TODO: Update your variables here
//----------------------------------------------------- //----------------------------------------------------------------------------------
// Draw // Draw
//----------------------------------------------------- //----------------------------------------------------------------------------------
BeginDrawing(); BeginDrawing();
ClearBackground(RAYWHITE); ClearBackground(RAYWHITE);
@ -61,13 +61,13 @@ void DrawPolyLine(Vector2 *points, int numPoints, Color color);
DrawText("_____", 320, 280, 50, 1, BLACK); DrawText("_____", 320, 280, 50, 1, BLACK);
EndDrawing(); EndDrawing();
//----------------------------------------------------- //----------------------------------------------------------------------------------
} }
// De-Initialization // De-Initialization
//--------------------------------------------------------- //--------------------------------------------------------------------------------------
CloseWindow(); // Close window and OpenGL context CloseWindow(); // Close window and OpenGL context
//---------------------------------------------------------- //--------------------------------------------------------------------------------------
return 0; return 0;
} }

View file

@ -13,29 +13,29 @@
int main() int main()
{ {
// Initialization
//--------------------------------------------------------------------------------------
int screenWidth = 800; int screenWidth = 800;
int screenHeight = 450; int screenHeight = 450;
// Initialization
//---------------------------------------------------------
InitWindow(screenWidth, screenHeight, "raylib example 02c - raylib color palette"); InitWindow(screenWidth, screenHeight, "raylib example 02c - raylib color palette");
//---------------------------------------------------------- //--------------------------------------------------------------------------------------
// 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
//----------------------------------------------------- //----------------------------------------------------------------------------------
// TODO: Update your variables here // TODO: Update your variables here
//----------------------------------------------------- //----------------------------------------------------------------------------------
// Draw // Draw
//----------------------------------------------------- //----------------------------------------------------------------------------------
BeginDrawing(); BeginDrawing();
ClearBackground(RAYWHITE); ClearBackground(RAYWHITE);
DrawText("raylib color palette", 28, 42, 20, 2, BLACK); DrawText("raylib color palette", 28, 42, 20, BLACK);
DrawRectangle(26, 80, 100, 100, DARKGRAY); DrawRectangle(26, 80, 100, 100, DARKGRAY);
DrawRectangle(26, 188, 100, 100, GRAY); DrawRectangle(26, 188, 100, 100, GRAY);
@ -60,36 +60,36 @@ int main()
DrawRectangle(674, 296, 100, 100, BEIGE); DrawRectangle(674, 296, 100, 100, BEIGE);
DrawText("DARKGRAY", 57, 166, 10, 2, BLACK); DrawText("DARKGRAY", 65, 166, 10, BLACK);
DrawText("GRAY", 89, 274, 10, 2, BLACK); DrawText("GRAY", 93, 274, 10, BLACK);
DrawText("LIGHTGRAY", 51, 382, 10, 2, BLACK); DrawText("LIGHTGRAY", 61, 382, 10, BLACK);
DrawText("MAROON", 180, 166, 10, 2, BLACK); DrawText("MAROON", 186, 166, 10, BLACK);
DrawText("RED", 207, 274, 10, 2, BLACK); DrawText("RED", 208, 274, 10, BLACK);
DrawText("PINK", 200, 382, 10, 2, BLACK); DrawText("PINK", 204, 382, 10, BLACK);
DrawText("ORANGE", 290, 166, 10, 2, BLACK); DrawText("ORANGE", 295, 166, 10, BLACK);
DrawText("GOLD", 306, 274, 10, 2, BLACK); DrawText("GOLD", 310, 274, 10, BLACK);
DrawText("YELLOW", 290, 382, 10, 2, BLACK); DrawText("YELLOW", 300, 382, 10, BLACK);
DrawText("DARKGREEN", 374, 166, 10, 2, BLACK); DrawText("DARKGREEN", 382, 166, 10, BLACK);
DrawText("LIME", 417, 274, 10, 2, BLACK); DrawText("LIME", 420, 274, 10, BLACK);
DrawText("GREEN", 407, 382, 10, 2, BLACK); DrawText("GREEN", 410, 382, 10, BLACK);
DrawText("DARKBLUE", 491, 166, 10, 2, BLACK); DrawText("DARKBLUE", 498, 166, 10, BLACK);
DrawText("BLUE", 523, 274, 10, 2, BLACK); DrawText("BLUE", 526, 274, 10, BLACK);
DrawText("SKYBLUE", 499, 382, 10, 2, BLACK); DrawText("SKYBLUE", 505, 382, 10, BLACK);
DrawText("DARKPURPLE", 582, 166, 10, 2, BLACK); DrawText("DARKPURPLE", 592, 166, 10, BLACK);
DrawText("VIOLET", 617, 274, 10, 2, BLACK); DrawText("VIOLET", 621, 274, 10, BLACK);
DrawText("PURPLE", 615, 382, 10, 2, BLACK); DrawText("PURPLE", 620, 382, 10, BLACK);
DrawText("DARKBROWN", 695, 166, 10, 2, BLACK); DrawText("DARKBROWN", 705, 166, 10, BLACK);
DrawText("BROWN", 728, 274, 10, 2, BLACK); DrawText("BROWN", 733, 274, 10, BLACK);
DrawText("BEIGE", 733, 382, 10, 2, BLACK); DrawText("BEIGE", 737, 382, 10, BLACK);
EndDrawing(); EndDrawing();
//----------------------------------------------------- //----------------------------------------------------------------------------------
} }
// De-Initialization // De-Initialization
//--------------------------------------------------------- //--------------------------------------------------------------------------------------
CloseWindow(); // Close window and OpenGL context CloseWindow(); // Close window and OpenGL context
//---------------------------------------------------------- //--------------------------------------------------------------------------------------
return 0; return 0;
} }

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 5.1 KiB

Before After
Before After

View file

@ -12,46 +12,48 @@
#include "raylib.h" #include "raylib.h"
int main() int main()
{ {
// Initialization
//--------------------------------------------------------------------------------------
int screenWidth = 800; int screenWidth = 800;
int screenHeight = 450; int screenHeight = 450;
Vector2 ballPosition = { screenWidth/2, screenHeight/2 }; Vector2 ballPosition = { screenWidth/2, screenHeight/2 };
// Initialization
//---------------------------------------------------------
InitWindow(screenWidth, screenHeight, "raylib example 05 - keyboard input"); InitWindow(screenWidth, screenHeight, "raylib example 05 - keyboard input");
//----------------------------------------------------------
SetTargetFPS(60); // Set target frames-per-second
//--------------------------------------------------------------------------------------
// 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
//----------------------------------------------------- //----------------------------------------------------------------------------------
if (IsKeyPressed(KEY_RIGHT)) ballPosition.x += 0.8; if (IsKeyPressed(KEY_RIGHT)) ballPosition.x += 0.8;
if (IsKeyPressed(KEY_LEFT)) ballPosition.x -= 0.8; if (IsKeyPressed(KEY_LEFT)) ballPosition.x -= 0.8;
if (IsKeyPressed(KEY_UP)) ballPosition.y -= 0.8; if (IsKeyPressed(KEY_UP)) ballPosition.y -= 0.8;
if (IsKeyPressed(KEY_DOWN)) ballPosition.y += 0.8; if (IsKeyPressed(KEY_DOWN)) ballPosition.y += 0.8;
//----------------------------------------------------- //----------------------------------------------------------------------------------
// Draw // Draw
//----------------------------------------------------- //----------------------------------------------------------------------------------
BeginDrawing(); BeginDrawing();
ClearBackground(RAYWHITE); ClearBackground(RAYWHITE);
DrawText("move the ball with arrow keys", 10, 10, 20, 1, DARKGRAY); DrawText("move the ball with arrow keys", 10, 10, 20, DARKGRAY);
DrawCircleV(ballPosition, 50, MAROON); DrawCircleV(ballPosition, 50, MAROON);
EndDrawing(); EndDrawing();
//----------------------------------------------------- //----------------------------------------------------------------------------------
} }
// De-Initialization // De-Initialization
//--------------------------------------------------------- //--------------------------------------------------------------------------------------
CloseWindow(); // Close window and OpenGL context CloseWindow(); // Close window and OpenGL context
//---------------------------------------------------------- //--------------------------------------------------------------------------------------
return 0; return 0;
} }

Binary file not shown.

View file

@ -13,6 +13,8 @@
int main() int main()
{ {
// Initialization
//--------------------------------------------------------------------------------------
int screenWidth = 800; int screenWidth = 800;
int screenHeight = 450; int screenHeight = 450;
@ -20,16 +22,14 @@ int main()
int counter = 0; int counter = 0;
int mouseX, mouseY; int mouseX, mouseY;
// Initialization
//---------------------------------------------------------
InitWindow(screenWidth, screenHeight, "raylib example 06 - mouse input"); InitWindow(screenWidth, screenHeight, "raylib example 06 - mouse input");
//---------------------------------------------------------- //---------------------------------------------------------------------------------------
// 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
//----------------------------------------------------- //----------------------------------------------------------------------------------
if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON))
{ {
mouseX = GetMouseX(); mouseX = GetMouseX();
@ -38,26 +38,26 @@ int main()
ballPosition.x = (float)mouseX; ballPosition.x = (float)mouseX;
ballPosition.y = (float)mouseY; ballPosition.y = (float)mouseY;
} }
//----------------------------------------------------- //----------------------------------------------------------------------------------
// Draw // Draw
//----------------------------------------------------- //----------------------------------------------------------------------------------
BeginDrawing(); BeginDrawing();
ClearBackground(RAYWHITE); ClearBackground(RAYWHITE);
DrawCircleV(ballPosition, 40, GOLD); DrawCircleV(ballPosition, 40, GOLD);
DrawText("mouse click to draw the ball", 10, 10, 20, 1, DARKGRAY); DrawText("mouse click to draw the ball", 10, 10, 20, DARKGRAY);
EndDrawing(); EndDrawing();
//----------------------------------------------------- //----------------------------------------------------------------------------------
} }
// De-Initialization // De-Initialization
//--------------------------------------------------------- //--------------------------------------------------------------------------------------
CloseWindow(); // Close window and OpenGL context CloseWindow(); // Close window and OpenGL context
//---------------------------------------------------------- //--------------------------------------------------------------------------------------
return 0; return 0;
} }

Binary file not shown.

View file

@ -13,22 +13,24 @@
int main() int main()
{ {
// Initialization
//--------------------------------------------------------------------------------------
int screenWidth = 800; int screenWidth = 800;
int screenHeight = 450; int screenHeight = 450;
Vector2 ballPosition = { screenWidth/2, screenHeight/2 }; Vector2 ballPosition = { screenWidth/2, screenHeight/2 };
Vector2 gamepadMove = { 0, 0 }; Vector2 gamepadMove = { 0, 0 };
// Initialization
//---------------------------------------------------------
InitWindow(screenWidth, screenHeight, "raylib example 01 - gamepad input"); InitWindow(screenWidth, screenHeight, "raylib example 01 - gamepad input");
//----------------------------------------------------------
SetTargetFPS(60); // Set target frames-per-second
//--------------------------------------------------------------------------------------
// 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
//----------------------------------------------------- //----------------------------------------------------------------------------------
if (IsGamepadAvailable(GAMEPAD_PLAYER1)) if (IsGamepadAvailable(GAMEPAD_PLAYER1))
{ {
gamepadMove = GetGamepadMovement(GAMEPAD_PLAYER1); gamepadMove = GetGamepadMovement(GAMEPAD_PLAYER1);
@ -42,26 +44,26 @@ int main()
ballPosition.y = screenHeight/2; ballPosition.y = screenHeight/2;
} }
} }
//----------------------------------------------------- //----------------------------------------------------------------------------------
// Draw // Draw
//----------------------------------------------------- //----------------------------------------------------------------------------------
BeginDrawing(); BeginDrawing();
ClearBackground(RAYWHITE); ClearBackground(RAYWHITE);
DrawText("move the ball with gamepad", 10, 10, 20, 1, DARKGRAY); DrawText("move the ball with gamepad", 10, 10, 20, DARKGRAY);
DrawCircleV(ballPosition, 50, MAROON); DrawCircleV(ballPosition, 50, MAROON);
EndDrawing(); EndDrawing();
//----------------------------------------------------- //----------------------------------------------------------------------------------
} }
// De-Initialization // De-Initialization
//--------------------------------------------------------- //--------------------------------------------------------------------------------------
CloseWindow(); // Close window and OpenGL context CloseWindow(); // Close window and OpenGL context
//---------------------------------------------------------- //--------------------------------------------------------------------------------------
return 0; return 0;
} }

Binary file not shown.

View file

@ -12,28 +12,28 @@
#include "raylib.h" #include "raylib.h"
int main() int main()
{ {
// Initialization
//--------------------------------------------------------------------------------------
int screenWidth = 800; int screenWidth = 800;
int screenHeight = 450; int screenHeight = 450;
// Initialization
//---------------------------------------------------------
InitWindow(screenWidth, screenHeight, "raylib example 04a - texture loading and drawing"); InitWindow(screenWidth, screenHeight, "raylib example 04a - texture loading and drawing");
// NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required) // NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required)
Texture2D texture = LoadTexture("resources/raylib_logo.png"); // Texture loading Texture2D texture = LoadTexture("resources/raylib_logo.png"); // Texture loading
//---------------------------------------------------------- //---------------------------------------------------------------------------------------
// 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
//----------------------------------------------------- //----------------------------------------------------------------------------------
// TODO: Update your variables here // TODO: Update your variables here
//----------------------------------------------------- //----------------------------------------------------------------------------------
// Draw // Draw
//----------------------------------------------------- //----------------------------------------------------------------------------------
BeginDrawing(); BeginDrawing();
ClearBackground(RAYWHITE); ClearBackground(RAYWHITE);
@ -41,18 +41,18 @@ int main()
DrawTexture(texture, screenWidth/2 - texture.width/2, DrawTexture(texture, screenWidth/2 - texture.width/2,
screenHeight/2 - texture.height/2, WHITE); screenHeight/2 - texture.height/2, WHITE);
DrawText("this IS a texture!", 360, 370, 10, 1, GRAY); DrawText("this IS a texture!", 360, 370, 10, GRAY);
EndDrawing(); EndDrawing();
//----------------------------------------------------- //----------------------------------------------------------------------------------
} }
// De-Initialization // De-Initialization
//--------------------------------------------------------- //--------------------------------------------------------------------------------------
UnloadTexture(texture); // Texture unloading UnloadTexture(texture); // Texture unloading
CloseWindow(); // Close window and OpenGL context CloseWindow(); // Close window and OpenGL context
//---------------------------------------------------------- //--------------------------------------------------------------------------------------
return 0; return 0;
} }

Binary file not shown.

View file

@ -13,27 +13,27 @@
int main() int main()
{ {
// Initialization
//--------------------------------------------------------------------------------------
int screenWidth = 800; int screenWidth = 800;
int screenHeight = 450; int screenHeight = 450;
// Initialization
//---------------------------------------------------------
InitWindow(screenWidth, screenHeight, "raylib example 04b - texture rectangle"); InitWindow(screenWidth, screenHeight, "raylib example 04b - texture rectangle");
// NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required) // NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required)
Texture2D texture = LoadTexture("resources/raylib_logo.png"); // Texture loading Texture2D texture = LoadTexture("resources/raylib_logo.png"); // Texture loading
//---------------------------------------------------------- //--------------------------------------------------------------------------------------
// 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
//----------------------------------------------------- //----------------------------------------------------------------------------------
// TODO: Update your variables here // TODO: Update your variables here
//----------------------------------------------------- //----------------------------------------------------------------------------------
// Draw // Draw
//----------------------------------------------------- //----------------------------------------------------------------------------------
BeginDrawing(); BeginDrawing();
ClearBackground(RAYWHITE); ClearBackground(RAYWHITE);
@ -44,15 +44,15 @@ int main()
void DrawTextureRec(Texture2D texture, Rectangle sourceRec, Vector2 position, float scale, Color tint); void DrawTextureRec(Texture2D texture, Rectangle sourceRec, Vector2 position, float scale, Color tint);
*/ */
EndDrawing(); EndDrawing();
//----------------------------------------------------- //----------------------------------------------------------------------------------
} }
// De-Initialization // De-Initialization
//--------------------------------------------------------- //--------------------------------------------------------------------------------------
UnloadTexture(texture); // Texture unloading UnloadTexture(texture); // Texture unloading
CloseWindow(); // Close window and OpenGL context CloseWindow(); // Close window and OpenGL context
//---------------------------------------------------------- //--------------------------------------------------------------------------------------
return 0; return 0;
} }

View file

@ -13,27 +13,27 @@
int main() int main()
{ {
// Initialization
//--------------------------------------------------------------------------------------
int screenWidth = 800; int screenWidth = 800;
int screenHeight = 450; int screenHeight = 450;
// Initialization
//---------------------------------------------------------
InitWindow(screenWidth, screenHeight, "raylib example 05a - sprite fonts"); InitWindow(screenWidth, screenHeight, "raylib example 05a - sprite fonts");
// NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required) // NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required)
SpriteFont font = LoadSpriteFont("resources/custom_font.png"); // SpriteFont loading SpriteFont font = LoadSpriteFont("resources/custom_font.png"); // SpriteFont loading
//---------------------------------------------------------- //--------------------------------------------------------------------------------------
// 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
//----------------------------------------------------- //----------------------------------------------------------------------------------
// TODO: Update your variables here // TODO: Update your variables here
//----------------------------------------------------- //----------------------------------------------------------------------------------
// Draw // Draw
//----------------------------------------------------- //----------------------------------------------------------------------------------
BeginDrawing(); BeginDrawing();
ClearBackground(RAYWHITE); ClearBackground(RAYWHITE);
@ -44,15 +44,15 @@ int main()
void DrawTextEx(SpriteFont spriteFont, const char* text, Vector2 position, int fontSize, int spacing, Color tint); void DrawTextEx(SpriteFont spriteFont, const char* text, Vector2 position, int fontSize, int spacing, Color tint);
*/ */
EndDrawing(); EndDrawing();
//----------------------------------------------------- //----------------------------------------------------------------------------------
} }
// De-Initialization // De-Initialization
//--------------------------------------------------------- //--------------------------------------------------------------------------------------
UnloadSpriteFont(font); // SpriteFont unloading UnloadSpriteFont(font); // SpriteFont unloading
CloseWindow(); // Close window and OpenGL context CloseWindow(); // Close window and OpenGL context
//---------------------------------------------------------- //--------------------------------------------------------------------------------------
return 0; return 0;
} }

View file

@ -13,27 +13,27 @@
int main() int main()
{ {
// Initialization
//--------------------------------------------------------------------------------------
int screenWidth = 800; int screenWidth = 800;
int screenHeight = 450; int screenHeight = 450;
// Initialization
//---------------------------------------------------------
InitWindow(screenWidth, screenHeight, "raylib example 04b - texture rectangle"); InitWindow(screenWidth, screenHeight, "raylib example 04b - texture rectangle");
// NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required) // NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required)
SpriteFont font = LoadSpriteFont("resources/custom_font.rbmf"); // SpriteFont loading SpriteFont font = LoadSpriteFont("resources/custom_font.rbmf"); // SpriteFont loading
//---------------------------------------------------------- //--------------------------------------------------------------------------------------
// 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
//----------------------------------------------------- //----------------------------------------------------------------------------------
// TODO: Update your variables here // TODO: Update your variables here
//----------------------------------------------------- //----------------------------------------------------------------------------------
// Draw // Draw
//----------------------------------------------------- //----------------------------------------------------------------------------------
BeginDrawing(); BeginDrawing();
ClearBackground(RAYWHITE); ClearBackground(RAYWHITE);
@ -44,15 +44,15 @@ int main()
void DrawTextEx(SpriteFont spriteFont, const char* text, Vector2 position, int fontSize, int spacing, Color tint); void DrawTextEx(SpriteFont spriteFont, const char* text, Vector2 position, int fontSize, int spacing, Color tint);
*/ */
EndDrawing(); EndDrawing();
//----------------------------------------------------- //----------------------------------------------------------------------------------
} }
// De-Initialization // De-Initialization
//--------------------------------------------------------- //--------------------------------------------------------------------------------------
UnloadSpriteFont(font); // SpriteFont unloading UnloadSpriteFont(font); // SpriteFont unloading
CloseWindow(); // Close window and OpenGL context CloseWindow(); // Close window and OpenGL context
//---------------------------------------------------------- //--------------------------------------------------------------------------------------
return 0; return 0;
} }

Some files were not shown because too many files have changed in this diff Show more