aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorraysan5 <raysan5@gmail.com>2015-08-30 17:46:37 +0200
committerraysan5 <raysan5@gmail.com>2015-08-30 17:46:37 +0200
commit32330801c96ad017de1334922a8a88f08811e6f4 (patch)
tree6d28ac760ef9198aba8ce3df0a87dbb9405fa231 /examples
parent535b9e606f6571c5d4163481d077ae3d5a79f1b8 (diff)
downloadraylib-32330801c96ad017de1334922a8a88f08811e6f4.tar.gz
raylib-32330801c96ad017de1334922a8a88f08811e6f4.zip
Updates some examples
Diffstat (limited to 'examples')
-rw-r--r--examples/core_3d_camera_first_person.c91
-rw-r--r--examples/core_3d_camera_first_person.pngbin0 -> 18402 bytes
-rw-r--r--examples/core_3d_camera_free.c2
-rw-r--r--examples/core_3d_picking.c2
-rw-r--r--examples/models_billboard.c2
-rw-r--r--examples/models_cubicmap.c10
-rw-r--r--examples/models_heightmap.c12
-rw-r--r--examples/text_font_select.c10
-rw-r--r--examples/text_rbmf_fonts.c10
-rw-r--r--examples/text_sprite_fonts.c18
10 files changed, 124 insertions, 33 deletions
diff --git a/examples/core_3d_camera_first_person.c b/examples/core_3d_camera_first_person.c
new file mode 100644
index 00000000..cd37f873
--- /dev/null
+++ b/examples/core_3d_camera_first_person.c
@@ -0,0 +1,91 @@
+/*******************************************************************************************
+*
+* raylib [core] example - 3d camera first person
+*
+* This example has been created using raylib 1.3 (www.raylib.com)
+* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
+*
+* Copyright (c) 2015 Ramon Santamaria (@raysan5)
+*
+********************************************************************************************/
+
+#include "raylib.h"
+
+#define MAX_COLUMNS 20
+
+int main()
+{
+ // Initialization
+ //--------------------------------------------------------------------------------------
+ int screenWidth = 800;
+ int screenHeight = 450;
+
+ InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d camera first person");
+
+ // Define the camera to look into our 3d world
+ Camera camera = {{ 0.0, 10.0, 10.0 }, { 0.0, 0.0, 0.0 }, { 0.0, 1.0, 0.0 }};
+
+ // Generates some random columns
+ float heights[MAX_COLUMNS];
+ Vector3 positions[MAX_COLUMNS] = { 0.0, 2.5, 0.0 };
+ Color colors[MAX_COLUMNS];
+
+ for (int i = 0; i < MAX_COLUMNS; i++)
+ {
+ heights[i] = (float)GetRandomValue(1, 12);
+ positions[i] = (Vector3){ GetRandomValue(-15, 15), heights[i]/2, GetRandomValue(-15, 15) };
+ colors[i] = (Color){ GetRandomValue(20, 255), GetRandomValue(10, 55), 30, 255 };
+ }
+
+ Vector3 playerPosition = { 4, 2, 4 }; // Define player position
+
+ SetCameraMode(CAMERA_FIRST_PERSON); // Set a first person camera mode
+
+ 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
+ //----------------------------------------------------------------------------------
+ UpdateCameraPlayer(&camera, &playerPosition); // Update camera and player position
+ //----------------------------------------------------------------------------------
+
+ // Draw
+ //----------------------------------------------------------------------------------
+ BeginDrawing();
+
+ ClearBackground(RAYWHITE);
+
+ Begin3dMode(camera);
+
+ DrawPlane((Vector3){ 0, 0, 0 }, (Vector2){ 32, 32 }, LIGHTGRAY); // Draw ground
+ DrawCube((Vector3){ -16, 2.5, 0 }, 1, 5, 32, BLUE); // Draw a blue wall
+ DrawCube((Vector3){ 16, 2.5, 0 }, 1, 5, 32, LIME); // Draw a green wall
+ DrawCube((Vector3){ 0, 2.5, 16 }, 32, 5, 1, GOLD); // Draw a yellow wall
+
+ // Draw some cubes around
+ for (int i = 0; i < MAX_COLUMNS; i++)
+ {
+ DrawCube(positions[i], 2, heights[i], 2, colors[i]);
+ DrawCubeWires(positions[i], 2, heights[i], 2, MAROON);
+ }
+
+ End3dMode();
+
+ DrawText("First person camera default controls:", 20, 20, 10, GRAY);
+ DrawText("- Move with keys: W, A, S, D", 40, 50, 10, DARKGRAY);
+ DrawText("- Mouse move to lokk around", 40, 70, 10, DARKGRAY);
+
+ EndDrawing();
+ //----------------------------------------------------------------------------------
+ }
+
+ // De-Initialization
+ //--------------------------------------------------------------------------------------
+ CloseWindow(); // Close window and OpenGL context
+ //--------------------------------------------------------------------------------------
+
+ return 0;
+} \ No newline at end of file
diff --git a/examples/core_3d_camera_first_person.png b/examples/core_3d_camera_first_person.png
new file mode 100644
index 00000000..9373da2d
--- /dev/null
+++ b/examples/core_3d_camera_first_person.png
Binary files differ
diff --git a/examples/core_3d_camera_free.c b/examples/core_3d_camera_free.c
index b54a99c1..cca9cfd5 100644
--- a/examples/core_3d_camera_free.c
+++ b/examples/core_3d_camera_free.c
@@ -37,7 +37,7 @@ int main()
{
// Update
//----------------------------------------------------------------------------------
- camera = UpdateCamera(0); // Update internal camera and our camera
+ UpdateCamera(&camera); // Update internal camera and our camera
//----------------------------------------------------------------------------------
// Draw
diff --git a/examples/core_3d_picking.c b/examples/core_3d_picking.c
index 28503570..13839070 100644
--- a/examples/core_3d_picking.c
+++ b/examples/core_3d_picking.c
@@ -38,7 +38,7 @@ int main()
{
// Update
//----------------------------------------------------------------------------------
- camera = UpdateCamera(0); // Update internal camera and our camera
+ UpdateCamera(&camera); // Update internal camera and our camera
if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON))
{
diff --git a/examples/models_billboard.c b/examples/models_billboard.c
index 511d61ce..05d836ca 100644
--- a/examples/models_billboard.c
+++ b/examples/models_billboard.c
@@ -38,7 +38,7 @@ int main()
{
// Update
//----------------------------------------------------------------------------------
- camera = UpdateCamera(0); // Update internal camera and our camera
+ UpdateCamera(&camera); // Update internal camera and our camera
//----------------------------------------------------------------------------------
// Draw
diff --git a/examples/models_cubicmap.c b/examples/models_cubicmap.c
index 3b20907b..d7fe896c 100644
--- a/examples/models_cubicmap.c
+++ b/examples/models_cubicmap.c
@@ -35,18 +35,18 @@ int main()
UnloadImage(image); // Unload cubesmap image from RAM, already uploaded to VRAM
- SetCameraMode(CAMERA_ORBITAL); // Set an orbital camera mode
- SetCameraPosition(camera.position); // Set internal camera position to match our custom camera position
+ SetCameraMode(CAMERA_ORBITAL); // Set an orbital camera mode
+ SetCameraPosition(camera.position); // Set internal camera position to match our custom camera position
- SetTargetFPS(60); // Set our game to run at 60 frames-per-second
+ SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------
// Main game loop
- while (!WindowShouldClose()) // Detect window close button or ESC key
+ while (!WindowShouldClose()) // Detect window close button or ESC key
{
// Update
//----------------------------------------------------------------------------------
- camera = UpdateCamera(0); // Update internal camera and our camera
+ UpdateCamera(&camera); // Update internal camera and our camera
//----------------------------------------------------------------------------------
// Draw
diff --git a/examples/models_heightmap.c b/examples/models_heightmap.c
index 7de31a8e..fec3f5e6 100644
--- a/examples/models_heightmap.c
+++ b/examples/models_heightmap.c
@@ -29,20 +29,20 @@ int main()
SetModelTexture(&map, texture); // Bind texture to model
Vector3 mapPosition = { -16, 0.0, -16 }; // Set model position (depends on model scaling!)
- UnloadImage(image); // Unload heightmap image from RAM, already uploaded to VRAM
+ UnloadImage(image); // Unload heightmap image from RAM, already uploaded to VRAM
- SetCameraMode(CAMERA_ORBITAL); // Set an orbital camera mode
- SetCameraPosition(camera.position); // Set internal camera position to match our custom camera position
+ SetCameraMode(CAMERA_ORBITAL); // Set an orbital camera mode
+ SetCameraPosition(camera.position); // Set internal camera position to match our custom camera position
- SetTargetFPS(60); // Set our game to run at 60 frames-per-second
+ SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------
// Main game loop
- while (!WindowShouldClose()) // Detect window close button or ESC key
+ while (!WindowShouldClose()) // Detect window close button or ESC key
{
// Update
//----------------------------------------------------------------------------------
- camera = UpdateCamera(0); // Update internal camera and our camera
+ UpdateCamera(&camera); // Update internal camera and our camera
//----------------------------------------------------------------------------------
// Draw
diff --git a/examples/text_font_select.c b/examples/text_font_select.c
index 25825aba..fe586db8 100644
--- a/examples/text_font_select.c
+++ b/examples/text_font_select.c
@@ -2,10 +2,10 @@
*
* raylib [text] example - Font selector
*
-* This example has been created using raylib 1.0 (www.raylib.com)
+* This example has been created using raylib 1.3 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
*
-* Copyright (c) 2014 Ramon Santamaria (@raysan5)
+* Copyright (c) 2015 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
@@ -41,7 +41,7 @@ int main()
const char text[50] = "THIS is THE FONT you SELECTED!"; // Main text
- Vector2 textSize = MeasureTextEx(fonts[currentFont], text, GetFontBaseSize(fonts[currentFont])*3, 1);
+ Vector2 textSize = MeasureTextEx(fonts[currentFont], text, fonts[currentFont].size*3, 1);
Vector2 mousePoint;
@@ -118,7 +118,7 @@ int main()
}
// Text measurement for better positioning on screen
- textSize = MeasureTextEx(fonts[currentFont], text, GetFontBaseSize(fonts[currentFont])*3, 1);
+ textSize = MeasureTextEx(fonts[currentFont], text, fonts[currentFont].size*3, 1);
//----------------------------------------------------------------------------------
// Draw
@@ -140,7 +140,7 @@ int main()
DrawText("NEXT", 700, positionY + 13, 20, btnNextOutColor);
DrawTextEx(fonts[currentFont], text, (Vector2){ screenWidth/2 - textSize.x/2,
- 260 + (70 - textSize.y)/2 }, GetFontBaseSize(fonts[currentFont])*3,
+ 260 + (70 - textSize.y)/2 }, fonts[currentFont].size*3,
1, colors[currentFont]);
EndDrawing();
diff --git a/examples/text_rbmf_fonts.c b/examples/text_rbmf_fonts.c
index 74e3da6b..b4bd851b 100644
--- a/examples/text_rbmf_fonts.c
+++ b/examples/text_rbmf_fonts.c
@@ -5,10 +5,10 @@
* NOTE: raylib is distributed with some free to use fonts (even for commercial pourposes!)
* To view details and credits for those fonts, check raylib license file
*
-* This example has been created using raylib 1.0 (www.raylib.com)
+* This example has been created using raylib 1.3 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
*
-* Copyright (c) 2014 Ramon Santamaria (@raysan5)
+* Copyright (c) 2015 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
@@ -50,8 +50,8 @@ int main()
for (int i = 0; i < 8; i++)
{
- positions[i].x = screenWidth/2 - MeasureTextEx(fonts[i], messages[i], GetFontBaseSize(fonts[i])*2, spacings[i]).x/2;
- positions[i].y = 60 + GetFontBaseSize(fonts[i]) + 50*i;
+ positions[i].x = screenWidth/2 - MeasureTextEx(fonts[i], messages[i], fonts[i].size*2, spacings[i]).x/2;
+ positions[i].y = 60 + fonts[i].size + 50*i;
}
Color colors[8] = { MAROON, ORANGE, DARKGREEN, DARKBLUE, DARKPURPLE, LIME, GOLD };
@@ -76,7 +76,7 @@ int main()
for (int i = 0; i < 8; i++)
{
- DrawTextEx(fonts[i], messages[i], positions[i], GetFontBaseSize(fonts[i])*2, spacings[i], colors[i]);
+ DrawTextEx(fonts[i], messages[i], positions[i], fonts[i].size*2, spacings[i], colors[i]);
}
EndDrawing();
diff --git a/examples/text_sprite_fonts.c b/examples/text_sprite_fonts.c
index 423fa250..c73eda85 100644
--- a/examples/text_sprite_fonts.c
+++ b/examples/text_sprite_fonts.c
@@ -31,14 +31,14 @@ int main()
Vector2 fontPosition1, fontPosition2, fontPosition3;
- fontPosition1.x = screenWidth/2 - MeasureTextEx(font1, msg1, GetFontBaseSize(font1), -3).x/2;
- fontPosition1.y = screenHeight/2 - GetFontBaseSize(font1)/2 - 80;
+ fontPosition1.x = screenWidth/2 - MeasureTextEx(font1, msg1, font1.size, -3).x/2;
+ fontPosition1.y = screenHeight/2 - font1.size/2 - 80;
- fontPosition2.x = screenWidth/2 - MeasureTextEx(font2, msg2, GetFontBaseSize(font2), -2).x/2;
- fontPosition2.y = screenHeight/2 - GetFontBaseSize(font2)/2 - 10;
+ fontPosition2.x = screenWidth/2 - MeasureTextEx(font2, msg2, font2.size, -2).x/2;
+ fontPosition2.y = screenHeight/2 - font2.size/2 - 10;
- fontPosition3.x = screenWidth/2 - MeasureTextEx(font3, msg3, GetFontBaseSize(font3), 2).x/2;
- fontPosition3.y = screenHeight/2 - GetFontBaseSize(font3)/2 + 50;
+ fontPosition3.x = screenWidth/2 - MeasureTextEx(font3, msg3, font3.size, 2).x/2;
+ fontPosition3.y = screenHeight/2 - font3.size/2 + 50;
//--------------------------------------------------------------------------------------
@@ -56,9 +56,9 @@ int main()
ClearBackground(RAYWHITE);
- DrawTextEx(font1, msg1, fontPosition1, GetFontBaseSize(font1), -3, WHITE);
- DrawTextEx(font2, msg2, fontPosition2, GetFontBaseSize(font2), -2, WHITE);
- DrawTextEx(font3, msg3, fontPosition3, GetFontBaseSize(font3), 2, WHITE);
+ DrawTextEx(font1, msg1, fontPosition1, font1.size, -3, WHITE);
+ DrawTextEx(font2, msg2, fontPosition2, font2.size, -2, WHITE);
+ DrawTextEx(font3, msg3, fontPosition3, font3.size, 2, WHITE);
EndDrawing();
//----------------------------------------------------------------------------------