Added some functions and Updated examples
View CHANGELOG for details
This commit is contained in:
parent
818e79638b
commit
e9143b8a8d
35 changed files with 586 additions and 199 deletions
|
@ -13,38 +13,38 @@
|
|||
|
||||
int main()
|
||||
{
|
||||
// Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
int screenWidth = 800;
|
||||
int screenHeight = 450;
|
||||
|
||||
// Initialization
|
||||
//---------------------------------------------------------
|
||||
InitWindow(screenWidth, screenHeight, "raylib example 01a - basic window");
|
||||
//----------------------------------------------------------
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
// Main game loop
|
||||
while (!WindowShouldClose()) // Detect window close button or ESC key
|
||||
{
|
||||
// Update
|
||||
//-----------------------------------------------------
|
||||
//----------------------------------------------------------------------------------
|
||||
// TODO: Update your variables here
|
||||
//-----------------------------------------------------
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
//-----------------------------------------------------
|
||||
//----------------------------------------------------------------------------------
|
||||
BeginDrawing();
|
||||
|
||||
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();
|
||||
//-----------------------------------------------------
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
// De-Initialization
|
||||
//---------------------------------------------------------
|
||||
//--------------------------------------------------------------------------------------
|
||||
CloseWindow(); // Close window and OpenGL context
|
||||
//----------------------------------------------------------
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
return 0;
|
||||
}
|
Binary file not shown.
|
@ -13,42 +13,42 @@
|
|||
|
||||
int main()
|
||||
{
|
||||
// Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
int screenWidth = 800;
|
||||
int screenHeight = 450;
|
||||
|
||||
// Initialization
|
||||
//---------------------------------------------------------
|
||||
InitWindow(screenWidth, screenHeight, "raylib example 02a - raylib logo");
|
||||
//----------------------------------------------------------
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
// Main game loop
|
||||
while (!WindowShouldClose()) // Detect window close button or ESC key
|
||||
{
|
||||
// Update
|
||||
//-----------------------------------------------------
|
||||
//----------------------------------------------------------------------------------
|
||||
// TODO: Update your variables here
|
||||
//-----------------------------------------------------
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
//-----------------------------------------------------
|
||||
//----------------------------------------------------------------------------------
|
||||
BeginDrawing();
|
||||
|
||||
ClearBackground(RAYWHITE);
|
||||
|
||||
DrawRectangle(screenWidth/2 - 128, screenHeight/2 - 128, 256, 256, BLACK);
|
||||
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();
|
||||
//-----------------------------------------------------
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
// De-Initialization
|
||||
//---------------------------------------------------------
|
||||
//--------------------------------------------------------------------------------------
|
||||
CloseWindow(); // Close window and OpenGL context
|
||||
//----------------------------------------------------------
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
return 0;
|
||||
}
|
Binary file not shown.
|
@ -13,24 +13,24 @@
|
|||
|
||||
int main()
|
||||
{
|
||||
// Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
int screenWidth = 800;
|
||||
int screenHeight = 450;
|
||||
|
||||
// Initialization
|
||||
//---------------------------------------------------------
|
||||
|
||||
InitWindow(screenWidth, screenHeight, "raylib example 02b - basic shapes drawing");
|
||||
//----------------------------------------------------------
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
// Main game loop
|
||||
while (!WindowShouldClose()) // Detect window close button or ESC key
|
||||
{
|
||||
// Update
|
||||
//-----------------------------------------------------
|
||||
//----------------------------------------------------------------------------------
|
||||
// TODO: Update your variables here
|
||||
//-----------------------------------------------------
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
//-----------------------------------------------------
|
||||
//----------------------------------------------------------------------------------
|
||||
BeginDrawing();
|
||||
|
||||
ClearBackground(RAYWHITE);
|
||||
|
@ -61,13 +61,13 @@ void DrawPolyLine(Vector2 *points, int numPoints, Color color);
|
|||
DrawText("_____", 320, 280, 50, 1, BLACK);
|
||||
|
||||
EndDrawing();
|
||||
//-----------------------------------------------------
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
// De-Initialization
|
||||
//---------------------------------------------------------
|
||||
//--------------------------------------------------------------------------------------
|
||||
CloseWindow(); // Close window and OpenGL context
|
||||
//----------------------------------------------------------
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -13,29 +13,29 @@
|
|||
|
||||
int main()
|
||||
{
|
||||
// Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
int screenWidth = 800;
|
||||
int screenHeight = 450;
|
||||
|
||||
// Initialization
|
||||
//---------------------------------------------------------
|
||||
InitWindow(screenWidth, screenHeight, "raylib example 02c - raylib color palette");
|
||||
//----------------------------------------------------------
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
// Main game loop
|
||||
while (!WindowShouldClose()) // Detect window close button or ESC key
|
||||
{
|
||||
// Update
|
||||
//-----------------------------------------------------
|
||||
//----------------------------------------------------------------------------------
|
||||
// TODO: Update your variables here
|
||||
//-----------------------------------------------------
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
//-----------------------------------------------------
|
||||
//----------------------------------------------------------------------------------
|
||||
BeginDrawing();
|
||||
|
||||
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, 188, 100, 100, GRAY);
|
||||
|
@ -60,36 +60,36 @@ int main()
|
|||
DrawRectangle(674, 296, 100, 100, BEIGE);
|
||||
|
||||
|
||||
DrawText("DARKGRAY", 57, 166, 10, 2, BLACK);
|
||||
DrawText("GRAY", 89, 274, 10, 2, BLACK);
|
||||
DrawText("LIGHTGRAY", 51, 382, 10, 2, BLACK);
|
||||
DrawText("MAROON", 180, 166, 10, 2, BLACK);
|
||||
DrawText("RED", 207, 274, 10, 2, BLACK);
|
||||
DrawText("PINK", 200, 382, 10, 2, BLACK);
|
||||
DrawText("ORANGE", 290, 166, 10, 2, BLACK);
|
||||
DrawText("GOLD", 306, 274, 10, 2, BLACK);
|
||||
DrawText("YELLOW", 290, 382, 10, 2, BLACK);
|
||||
DrawText("DARKGREEN", 374, 166, 10, 2, BLACK);
|
||||
DrawText("LIME", 417, 274, 10, 2, BLACK);
|
||||
DrawText("GREEN", 407, 382, 10, 2, BLACK);
|
||||
DrawText("DARKBLUE", 491, 166, 10, 2, BLACK);
|
||||
DrawText("BLUE", 523, 274, 10, 2, BLACK);
|
||||
DrawText("SKYBLUE", 499, 382, 10, 2, BLACK);
|
||||
DrawText("DARKPURPLE", 582, 166, 10, 2, BLACK);
|
||||
DrawText("VIOLET", 617, 274, 10, 2, BLACK);
|
||||
DrawText("PURPLE", 615, 382, 10, 2, BLACK);
|
||||
DrawText("DARKBROWN", 695, 166, 10, 2, BLACK);
|
||||
DrawText("BROWN", 728, 274, 10, 2, BLACK);
|
||||
DrawText("BEIGE", 733, 382, 10, 2, BLACK);
|
||||
DrawText("DARKGRAY", 65, 166, 10, BLACK);
|
||||
DrawText("GRAY", 93, 274, 10, BLACK);
|
||||
DrawText("LIGHTGRAY", 61, 382, 10, BLACK);
|
||||
DrawText("MAROON", 186, 166, 10, BLACK);
|
||||
DrawText("RED", 208, 274, 10, BLACK);
|
||||
DrawText("PINK", 204, 382, 10, BLACK);
|
||||
DrawText("ORANGE", 295, 166, 10, BLACK);
|
||||
DrawText("GOLD", 310, 274, 10, BLACK);
|
||||
DrawText("YELLOW", 300, 382, 10, BLACK);
|
||||
DrawText("DARKGREEN", 382, 166, 10, BLACK);
|
||||
DrawText("LIME", 420, 274, 10, BLACK);
|
||||
DrawText("GREEN", 410, 382, 10, BLACK);
|
||||
DrawText("DARKBLUE", 498, 166, 10, BLACK);
|
||||
DrawText("BLUE", 526, 274, 10, BLACK);
|
||||
DrawText("SKYBLUE", 505, 382, 10, BLACK);
|
||||
DrawText("DARKPURPLE", 592, 166, 10, BLACK);
|
||||
DrawText("VIOLET", 621, 274, 10, BLACK);
|
||||
DrawText("PURPLE", 620, 382, 10, BLACK);
|
||||
DrawText("DARKBROWN", 705, 166, 10, BLACK);
|
||||
DrawText("BROWN", 733, 274, 10, BLACK);
|
||||
DrawText("BEIGE", 737, 382, 10, BLACK);
|
||||
|
||||
EndDrawing();
|
||||
//-----------------------------------------------------
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
// De-Initialization
|
||||
//---------------------------------------------------------
|
||||
//--------------------------------------------------------------------------------------
|
||||
CloseWindow(); // Close window and OpenGL context
|
||||
//----------------------------------------------------------
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
return 0;
|
||||
}
|
Binary file not shown.
Binary file not shown.
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 5.1 KiB |
|
@ -12,46 +12,48 @@
|
|||
#include "raylib.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
// Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
int screenWidth = 800;
|
||||
int screenHeight = 450;
|
||||
|
||||
Vector2 ballPosition = { screenWidth/2, screenHeight/2 };
|
||||
|
||||
// Initialization
|
||||
//---------------------------------------------------------
|
||||
InitWindow(screenWidth, screenHeight, "raylib example 05 - keyboard input");
|
||||
//----------------------------------------------------------
|
||||
|
||||
SetTargetFPS(60); // Set target frames-per-second
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
// Main game loop
|
||||
while (!WindowShouldClose()) // Detect window close button or ESC key
|
||||
{
|
||||
// Update
|
||||
//-----------------------------------------------------
|
||||
//----------------------------------------------------------------------------------
|
||||
if (IsKeyPressed(KEY_RIGHT)) ballPosition.x += 0.8;
|
||||
if (IsKeyPressed(KEY_LEFT)) ballPosition.x -= 0.8;
|
||||
if (IsKeyPressed(KEY_UP)) ballPosition.y -= 0.8;
|
||||
if (IsKeyPressed(KEY_DOWN)) ballPosition.y += 0.8;
|
||||
//-----------------------------------------------------
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
//-----------------------------------------------------
|
||||
//----------------------------------------------------------------------------------
|
||||
BeginDrawing();
|
||||
|
||||
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);
|
||||
|
||||
EndDrawing();
|
||||
//-----------------------------------------------------
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
// De-Initialization
|
||||
//---------------------------------------------------------
|
||||
//--------------------------------------------------------------------------------------
|
||||
CloseWindow(); // Close window and OpenGL context
|
||||
//----------------------------------------------------------
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
return 0;
|
||||
}
|
Binary file not shown.
|
@ -13,6 +13,8 @@
|
|||
|
||||
int main()
|
||||
{
|
||||
// Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
int screenWidth = 800;
|
||||
int screenHeight = 450;
|
||||
|
||||
|
@ -20,16 +22,14 @@ int main()
|
|||
int counter = 0;
|
||||
int mouseX, mouseY;
|
||||
|
||||
// Initialization
|
||||
//---------------------------------------------------------
|
||||
InitWindow(screenWidth, screenHeight, "raylib example 06 - mouse input");
|
||||
//----------------------------------------------------------
|
||||
//---------------------------------------------------------------------------------------
|
||||
|
||||
// Main game loop
|
||||
while (!WindowShouldClose()) // Detect window close button or ESC key
|
||||
{
|
||||
// Update
|
||||
//-----------------------------------------------------
|
||||
//----------------------------------------------------------------------------------
|
||||
if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON))
|
||||
{
|
||||
mouseX = GetMouseX();
|
||||
|
@ -38,26 +38,26 @@ int main()
|
|||
ballPosition.x = (float)mouseX;
|
||||
ballPosition.y = (float)mouseY;
|
||||
}
|
||||
//-----------------------------------------------------
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
//-----------------------------------------------------
|
||||
//----------------------------------------------------------------------------------
|
||||
BeginDrawing();
|
||||
|
||||
ClearBackground(RAYWHITE);
|
||||
|
||||
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();
|
||||
//-----------------------------------------------------
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
// De-Initialization
|
||||
//---------------------------------------------------------
|
||||
//--------------------------------------------------------------------------------------
|
||||
CloseWindow(); // Close window and OpenGL context
|
||||
//----------------------------------------------------------
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
return 0;
|
||||
}
|
Binary file not shown.
|
@ -13,22 +13,24 @@
|
|||
|
||||
int main()
|
||||
{
|
||||
// Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
int screenWidth = 800;
|
||||
int screenHeight = 450;
|
||||
|
||||
Vector2 ballPosition = { screenWidth/2, screenHeight/2 };
|
||||
Vector2 gamepadMove = { 0, 0 };
|
||||
|
||||
// Initialization
|
||||
//---------------------------------------------------------
|
||||
InitWindow(screenWidth, screenHeight, "raylib example 01 - gamepad input");
|
||||
//----------------------------------------------------------
|
||||
|
||||
SetTargetFPS(60); // Set target frames-per-second
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
// Main game loop
|
||||
while (!WindowShouldClose()) // Detect window close button or ESC key
|
||||
{
|
||||
// Update
|
||||
//-----------------------------------------------------
|
||||
//----------------------------------------------------------------------------------
|
||||
if (IsGamepadAvailable(GAMEPAD_PLAYER1))
|
||||
{
|
||||
gamepadMove = GetGamepadMovement(GAMEPAD_PLAYER1);
|
||||
|
@ -42,26 +44,26 @@ int main()
|
|||
ballPosition.y = screenHeight/2;
|
||||
}
|
||||
}
|
||||
//-----------------------------------------------------
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
//-----------------------------------------------------
|
||||
//----------------------------------------------------------------------------------
|
||||
BeginDrawing();
|
||||
|
||||
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);
|
||||
|
||||
EndDrawing();
|
||||
//-----------------------------------------------------
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
// De-Initialization
|
||||
//---------------------------------------------------------
|
||||
//--------------------------------------------------------------------------------------
|
||||
CloseWindow(); // Close window and OpenGL context
|
||||
//----------------------------------------------------------
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
return 0;
|
||||
}
|
Binary file not shown.
|
@ -12,28 +12,28 @@
|
|||
#include "raylib.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
// Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
int screenWidth = 800;
|
||||
int screenHeight = 450;
|
||||
|
||||
// Initialization
|
||||
//---------------------------------------------------------
|
||||
|
||||
InitWindow(screenWidth, screenHeight, "raylib example 04a - texture loading and drawing");
|
||||
|
||||
// NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required)
|
||||
Texture2D texture = LoadTexture("resources/raylib_logo.png"); // Texture loading
|
||||
//----------------------------------------------------------
|
||||
//---------------------------------------------------------------------------------------
|
||||
|
||||
// Main game loop
|
||||
while (!WindowShouldClose()) // Detect window close button or ESC key
|
||||
{
|
||||
// Update
|
||||
//-----------------------------------------------------
|
||||
//----------------------------------------------------------------------------------
|
||||
// TODO: Update your variables here
|
||||
//-----------------------------------------------------
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
//-----------------------------------------------------
|
||||
//----------------------------------------------------------------------------------
|
||||
BeginDrawing();
|
||||
|
||||
ClearBackground(RAYWHITE);
|
||||
|
@ -41,18 +41,18 @@ int main()
|
|||
DrawTexture(texture, screenWidth/2 - texture.width/2,
|
||||
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();
|
||||
//-----------------------------------------------------
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
// De-Initialization
|
||||
//---------------------------------------------------------
|
||||
//--------------------------------------------------------------------------------------
|
||||
UnloadTexture(texture); // Texture unloading
|
||||
|
||||
CloseWindow(); // Close window and OpenGL context
|
||||
//----------------------------------------------------------
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
return 0;
|
||||
}
|
Binary file not shown.
|
@ -13,27 +13,27 @@
|
|||
|
||||
int main()
|
||||
{
|
||||
// Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
int screenWidth = 800;
|
||||
int screenHeight = 450;
|
||||
|
||||
// Initialization
|
||||
//---------------------------------------------------------
|
||||
|
||||
InitWindow(screenWidth, screenHeight, "raylib example 04b - texture rectangle");
|
||||
|
||||
// NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required)
|
||||
Texture2D texture = LoadTexture("resources/raylib_logo.png"); // Texture loading
|
||||
//----------------------------------------------------------
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
// Main game loop
|
||||
while (!WindowShouldClose()) // Detect window close button or ESC key
|
||||
{
|
||||
// Update
|
||||
//-----------------------------------------------------
|
||||
//----------------------------------------------------------------------------------
|
||||
// TODO: Update your variables here
|
||||
//-----------------------------------------------------
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
//-----------------------------------------------------
|
||||
//----------------------------------------------------------------------------------
|
||||
BeginDrawing();
|
||||
|
||||
ClearBackground(RAYWHITE);
|
||||
|
@ -44,15 +44,15 @@ int main()
|
|||
void DrawTextureRec(Texture2D texture, Rectangle sourceRec, Vector2 position, float scale, Color tint);
|
||||
*/
|
||||
EndDrawing();
|
||||
//-----------------------------------------------------
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
// De-Initialization
|
||||
//---------------------------------------------------------
|
||||
//--------------------------------------------------------------------------------------
|
||||
UnloadTexture(texture); // Texture unloading
|
||||
|
||||
CloseWindow(); // Close window and OpenGL context
|
||||
//----------------------------------------------------------
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -13,27 +13,27 @@
|
|||
|
||||
int main()
|
||||
{
|
||||
// Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
int screenWidth = 800;
|
||||
int screenHeight = 450;
|
||||
|
||||
// Initialization
|
||||
//---------------------------------------------------------
|
||||
|
||||
InitWindow(screenWidth, screenHeight, "raylib example 05a - sprite fonts");
|
||||
|
||||
// NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required)
|
||||
SpriteFont font = LoadSpriteFont("resources/custom_font.png"); // SpriteFont loading
|
||||
//----------------------------------------------------------
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
// Main game loop
|
||||
while (!WindowShouldClose()) // Detect window close button or ESC key
|
||||
{
|
||||
// Update
|
||||
//-----------------------------------------------------
|
||||
//----------------------------------------------------------------------------------
|
||||
// TODO: Update your variables here
|
||||
//-----------------------------------------------------
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
//-----------------------------------------------------
|
||||
//----------------------------------------------------------------------------------
|
||||
BeginDrawing();
|
||||
|
||||
ClearBackground(RAYWHITE);
|
||||
|
@ -44,15 +44,15 @@ int main()
|
|||
void DrawTextEx(SpriteFont spriteFont, const char* text, Vector2 position, int fontSize, int spacing, Color tint);
|
||||
*/
|
||||
EndDrawing();
|
||||
//-----------------------------------------------------
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
// De-Initialization
|
||||
//---------------------------------------------------------
|
||||
//--------------------------------------------------------------------------------------
|
||||
UnloadSpriteFont(font); // SpriteFont unloading
|
||||
|
||||
CloseWindow(); // Close window and OpenGL context
|
||||
//----------------------------------------------------------
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -13,27 +13,27 @@
|
|||
|
||||
int main()
|
||||
{
|
||||
// Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
int screenWidth = 800;
|
||||
int screenHeight = 450;
|
||||
|
||||
// Initialization
|
||||
//---------------------------------------------------------
|
||||
|
||||
InitWindow(screenWidth, screenHeight, "raylib example 04b - texture rectangle");
|
||||
|
||||
// NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required)
|
||||
SpriteFont font = LoadSpriteFont("resources/custom_font.rbmf"); // SpriteFont loading
|
||||
//----------------------------------------------------------
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
// Main game loop
|
||||
while (!WindowShouldClose()) // Detect window close button or ESC key
|
||||
{
|
||||
// Update
|
||||
//-----------------------------------------------------
|
||||
//----------------------------------------------------------------------------------
|
||||
// TODO: Update your variables here
|
||||
//-----------------------------------------------------
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
//-----------------------------------------------------
|
||||
//----------------------------------------------------------------------------------
|
||||
BeginDrawing();
|
||||
|
||||
ClearBackground(RAYWHITE);
|
||||
|
@ -44,15 +44,15 @@ int main()
|
|||
void DrawTextEx(SpriteFont spriteFont, const char* text, Vector2 position, int fontSize, int spacing, Color tint);
|
||||
*/
|
||||
EndDrawing();
|
||||
//-----------------------------------------------------
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
// De-Initialization
|
||||
//---------------------------------------------------------
|
||||
//--------------------------------------------------------------------------------------
|
||||
UnloadSpriteFont(font); // SpriteFont unloading
|
||||
|
||||
CloseWindow(); // Close window and OpenGL context
|
||||
//----------------------------------------------------------
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -13,24 +13,24 @@
|
|||
|
||||
int main()
|
||||
{
|
||||
// Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
int screenWidth = 800;
|
||||
int screenHeight = 450;
|
||||
|
||||
// Initialization
|
||||
//---------------------------------------------------------
|
||||
InitWindow(screenWidth, screenHeight, "raylib example 06a - color selection");
|
||||
//----------------------------------------------------------
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
// Main game loop
|
||||
while (!WindowShouldClose()) // Detect window close button or ESC key
|
||||
{
|
||||
// Update
|
||||
//-----------------------------------------------------
|
||||
//----------------------------------------------------------------------------------
|
||||
// TODO: Update your variables here
|
||||
//-----------------------------------------------------
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
//-----------------------------------------------------
|
||||
//----------------------------------------------------------------------------------
|
||||
BeginDrawing();
|
||||
|
||||
ClearBackground(RAYWHITE);
|
||||
|
@ -38,13 +38,13 @@ int main()
|
|||
// TODO: Comming soon...
|
||||
|
||||
EndDrawing();
|
||||
//-----------------------------------------------------
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
// De-Initialization
|
||||
//---------------------------------------------------------
|
||||
//--------------------------------------------------------------------------------------
|
||||
CloseWindow(); // Close window and OpenGL context
|
||||
//----------------------------------------------------------
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -13,24 +13,24 @@
|
|||
|
||||
int main()
|
||||
{
|
||||
// Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
int screenWidth = 800;
|
||||
int screenHeight = 450;
|
||||
|
||||
// Initialization
|
||||
//---------------------------------------------------------
|
||||
|
||||
InitWindow(screenWidth, screenHeight, "raylib example 06b - shape selection");
|
||||
//----------------------------------------------------------
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
// Main game loop
|
||||
while (!WindowShouldClose()) // Detect window close button or ESC key
|
||||
{
|
||||
// Update
|
||||
//-----------------------------------------------------
|
||||
//----------------------------------------------------------------------------------
|
||||
// TODO: Update your variables here
|
||||
//-----------------------------------------------------
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
//-----------------------------------------------------
|
||||
//----------------------------------------------------------------------------------
|
||||
BeginDrawing();
|
||||
|
||||
ClearBackground(RAYWHITE);
|
||||
|
@ -38,13 +38,13 @@ int main()
|
|||
// TODO: Comming soon...
|
||||
|
||||
EndDrawing();
|
||||
//-----------------------------------------------------
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
// De-Initialization
|
||||
//---------------------------------------------------------
|
||||
//--------------------------------------------------------------------------------------
|
||||
CloseWindow(); // Close window and OpenGL context
|
||||
//----------------------------------------------------------
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -13,24 +13,24 @@
|
|||
|
||||
int main()
|
||||
{
|
||||
// Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
int screenWidth = 800;
|
||||
int screenHeight = 450;
|
||||
|
||||
// Initialization
|
||||
//---------------------------------------------------------
|
||||
|
||||
InitWindow(screenWidth, screenHeight, "raylib example 06c - font selection");
|
||||
//----------------------------------------------------------
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
// Main game loop
|
||||
while (!WindowShouldClose()) // Detect window close button or ESC key
|
||||
{
|
||||
// Update
|
||||
//-----------------------------------------------------
|
||||
//----------------------------------------------------------------------------------
|
||||
// TODO: Update your variables here
|
||||
//-----------------------------------------------------
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
//-----------------------------------------------------
|
||||
//----------------------------------------------------------------------------------
|
||||
BeginDrawing();
|
||||
|
||||
ClearBackground(RAYWHITE);
|
||||
|
@ -38,13 +38,13 @@ int main()
|
|||
// TODO: Comming soon...
|
||||
|
||||
EndDrawing();
|
||||
//-----------------------------------------------------
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
// De-Initialization
|
||||
//---------------------------------------------------------
|
||||
//--------------------------------------------------------------------------------------
|
||||
CloseWindow(); // Close window and OpenGL context
|
||||
//----------------------------------------------------------
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -13,6 +13,7 @@
|
|||
|
||||
int main()
|
||||
{
|
||||
<<<<<<< HEAD
|
||||
int screenWidth = 800;
|
||||
int screenHeight = 450;
|
||||
|
||||
|
@ -25,9 +26,24 @@ int main()
|
|||
InitWindow(screenWidth, screenHeight, "raylib example 07a - 3d mode");
|
||||
//----------------------------------------------------------
|
||||
|
||||
=======
|
||||
// Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
int screenWidth = 800;
|
||||
int screenHeight = 450;
|
||||
|
||||
Vector3 position = { 0.0, 0.0, 0.0 };
|
||||
|
||||
Camera camera = {{ 0.0, 10.0, 10.0 }, { 0.0, 0.0, 0.0 }, { 0.0, 1.0, 0.0 }};
|
||||
|
||||
InitWindow(screenWidth, screenHeight, "raylib example 07a - 3d mode");
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
>>>>>>> Added some functions and examples update
|
||||
// Main game loop
|
||||
while (!WindowShouldClose()) // Detect window close button or ESC key
|
||||
{
|
||||
<<<<<<< HEAD
|
||||
// Update
|
||||
//-----------------------------------------------------
|
||||
// TODO: Update your variables here
|
||||
|
@ -60,5 +76,39 @@ int main()
|
|||
CloseWindow(); // Close window and OpenGL context
|
||||
//----------------------------------------------------------
|
||||
|
||||
=======
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
// TODO: Update your variables here
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
//----------------------------------------------------------------------------------
|
||||
BeginDrawing();
|
||||
|
||||
ClearBackground(WHITE);
|
||||
|
||||
Begin3dMode(camera);
|
||||
|
||||
DrawCube(position, 2, 2, 2, RED);
|
||||
|
||||
DrawGrid(10.0, 1.0);
|
||||
|
||||
End3dMode();
|
||||
|
||||
DrawText("Welcome to the third dimension!", 10, 40, 20, DARKGRAY);
|
||||
|
||||
DrawFPS(10, 10);
|
||||
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
// De-Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
CloseWindow(); // Close window and OpenGL context
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
>>>>>>> Added some functions and examples update
|
||||
return 0;
|
||||
}
|
Binary file not shown.
|
@ -13,12 +13,20 @@
|
|||
|
||||
int main()
|
||||
{
|
||||
<<<<<<< HEAD
|
||||
int screenWidth = 800;
|
||||
int screenHeight = 450;
|
||||
=======
|
||||
// Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
int screenWidth = 800;
|
||||
int screenHeight = 450;
|
||||
>>>>>>> Added some functions and examples update
|
||||
|
||||
Vector3 position = { 0.0, 0.0, 0.0 };
|
||||
|
||||
// Define the camera to look into our 3d world
|
||||
<<<<<<< HEAD
|
||||
Camera camera = {{ 0.0, 10.0, 10.0 }, { 0.0, 0.0, 0.0 }, { 0.0, 1.0, 0.0 }};
|
||||
|
||||
// Initialization
|
||||
|
@ -28,9 +36,19 @@ int main()
|
|||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||
//----------------------------------------------------------
|
||||
|
||||
=======
|
||||
Camera camera = {{ 0.0, 10.0, 10.0 }, { 0.0, 0.0, 0.0 }, { 0.0, 1.0, 0.0 }};
|
||||
|
||||
InitWindow(screenWidth, screenHeight, "raylib example 07b - 3d shapes");
|
||||
|
||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
>>>>>>> Added some functions and examples update
|
||||
// Main game loop
|
||||
while (!WindowShouldClose()) // Detect window close button or ESC key
|
||||
{
|
||||
<<<<<<< HEAD
|
||||
// Update
|
||||
//-----------------------------------------------------
|
||||
// TODO: Update your variables here
|
||||
|
@ -45,6 +63,22 @@ int main()
|
|||
Begin3dMode(camera);
|
||||
|
||||
DrawCube(position, 2, 2, 2, RED); // Draw a cube
|
||||
=======
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
// TODO: Update your variables here
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
//----------------------------------------------------------------------------------
|
||||
BeginDrawing();
|
||||
|
||||
ClearBackground(RAYWHITE);
|
||||
|
||||
Begin3dMode(camera);
|
||||
|
||||
DrawCube(position, 2, 2, 2, RED); // Draw a cube
|
||||
>>>>>>> Added some functions and examples update
|
||||
DrawCubeWires(position, 2, 2, 2, MAROON); // Draw a wired-cube
|
||||
|
||||
// TODO: Draw some basic 3d shapes
|
||||
|
@ -58,6 +92,7 @@ void DrawSphereWires(Vector3 centerPos, float radius, Color color);
|
|||
void DrawCylinder(Vector3 position, float radiusTop, float radiusBottom, float height, int slices, Color color);
|
||||
void DrawCylinderWires(Vector3 position, float radiusTop, float radiusBottom, float height, int slices, Color color);
|
||||
*/
|
||||
<<<<<<< HEAD
|
||||
DrawGrid(10.0, 1.0); // Draw a grid
|
||||
|
||||
End3dMode();
|
||||
|
@ -73,5 +108,22 @@ void DrawCylinderWires(Vector3 position, float radiusTop, float radiusBottom, fl
|
|||
CloseWindow(); // Close window and OpenGL context
|
||||
//----------------------------------------------------------
|
||||
|
||||
=======
|
||||
DrawGrid(10.0, 1.0); // Draw a grid
|
||||
|
||||
End3dMode();
|
||||
|
||||
DrawFPS(10, 10);
|
||||
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
// De-Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
CloseWindow(); // Close window and OpenGL context
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
>>>>>>> Added some functions and examples update
|
||||
return 0;
|
||||
}
|
|
@ -13,12 +13,20 @@
|
|||
|
||||
int main()
|
||||
{
|
||||
<<<<<<< HEAD
|
||||
int screenWidth = 800;
|
||||
int screenHeight = 450;
|
||||
=======
|
||||
// Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
int screenWidth = 800;
|
||||
int screenHeight = 450;
|
||||
>>>>>>> Added some functions and examples update
|
||||
|
||||
Vector3 position = { 0.0, 0.0, 0.0 };
|
||||
|
||||
// Define the camera to look into our 3d world
|
||||
<<<<<<< HEAD
|
||||
Camera camera = {{ 10.0, 8.0, 10.0 }, { 0.0, 0.0, 0.0 }, { 0.0, 1.0, 0.0 }};
|
||||
|
||||
// Initialization
|
||||
|
@ -31,9 +39,22 @@ int main()
|
|||
Model cat = LoadModel("resources/cat.obj");
|
||||
//----------------------------------------------------------
|
||||
|
||||
=======
|
||||
Camera camera = {{ 10.0, 8.0, 10.0 }, { 0.0, 0.0, 0.0 }, { 0.0, 1.0, 0.0 }};
|
||||
|
||||
InitWindow(screenWidth, screenHeight, "raylib example 07c - 3d models");
|
||||
|
||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||
|
||||
Texture2D texture = LoadTexture("resources/catwhite.png");
|
||||
Model cat = LoadModel("resources/cat.obj");
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
>>>>>>> Added some functions and examples update
|
||||
// Main game loop
|
||||
while (!WindowShouldClose()) // Detect window close button or ESC key
|
||||
{
|
||||
<<<<<<< HEAD
|
||||
// Update
|
||||
//-----------------------------------------------------
|
||||
if (IsKeyPressed(KEY_LEFT)) position.x -= 0.2;
|
||||
|
@ -51,10 +72,30 @@ int main()
|
|||
Begin3dMode(camera);
|
||||
|
||||
DrawModelEx(cat, texture, position, 0.1f, WHITE); // Draw 3d model with texture
|
||||
=======
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
if (IsKeyPressed(KEY_LEFT)) position.x -= 0.2;
|
||||
if (IsKeyPressed(KEY_RIGHT)) position.x += 0.2;
|
||||
if (IsKeyPressed(KEY_UP)) position.z -= 0.2;
|
||||
if (IsKeyPressed(KEY_DOWN)) position.z += 0.2;
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
//----------------------------------------------------------------------------------
|
||||
BeginDrawing();
|
||||
|
||||
ClearBackground(RAYWHITE);
|
||||
|
||||
Begin3dMode(camera);
|
||||
|
||||
DrawModelEx(cat, texture, position, 0.1f, WHITE); // Draw 3d model with texture
|
||||
>>>>>>> Added some functions and examples update
|
||||
|
||||
DrawGrid(10.0, 1.0); // Draw a grid
|
||||
|
||||
DrawGizmo(position, false);
|
||||
<<<<<<< HEAD
|
||||
|
||||
End3dMode();
|
||||
|
||||
|
@ -66,11 +107,30 @@ int main()
|
|||
|
||||
// De-Initialization
|
||||
//---------------------------------------------------------
|
||||
=======
|
||||
|
||||
End3dMode();
|
||||
|
||||
DrawFPS(10, 10);
|
||||
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
// De-Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
>>>>>>> Added some functions and examples update
|
||||
UnloadTexture(texture); // Unload texture
|
||||
UnloadModel(cat); // Unload model
|
||||
|
||||
CloseWindow(); // Close window and OpenGL context
|
||||
//----------------------------------------------------------
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
CloseWindow(); // Close window and OpenGL context
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
>>>>>>> Added some functions and examples update
|
||||
return 0;
|
||||
}
|
Binary file not shown.
|
@ -13,6 +13,7 @@
|
|||
|
||||
int main()
|
||||
{
|
||||
<<<<<<< HEAD
|
||||
int screenWidth = 800;
|
||||
int screenHeight = 450;
|
||||
|
||||
|
@ -28,9 +29,24 @@ int main()
|
|||
bool previousKeyState = currentKeyState;
|
||||
//----------------------------------------------------------
|
||||
|
||||
=======
|
||||
// Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
int screenWidth = 800;
|
||||
int screenHeight = 450;
|
||||
|
||||
InitWindow(screenWidth, screenHeight, "raylib example 08 - audio loading and playing");
|
||||
|
||||
InitAudioDevice(); // Initialize audio device
|
||||
|
||||
Sound fx = LoadSound("resources/coin.wav"); // Load WAV audio file
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
>>>>>>> Added some functions and examples update
|
||||
// Main game loop
|
||||
while (!WindowShouldClose()) // Detect window close button or ESC key
|
||||
{
|
||||
<<<<<<< HEAD
|
||||
// Update
|
||||
//-----------------------------------------------------
|
||||
currentKeyState = IsKeyPressed(KEY_SPACE); // Check if Space have been pressed
|
||||
|
@ -65,5 +81,33 @@ int main()
|
|||
CloseWindow(); // Close window and OpenGL context
|
||||
//----------------------------------------------------------
|
||||
|
||||
=======
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
if (IsKeyPressed(KEY_SPACE)) PlaySound(fx); // Play the sound!
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
//----------------------------------------------------------------------------------
|
||||
BeginDrawing();
|
||||
|
||||
ClearBackground(RAYWHITE);
|
||||
|
||||
DrawText("Press SPACE to PLAY the SOUND!", 240, 200, 20, LIGHTGRAY);
|
||||
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
// De-Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
UnloadSound(fx); // Unload sound data
|
||||
|
||||
CloseAudioDevice(); // Close audio device
|
||||
|
||||
CloseWindow(); // Close window and OpenGL context
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
>>>>>>> Added some functions and examples update
|
||||
return 0;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue