diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/heightmap.png | bin | 0 -> 1362 bytes | |||
| -rw-r--r-- | tests/test_billboard.c | 77 | ||||
| -rw-r--r-- | tests/test_formattext.c | 62 | ||||
| -rw-r--r-- | tests/test_heightmap.c | 76 | ||||
| -rw-r--r-- | tests/test_image_loading.c | 60 | ||||
| -rw-r--r-- | tests/test_mouse_wheel.c | 57 | ||||
| -rw-r--r-- | tests/test_random.c | 62 |
7 files changed, 394 insertions, 0 deletions
diff --git a/tests/heightmap.png b/tests/heightmap.png Binary files differnew file mode 100644 index 00000000..c17050fc --- /dev/null +++ b/tests/heightmap.png diff --git a/tests/test_billboard.c b/tests/test_billboard.c new file mode 100644 index 00000000..99cf0f33 --- /dev/null +++ b/tests/test_billboard.c @@ -0,0 +1,77 @@ +/******************************************************************************************* +* +* raylib test - Testing DrawBillboard() and DrawBillboardRec() +* +* 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) 2013 Ramon Santamaria (Ray San - raysan@raysanweb.com) +* +********************************************************************************************/ + +#include "raylib.h" + +int main() +{ + // Initialization + //-------------------------------------------------------------------------------------- + int screenWidth = 800; + int screenHeight = 450; + + Vector3 position = { 0.0, 0.0, 0.0 }; + + // Define the camera to look into our 3d world + Camera camera = {{ 10.0, 8.0, 10.0 }, { 0.0, 0.0, 0.0 }, { 0.0, 1.0, 0.0 }}; + + InitWindow(screenWidth, screenHeight, "raylib test - Billboards"); + + SetTargetFPS(60); // Set our game to run at 60 frames-per-second + + Texture2D texture = LoadTexture("resources/raylib_logo.png"); + Texture2D lena = LoadTexture("resources/lena.png"); + + Rectangle eyesRec = { 225, 240, 155, 50 }; + //-------------------------------------------------------------------------------------- + + // Main game loop + while (!WindowShouldClose()) // Detect window close button or ESC key + { + // Update + //---------------------------------------------------------------------------------- + if (IsKeyDown(KEY_LEFT)) camera.position.x -= 0.2; + if (IsKeyDown(KEY_RIGHT)) camera.position.x += 0.2; + if (IsKeyDown(KEY_UP)) camera.position.y -= 0.2; + if (IsKeyDown(KEY_DOWN)) camera.position.y += 0.2; + //---------------------------------------------------------------------------------- + + // Draw + //---------------------------------------------------------------------------------- + BeginDrawing(); + + ClearBackground(RAYWHITE); + + Begin3dMode(camera); + + //DrawBillboard(camera, texture, position, 2.0, WHITE); + DrawBillboardRec(camera, lena, eyesRec, position, 4.0, WHITE); + + DrawGrid(10.0, 1.0); // Draw a grid + + End3dMode(); + + DrawFPS(10, 10); + + EndDrawing(); + //---------------------------------------------------------------------------------- + } + + // De-Initialization + //-------------------------------------------------------------------------------------- + UnloadTexture(texture); // Unload texture + UnloadTexture(lena); // Unload texture + + CloseWindow(); // Close window and OpenGL context + //-------------------------------------------------------------------------------------- + + return 0; +}
\ No newline at end of file diff --git a/tests/test_formattext.c b/tests/test_formattext.c new file mode 100644 index 00000000..c74e76a7 --- /dev/null +++ b/tests/test_formattext.c @@ -0,0 +1,62 @@ +/******************************************************************************************* +* +* raylib test - Testing FormatText() function +* +* 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) 2013 Ramon Santamaria (Ray San - raysan@raysanweb.com) +* +********************************************************************************************/ + +#include "raylib.h" + +int main() +{ + // Initialization + //-------------------------------------------------------------------------------------- + int screenWidth = 800; + int screenHeight = 450; + + int score = 100020; + int hiscore = 200450; + int lives = 5; + + InitWindow(screenWidth, screenHeight, "raylib test - FormatText()"); + + SetTargetFPS(60); + //-------------------------------------------------------------------------------------- + + // Main game loop + while (!WindowShouldClose()) // Detect window close button or ESC key + { + // Update + //---------------------------------------------------------------------------------- + // TODO: Update your variables here + //---------------------------------------------------------------------------------- + + // Draw + //---------------------------------------------------------------------------------- + BeginDrawing(); + + ClearBackground(RAYWHITE); + + DrawText(FormatText("Score: %08i", score), 80, 80, 20, RED); + + DrawText(FormatText("HiScore: %08i", hiscore), 80, 120, 20, GREEN); + + DrawText(FormatText("Lives: %02i", lives), 80, 160, 40, BLUE); + + DrawText(FormatText("Elapsed Time: %02.02f ms", GetFrameTime()*1000), 80, 220, 20, BLACK); + + EndDrawing(); + //---------------------------------------------------------------------------------- + } + + // De-Initialization + //-------------------------------------------------------------------------------------- + CloseWindow(); // Close window and OpenGL context + //-------------------------------------------------------------------------------------- + + return 0; +}
\ No newline at end of file diff --git a/tests/test_heightmap.c b/tests/test_heightmap.c new file mode 100644 index 00000000..890bc0a4 --- /dev/null +++ b/tests/test_heightmap.c @@ -0,0 +1,76 @@ +/******************************************************************************************* +* +* raylib test - Testing Heightmap Loading and Drawing +* +* 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) 2013 Ramon Santamaria (Ray San - raysan@raysanweb.com) +* +********************************************************************************************/ + +#include "raylib.h" + +int main() +{ + // Initialization + //-------------------------------------------------------------------------------------- + int screenWidth = 800; + int screenHeight = 450; + + Vector3 position = { 0.0, 0.0, 0.0 }; + + // Define the camera to look into our 3d world + Camera camera = {{ 12.0, 10.0, 12.0 }, { 0.0, 0.0, 0.0 }, { 0.0, 1.0, 0.0 }}; + + InitWindow(screenWidth, screenHeight, "raylib test - Heightmap loading and drawing"); + + Image img = LoadImage("heightmap.png"); + Model map = LoadHeightmap(img, 4); + Texture2D tex = CreateTexture(img); + UnloadImage(img); + + SetTargetFPS(60); // Set our game to run at 60 frames-per-second + //-------------------------------------------------------------------------------------- + + // Main game loop + while (!WindowShouldClose()) // Detect window close button or ESC key + { + // Update + //---------------------------------------------------------------------------------- + // ... + //---------------------------------------------------------------------------------- + + // Draw + //---------------------------------------------------------------------------------- + BeginDrawing(); + + ClearBackground(RAYWHITE); + + Begin3dMode(camera); + + //DrawModel(map, position, 0.5f, MAROON); + DrawModelEx(map, tex, position, 0.5f, WHITE); // Draw 3d model with texture + + DrawGrid(10.0, 1.0); // Draw a grid + + DrawGizmo(position, false); + + End3dMode(); + + DrawFPS(10, 10); + + EndDrawing(); + //---------------------------------------------------------------------------------- + } + + // De-Initialization + //-------------------------------------------------------------------------------------- + UnloadTexture(tex); // Unload texture + UnloadModel(map); // Unload model + + CloseWindow(); // Close window and OpenGL context + //-------------------------------------------------------------------------------------- + + return 0; +}
\ No newline at end of file diff --git a/tests/test_image_loading.c b/tests/test_image_loading.c new file mode 100644 index 00000000..c554a394 --- /dev/null +++ b/tests/test_image_loading.c @@ -0,0 +1,60 @@ +/******************************************************************************************* +* +* raylib test - Testing LoadImage() and CreateTexture() +* +* 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) 2013 Ramon Santamaria (Ray San - raysan@raysanweb.com) +* +********************************************************************************************/ + +#include "raylib.h" + +int main() +{ + // Initialization + //-------------------------------------------------------------------------------------- + int screenWidth = 800; + int screenHeight = 450; + + InitWindow(screenWidth, screenHeight, "raylib test - Image loading"); + + // NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required) + + Image img = LoadImage("resources/raylib_logo.png"); + Texture2D texture = CreateTexture(img); + UnloadImage(img); + //--------------------------------------------------------------------------------------- + + // Main game loop + while (!WindowShouldClose()) // Detect window close button or ESC key + { + // Update + //---------------------------------------------------------------------------------- + // TODO: Update your variables here + //---------------------------------------------------------------------------------- + + // Draw + //---------------------------------------------------------------------------------- + BeginDrawing(); + + ClearBackground(RAYWHITE); + + DrawTexture(texture, screenWidth/2 - texture.width/2, screenHeight/2 - texture.height/2, WHITE); + + DrawText("this IS a texture!", 360, 370, 10, GRAY); + + EndDrawing(); + //---------------------------------------------------------------------------------- + } + + // De-Initialization + //-------------------------------------------------------------------------------------- + UnloadTexture(texture); // Texture unloading + + CloseWindow(); // Close window and OpenGL context + //-------------------------------------------------------------------------------------- + + return 0; +}
\ No newline at end of file diff --git a/tests/test_mouse_wheel.c b/tests/test_mouse_wheel.c new file mode 100644 index 00000000..0acbb0f8 --- /dev/null +++ b/tests/test_mouse_wheel.c @@ -0,0 +1,57 @@ +/******************************************************************************************* +* +* raylib test - Testing GetMouseWheelMove() +* +* 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) 2013 Ramon Santamaria (Ray San - raysan@raysanweb.com) +* +********************************************************************************************/ + +#include "raylib.h" + +int main() +{ + // Initialization + //-------------------------------------------------------------------------------------- + int screenWidth = 800; + int screenHeight = 450; + + InitWindow(screenWidth, screenHeight, "raylib test - Mouse wheel"); + + int positionY = 0; + int scrollSpeed = 4; // Scrolling speed in pixels + + SetTargetFPS(60); + //-------------------------------------------------------------------------------------- + + // Main game loop + while (!WindowShouldClose()) // Detect window close button or ESC key + { + // Update + //---------------------------------------------------------------------------------- + positionY -= (GetMouseWheelMove()*scrollSpeed); + //---------------------------------------------------------------------------------- + + // Draw + //---------------------------------------------------------------------------------- + BeginDrawing(); + + ClearBackground(RAYWHITE); + + DrawRectangle(200, positionY, 80, 80, MAROON); + + DrawText(FormatText("%i", positionY), 10, 10, 20, GRAY); + + EndDrawing(); + //---------------------------------------------------------------------------------- + } + + // De-Initialization + //-------------------------------------------------------------------------------------- + CloseWindow(); // Close window and OpenGL context + //-------------------------------------------------------------------------------------- + + return 0; +}
\ No newline at end of file diff --git a/tests/test_random.c b/tests/test_random.c new file mode 100644 index 00000000..b44bf1db --- /dev/null +++ b/tests/test_random.c @@ -0,0 +1,62 @@ +/******************************************************************************************* +* +* raylib test - Testing GetRandomValue() +* +* 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) 2013 Ramon Santamaria (Ray San - raysan@raysanweb.com) +* +********************************************************************************************/ + +#include "raylib.h" + +int main() +{ + // Initialization + //-------------------------------------------------------------------------------------- + int screenWidth = 800; + int screenHeight = 450; + + int framesCounter = 0; + + InitWindow(screenWidth, screenHeight, "raylib test - Random numbers"); + + int randValue = GetRandomValue(-8,5); + + SetTargetFPS(60); + //-------------------------------------------------------------------------------------- + + // Main game loop + while (!WindowShouldClose()) // Detect window close button or ESC key + { + // Update + //---------------------------------------------------------------------------------- + framesCounter++; + + if ((framesCounter/60)%2) + { + randValue = GetRandomValue(-8,5); + framesCounter = 0; + } + //---------------------------------------------------------------------------------- + + // Draw + //---------------------------------------------------------------------------------- + BeginDrawing(); + + ClearBackground(RAYWHITE); + + DrawText(FormatText("%i", randValue), 120, 120, 60, LIGHTGRAY); + + EndDrawing(); + //---------------------------------------------------------------------------------- + } + + // De-Initialization + //-------------------------------------------------------------------------------------- + CloseWindow(); // Close window and OpenGL context + //-------------------------------------------------------------------------------------- + + return 0; +}
\ No newline at end of file |
