2
0
mirror of https://github.com/raylib-cs/raylib-cs synced 2025-06-30 19:03:42 -04:00

Update enum/color names to match C# naming convention (#224)

This commit is contained in:
Danil
2024-01-18 21:00:57 +02:00
committed by GitHub
parent 2a1889403d
commit 70d86837d4
123 changed files with 1843 additions and 1847 deletions

View File

@ -78,7 +78,7 @@ public class BasicScreenManager
// TODO: Update TITLE screen variables here!
// Press enter to change to GAMEPLAY screen
if (IsKeyPressed(KeyboardKey.KEY_ENTER) || IsGestureDetected(Gesture.GESTURE_TAP))
if (IsKeyPressed(KeyboardKey.Enter) || IsGestureDetected(Gesture.Tap))
{
currentScreen = GameScreen.Gameplay;
}
@ -89,7 +89,7 @@ public class BasicScreenManager
// TODO: Update GAMEPLAY screen variables here!
// Press enter to change to ENDING screen
if (IsKeyPressed(KeyboardKey.KEY_ENTER) || IsGestureDetected(Gesture.GESTURE_TAP))
if (IsKeyPressed(KeyboardKey.Enter) || IsGestureDetected(Gesture.Tap))
{
currentScreen = GameScreen.Ending;
}
@ -100,7 +100,7 @@ public class BasicScreenManager
// TODO: Update ENDING screen variables here!
// Press enter to return to TITLE screen
if (IsKeyPressed(KeyboardKey.KEY_ENTER) || IsGestureDetected(Gesture.GESTURE_TAP))
if (IsKeyPressed(KeyboardKey.Enter) || IsGestureDetected(Gesture.Tap))
{
currentScreen = GameScreen.Title;
}
@ -115,42 +115,42 @@ public class BasicScreenManager
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
switch (currentScreen)
{
case GameScreen.Logo:
{
// TODO: Draw LOGO screen here!
DrawText("LOGO SCREEN", 20, 20, 40, Color.LIGHTGRAY);
DrawText("WAIT for 2 SECONDS...", 290, 220, 20, Color.GRAY);
DrawText("LOGO SCREEN", 20, 20, 40, Color.LightGray);
DrawText("WAIT for 2 SECONDS...", 290, 220, 20, Color.Gray);
}
break;
case GameScreen.Title:
{
// TODO: Draw TITLE screen here!
DrawRectangle(0, 0, screenWidth, screenHeight, Color.GREEN);
DrawText("TITLE SCREEN", 20, 20, 40, Color.DARKGREEN);
DrawText("PRESS ENTER or TAP to JUMP to GAMEPLAY SCREEN", 120, 220, 20, Color.DARKGREEN);
DrawRectangle(0, 0, screenWidth, screenHeight, Color.Green);
DrawText("TITLE SCREEN", 20, 20, 40, Color.DarkGreen);
DrawText("PRESS ENTER or TAP to JUMP to GAMEPLAY SCREEN", 120, 220, 20, Color.DarkGreen);
}
break;
case GameScreen.Gameplay:
{
// TODO: Draw GAMEPLAY screen here!
DrawRectangle(0, 0, screenWidth, screenHeight, Color.PURPLE);
DrawText("GAMEPLAY SCREEN", 20, 20, 40, Color.MAROON);
DrawText("PRESS ENTER or TAP to JUMP to ENDING SCREEN", 130, 220, 20, Color.MAROON);
DrawRectangle(0, 0, screenWidth, screenHeight, Color.Purple);
DrawText("GAMEPLAY SCREEN", 20, 20, 40, Color.Maroon);
DrawText("PRESS ENTER or TAP to JUMP to ENDING SCREEN", 130, 220, 20, Color.Maroon);
}
break;
case GameScreen.Ending:
{
// TODO: Draw ENDING screen here!
DrawRectangle(0, 0, screenWidth, screenHeight, Color.BLUE);
DrawText("ENDING SCREEN", 20, 20, 40, Color.DARKBLUE);
DrawText("PRESS ENTER or TAP to RETURN to TITLE SCREEN", 120, 220, 20, Color.DARKBLUE);
DrawRectangle(0, 0, screenWidth, screenHeight, Color.Blue);
DrawText("ENDING SCREEN", 20, 20, 40, Color.DarkBlue);
DrawText("PRESS ENTER or TAP to RETURN to TITLE SCREEN", 120, 220, 20, Color.DarkBlue);
}
break;

View File

@ -51,9 +51,9 @@ public class BasicWindow
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
DrawText("Congrats! You created your first window!", 190, 200, 20, Color.MAROON);
DrawText("Congrats! You created your first window!", 190, 200, 20, Color.Maroon);
EndDrawing();
//----------------------------------------------------------------------------------

View File

@ -66,11 +66,11 @@ public class Camera2dDemo
//----------------------------------------------------------------------------------
// Player movement
if (IsKeyDown(KeyboardKey.KEY_RIGHT))
if (IsKeyDown(KeyboardKey.Right))
{
player.X += 2;
}
else if (IsKeyDown(KeyboardKey.KEY_LEFT))
else if (IsKeyDown(KeyboardKey.Left))
{
player.X -= 2;
}
@ -79,11 +79,11 @@ public class Camera2dDemo
camera.Target = new Vector2(player.X + 20, player.Y + 20);
// Camera3D rotation controls
if (IsKeyDown(KeyboardKey.KEY_A))
if (IsKeyDown(KeyboardKey.A))
{
camera.Rotation--;
}
else if (IsKeyDown(KeyboardKey.KEY_S))
else if (IsKeyDown(KeyboardKey.S))
{
camera.Rotation++;
}
@ -111,7 +111,7 @@ public class Camera2dDemo
}
// Camera3D reset (zoom and rotation)
if (IsKeyPressed(KeyboardKey.KEY_R))
if (IsKeyPressed(KeyboardKey.R))
{
camera.Zoom = 1.0f;
camera.Rotation = 0.0f;
@ -121,45 +121,45 @@ public class Camera2dDemo
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
BeginMode2D(camera);
DrawRectangle(-6000, 320, 13000, 8000, Color.DARKGRAY);
DrawRectangle(-6000, 320, 13000, 8000, Color.DarkGray);
for (int i = 0; i < MaxBuildings; i++)
{
DrawRectangleRec(buildings[i], buildColors[i]);
}
DrawRectangleRec(player, Color.RED);
DrawRectangleRec(player, Color.Red);
DrawRectangle((int)camera.Target.X, -500, 1, (int)(screenHeight * 4), Color.GREEN);
DrawRectangle((int)camera.Target.X, -500, 1, (int)(screenHeight * 4), Color.Green);
DrawLine(
(int)(-screenWidth * 10),
(int)camera.Target.Y,
(int)(screenWidth * 10),
(int)camera.Target.Y,
Color.GREEN
Color.Green
);
EndMode2D();
DrawText("SCREEN AREA", 640, 10, 20, Color.RED);
DrawText("SCREEN AREA", 640, 10, 20, Color.Red);
DrawRectangle(0, 0, (int)screenWidth, 5, Color.RED);
DrawRectangle(0, 5, 5, (int)screenHeight - 10, Color.RED);
DrawRectangle((int)screenWidth - 5, 5, 5, (int)screenHeight - 10, Color.RED);
DrawRectangle(0, (int)screenHeight - 5, (int)screenWidth, 5, Color.RED);
DrawRectangle(0, 0, (int)screenWidth, 5, Color.Red);
DrawRectangle(0, 5, 5, (int)screenHeight - 10, Color.Red);
DrawRectangle((int)screenWidth - 5, 5, 5, (int)screenHeight - 10, Color.Red);
DrawRectangle(0, (int)screenHeight - 5, (int)screenWidth, 5, Color.Red);
DrawRectangle(10, 10, 250, 113, ColorAlpha(Color.SKYBLUE, 0.5f));
DrawRectangleLines(10, 10, 250, 113, Color.BLUE);
DrawRectangle(10, 10, 250, 113, ColorAlpha(Color.SkyBlue, 0.5f));
DrawRectangleLines(10, 10, 250, 113, Color.Blue);
DrawText("Free 2d camera controls:", 20, 20, 10, Color.BLACK);
DrawText("- Right/Left to move Offset", 40, 40, 10, Color.DARKGRAY);
DrawText("- Mouse Wheel to Zoom in-out", 40, 60, 10, Color.DARKGRAY);
DrawText("- A / S to Rotate", 40, 80, 10, Color.DARKGRAY);
DrawText("- R to reset Zoom and Rotation", 40, 100, 10, Color.DARKGRAY);
DrawText("Free 2d camera controls:", 20, 20, 10, Color.Black);
DrawText("- Right/Left to move Offset", 40, 40, 10, Color.DarkGray);
DrawText("- Mouse Wheel to Zoom in-out", 40, 60, 10, Color.DarkGray);
DrawText("- A / S to Rotate", 40, 80, 10, Color.DarkGray);
DrawText("- R to reset Zoom and Rotation", 40, 100, 10, Color.DarkGray);
EndDrawing();
//----------------------------------------------------------------------------------

View File

@ -70,11 +70,11 @@ public class Camera2dPlatformer
EnvItem[] envItems = new EnvItem[]
{
new EnvItem(new Rectangle(0, 0, 1000, 400), 0, Color.LIGHTGRAY),
new EnvItem(new Rectangle(0, 400, 1000, 200), 1, Color.GRAY),
new EnvItem(new Rectangle(300, 200, 400, 10), 1, Color.GRAY),
new EnvItem(new Rectangle(250, 300, 100, 10), 1, Color.GRAY),
new EnvItem(new Rectangle(650, 300, 100, 10), 1, Color.GRAY)
new EnvItem(new Rectangle(0, 0, 1000, 400), 0, Color.LightGray),
new EnvItem(new Rectangle(0, 400, 1000, 200), 1, Color.Gray),
new EnvItem(new Rectangle(300, 200, 400, 10), 1, Color.Gray),
new EnvItem(new Rectangle(250, 300, 100, 10), 1, Color.Gray),
new EnvItem(new Rectangle(650, 300, 100, 10), 1, Color.Gray)
};
Camera2D camera = new();
@ -127,13 +127,13 @@ public class Camera2dPlatformer
camera.Zoom = 0.25f;
}
if (IsKeyPressed(KeyboardKey.KEY_R))
if (IsKeyPressed(KeyboardKey.R))
{
camera.Zoom = 1.0f;
player.Position = new Vector2(400, 280);
}
if (IsKeyPressed(KeyboardKey.KEY_C))
if (IsKeyPressed(KeyboardKey.C))
{
cameraOption = (cameraOption + 1) % cameraUpdatersLength;
}
@ -145,7 +145,7 @@ public class Camera2dPlatformer
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.LIGHTGRAY);
ClearBackground(Color.LightGray);
BeginMode2D(camera);
@ -155,17 +155,17 @@ public class Camera2dPlatformer
}
Rectangle playerRect = new(player.Position.X - 20, player.Position.Y - 40, 40, 40);
DrawRectangleRec(playerRect, Color.RED);
DrawRectangleRec(playerRect, Color.Red);
EndMode2D();
DrawText("Controls:", 20, 20, 10, Color.BLACK);
DrawText("- Right/Left to move", 40, 40, 10, Color.DARKGRAY);
DrawText("- Space to jump", 40, 60, 10, Color.DARKGRAY);
DrawText("- Mouse Wheel to Zoom in-out, R to reset zoom", 40, 80, 10, Color.DARKGRAY);
DrawText("- C to change camera mode", 40, 100, 10, Color.DARKGRAY);
DrawText("Current camera mode:", 20, 120, 10, Color.BLACK);
DrawText(cameraDescriptions[cameraOption], 40, 140, 10, Color.DARKGRAY);
DrawText("Controls:", 20, 20, 10, Color.Black);
DrawText("- Right/Left to move", 40, 40, 10, Color.DarkGray);
DrawText("- Space to jump", 40, 60, 10, Color.DarkGray);
DrawText("- Mouse Wheel to Zoom in-out, R to reset zoom", 40, 80, 10, Color.DarkGray);
DrawText("- C to change camera mode", 40, 100, 10, Color.DarkGray);
DrawText("Current camera mode:", 20, 120, 10, Color.Black);
DrawText(cameraDescriptions[cameraOption], 40, 140, 10, Color.DarkGray);
EndDrawing();
//----------------------------------------------------------------------------------
@ -181,17 +181,17 @@ public class Camera2dPlatformer
static void UpdatePlayer(ref Player player, EnvItem[] envItems, float delta)
{
if (IsKeyDown(KeyboardKey.KEY_LEFT))
if (IsKeyDown(KeyboardKey.Left))
{
player.Position.X -= PlayerHorSpeed * delta;
}
if (IsKeyDown(KeyboardKey.KEY_RIGHT))
if (IsKeyDown(KeyboardKey.Right))
{
player.Position.X += PlayerHorSpeed * delta;
}
if (IsKeyDown(KeyboardKey.KEY_SPACE) && player.CanJump)
if (IsKeyDown(KeyboardKey.Space) && player.CanJump)
{
player.Speed = -PlayerJumpSpeed;
player.CanJump = false;

View File

@ -33,7 +33,7 @@ public class Camera3dFirstPerson
camera.Target = new Vector3(0.0f, 1.8f, 0.0f);
camera.Up = new Vector3(0.0f, 1.0f, 0.0f);
camera.FovY = 60.0f;
camera.Projection = CameraProjection.CAMERA_PERSPECTIVE;
camera.Projection = CameraProjection.Perspective;
// Generates some random columns
float[] heights = new float[MaxColumns];
@ -47,7 +47,7 @@ public class Camera3dFirstPerson
colors[i] = new Color(GetRandomValue(20, 255), GetRandomValue(10, 55), 30, 255);
}
CameraMode cameraMode = CameraMode.CAMERA_FIRST_PERSON;
CameraMode cameraMode = CameraMode.FirstPerson;
SetTargetFPS(60);
//--------------------------------------------------------------------------------------
@ -58,54 +58,54 @@ public class Camera3dFirstPerson
// Update
//----------------------------------------------------------------------------------
// Switch camera mode
if (IsKeyPressed(KeyboardKey.KEY_ONE))
if (IsKeyPressed(KeyboardKey.One))
{
cameraMode = CameraMode.CAMERA_FREE;
cameraMode = CameraMode.Free;
camera.Up = new Vector3(0.0f, 1.0f, 0.0f);
}
if (IsKeyPressed(KeyboardKey.KEY_TWO))
if (IsKeyPressed(KeyboardKey.Two))
{
cameraMode = CameraMode.CAMERA_FIRST_PERSON;
cameraMode = CameraMode.FirstPerson;
camera.Up = new Vector3(0.0f, 1.0f, 0.0f);
}
if (IsKeyPressed(KeyboardKey.KEY_THREE))
if (IsKeyPressed(KeyboardKey.Three))
{
cameraMode = CameraMode.CAMERA_THIRD_PERSON;
cameraMode = CameraMode.ThirdPerson;
camera.Up = new Vector3(0.0f, 1.0f, 0.0f);
}
if (IsKeyPressed(KeyboardKey.KEY_FOUR))
if (IsKeyPressed(KeyboardKey.Four))
{
cameraMode = CameraMode.CAMERA_ORBITAL;
cameraMode = CameraMode.Orbital;
camera.Up = new Vector3(0.0f, 1.0f, 0.0f);
}
// Switch camera projection
if (IsKeyPressed(KeyboardKey.KEY_P))
if (IsKeyPressed(KeyboardKey.P))
{
if (camera.Projection == CameraProjection.CAMERA_PERSPECTIVE)
if (camera.Projection == CameraProjection.Perspective)
{
// Create isometric view
cameraMode = CameraMode.CAMERA_THIRD_PERSON;
cameraMode = CameraMode.ThirdPerson;
// Note: The target distance is related to the render distance in the orthographic projection
camera.Position = new Vector3(0.0f, 2.0f, -100.0f);
camera.Target = new Vector3(0.0f, 2.0f, 0.0f);
camera.Up = new Vector3(0.0f, 1.0f, 0.0f);
camera.Projection = CameraProjection.CAMERA_ORTHOGRAPHIC;
camera.Projection = CameraProjection.Orthographic;
camera.FovY = 20.0f; // near plane width in CAMERA_ORTHOGRAPHIC
// CameraYaw(&camera, -135 * DEG2RAD, true);
// CameraPitch(&camera, -45 * DEG2RAD, true, true, false);
}
else if (camera.Projection == CameraProjection.CAMERA_ORTHOGRAPHIC)
else if (camera.Projection == CameraProjection.Orthographic)
{
// Reset to default view
cameraMode = CameraMode.CAMERA_THIRD_PERSON;
cameraMode = CameraMode.ThirdPerson;
camera.Position = new Vector3(0.0f, 2.0f, 10.0f);
camera.Target = new Vector3(0.0f, 2.0f, 0.0f);
camera.Up = new Vector3(0.0f, 1.0f, 0.0f);
camera.Projection = CameraProjection.CAMERA_PERSPECTIVE;
camera.Projection = CameraProjection.Perspective;
camera.FovY = 60.0f;
}
}
@ -113,64 +113,64 @@ public class Camera3dFirstPerson
// Update camera computes movement internally depending on the camera mode
// Some default standard keyboard/mouse inputs are hardcoded to simplify use
// For advance camera controls, it's reecommended to compute camera movement manually
UpdateCamera(ref camera, CameraMode.CAMERA_CUSTOM);
UpdateCamera(ref camera, CameraMode.Custom);
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
BeginMode3D(camera);
// Draw ground
DrawPlane(new Vector3(0.0f, 0.0f, 0.0f), new Vector2(32.0f, 32.0f), Color.LIGHTGRAY);
DrawPlane(new Vector3(0.0f, 0.0f, 0.0f), new Vector2(32.0f, 32.0f), Color.LightGray);
// Draw a blue wall
DrawCube(new Vector3(-16.0f, 2.5f, 0.0f), 1.0f, 5.0f, 32.0f, Color.BLUE);
DrawCube(new Vector3(-16.0f, 2.5f, 0.0f), 1.0f, 5.0f, 32.0f, Color.Blue);
// Draw a green wall
DrawCube(new Vector3(16.0f, 2.5f, 0.0f), 1.0f, 5.0f, 32.0f, Color.LIME);
DrawCube(new Vector3(16.0f, 2.5f, 0.0f), 1.0f, 5.0f, 32.0f, Color.Lime);
// Draw a yellow wall
DrawCube(new Vector3(0.0f, 2.5f, 16.0f), 32.0f, 5.0f, 1.0f, Color.GOLD);
DrawCube(new Vector3(0.0f, 2.5f, 16.0f), 32.0f, 5.0f, 1.0f, Color.Gold);
// Draw some cubes around
for (int i = 0; i < MaxColumns; i++)
{
DrawCube(positions[i], 2.0f, heights[i], 2.0f, colors[i]);
DrawCubeWires(positions[i], 2.0f, heights[i], 2.0f, Color.MAROON);
DrawCubeWires(positions[i], 2.0f, heights[i], 2.0f, Color.Maroon);
}
// Draw player cube
if (cameraMode == CameraMode.CAMERA_THIRD_PERSON)
if (cameraMode == CameraMode.ThirdPerson)
{
DrawCube(camera.Target, 0.5f, 0.5f, 0.5f, Color.PURPLE);
DrawCubeWires(camera.Target, 0.5f, 0.5f, 0.5f, Color.DARKPURPLE);
DrawCube(camera.Target, 0.5f, 0.5f, 0.5f, Color.Purple);
DrawCubeWires(camera.Target, 0.5f, 0.5f, 0.5f, Color.DarkPurple);
}
EndMode3D();
// Draw info boxes
DrawRectangle(5, 5, 330, 100, ColorAlpha(Color.SKYBLUE, 0.5f));
DrawRectangleLines(10, 10, 330, 100, Color.BLUE);
DrawRectangle(5, 5, 330, 100, ColorAlpha(Color.SkyBlue, 0.5f));
DrawRectangleLines(10, 10, 330, 100, Color.Blue);
DrawText("Camera controls:", 15, 15, 10, Color.BLACK);
DrawText("- Move keys: W, A, S, D, Space, Left-Ctrl", 15, 30, 10, Color.BLACK);
DrawText("- Look around: arrow keys or mouse", 15, 45, 10, Color.BLACK);
DrawText("- Camera mode keys: 1, 2, 3, 4", 15, 60, 10, Color.BLACK);
DrawText("- Zoom keys: num-plus, num-minus or mouse scroll", 15, 75, 10, Color.BLACK);
DrawText("- Camera projection key: P", 15, 90, 10, Color.BLACK);
DrawText("Camera controls:", 15, 15, 10, Color.Black);
DrawText("- Move keys: W, A, S, D, Space, Left-Ctrl", 15, 30, 10, Color.Black);
DrawText("- Look around: arrow keys or mouse", 15, 45, 10, Color.Black);
DrawText("- Camera mode keys: 1, 2, 3, 4", 15, 60, 10, Color.Black);
DrawText("- Zoom keys: num-plus, num-minus or mouse scroll", 15, 75, 10, Color.Black);
DrawText("- Camera projection key: P", 15, 90, 10, Color.Black);
DrawRectangle(600, 5, 195, 100, Fade(Color.SKYBLUE, 0.5f));
DrawRectangleLines(600, 5, 195, 100, Color.BLUE);
DrawRectangle(600, 5, 195, 100, Fade(Color.SkyBlue, 0.5f));
DrawRectangleLines(600, 5, 195, 100, Color.Blue);
DrawText("Camera status:", 610, 15, 10, Color.BLACK);
DrawText($"- Mode: {cameraMode}", 610, 30, 10, Color.BLACK);
DrawText($"- Projection: {camera.Projection}", 610, 45, 10, Color.BLACK);
DrawText($"- Position: {camera.Position}", 610, 60, 10, Color.BLACK);
DrawText($"- Target: {camera.Target}", 610, 75, 10, Color.BLACK);
DrawText($"- Up: {camera.Up}", 610, 90, 10, Color.BLACK);
DrawText("Camera status:", 610, 15, 10, Color.Black);
DrawText($"- Mode: {cameraMode}", 610, 30, 10, Color.Black);
DrawText($"- Projection: {camera.Projection}", 610, 45, 10, Color.Black);
DrawText($"- Position: {camera.Position}", 610, 60, 10, Color.Black);
DrawText($"- Target: {camera.Target}", 610, 75, 10, Color.Black);
DrawText($"- Up: {camera.Up}", 610, 90, 10, Color.Black);
EndDrawing();
//----------------------------------------------------------------------------------

View File

@ -31,7 +31,7 @@ public class Camera3dFree
camera.Target = new Vector3(0.0f, 0.0f, 0.0f);
camera.Up = new Vector3(0.0f, 1.0f, 0.0f);
camera.FovY = 45.0f;
camera.Projection = CameraProjection.CAMERA_PERSPECTIVE;
camera.Projection = CameraProjection.Perspective;
Vector3 cubePosition = new(0.0f, 0.0f, 0.0f);
@ -43,9 +43,9 @@ public class Camera3dFree
{
// Update
//----------------------------------------------------------------------------------
UpdateCamera(ref camera, CameraMode.CAMERA_FREE);
UpdateCamera(ref camera, CameraMode.Free);
if (IsKeyDown(KeyboardKey.KEY_Z))
if (IsKeyDown(KeyboardKey.Z))
{
camera.Target = new Vector3(0.0f, 0.0f, 0.0f);
}
@ -54,26 +54,26 @@ public class Camera3dFree
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
BeginMode3D(camera);
DrawCube(cubePosition, 2.0f, 2.0f, 2.0f, Color.RED);
DrawCubeWires(cubePosition, 2.0f, 2.0f, 2.0f, Color.MAROON);
DrawCube(cubePosition, 2.0f, 2.0f, 2.0f, Color.Red);
DrawCubeWires(cubePosition, 2.0f, 2.0f, 2.0f, Color.Maroon);
DrawGrid(10, 1.0f);
EndMode3D();
DrawRectangle(10, 10, 320, 133, ColorAlpha(Color.SKYBLUE, 0.5f));
DrawRectangleLines(10, 10, 320, 133, Color.BLUE);
DrawRectangle(10, 10, 320, 133, ColorAlpha(Color.SkyBlue, 0.5f));
DrawRectangleLines(10, 10, 320, 133, Color.Blue);
DrawText("Free camera default controls:", 20, 20, 10, Color.BLACK);
DrawText("- Mouse Wheel to Zoom in-out", 40, 40, 10, Color.DARKGRAY);
DrawText("- Mouse Wheel Pressed to Pan", 40, 60, 10, Color.DARKGRAY);
DrawText("- Alt + Mouse Wheel Pressed to Rotate", 40, 80, 10, Color.DARKGRAY);
DrawText("- Alt + Ctrl + Mouse Wheel Pressed for Smooth Zoom", 40, 100, 10, Color.DARKGRAY);
DrawText("- Z to zoom to (0, 0, 0)", 40, 120, 10, Color.DARKGRAY);
DrawText("Free camera default controls:", 20, 20, 10, Color.Black);
DrawText("- Mouse Wheel to Zoom in-out", 40, 40, 10, Color.DarkGray);
DrawText("- Mouse Wheel Pressed to Pan", 40, 60, 10, Color.DarkGray);
DrawText("- Alt + Mouse Wheel Pressed to Rotate", 40, 80, 10, Color.DarkGray);
DrawText("- Alt + Ctrl + Mouse Wheel Pressed for Smooth Zoom", 40, 100, 10, Color.DarkGray);
DrawText("- Z to zoom to (0, 0, 0)", 40, 120, 10, Color.DarkGray);
EndDrawing();
//----------------------------------------------------------------------------------

View File

@ -31,7 +31,7 @@ public class Camera3dMode
camera.Target = new Vector3(0.0f, 0.0f, 0.0f);
camera.Up = new Vector3(0.0f, 1.0f, 0.0f);
camera.FovY = 45.0f;
camera.Projection = CameraProjection.CAMERA_PERSPECTIVE;
camera.Projection = CameraProjection.Perspective;
Vector3 cubePosition = new(0.0f, 0.0f, 0.0f);
@ -49,18 +49,18 @@ public class Camera3dMode
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
BeginMode3D(camera);
DrawCube(cubePosition, 2.0f, 2.0f, 2.0f, Color.RED);
DrawCubeWires(cubePosition, 2.0f, 2.0f, 2.0f, Color.MAROON);
DrawCube(cubePosition, 2.0f, 2.0f, 2.0f, Color.Red);
DrawCubeWires(cubePosition, 2.0f, 2.0f, 2.0f, Color.Maroon);
DrawGrid(10, 1.0f);
EndMode3D();
DrawText("Welcome to the third dimension!", 10, 40, 20, Color.DARKGRAY);
DrawText("Welcome to the third dimension!", 10, 40, 20, Color.DarkGray);
DrawFPS(10, 10);

View File

@ -68,9 +68,9 @@ public unsafe class CustomLogging
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
DrawText("Check out the console output to see the custom logger in action!", 60, 200, 20, Color.LIGHTGRAY);
DrawText("Check out the console output to see the custom logger in action!", 60, 200, 20, Color.LightGray);
EndDrawing();
//----------------------------------------------------------------------------------

View File

@ -45,30 +45,30 @@ public class DropFiles
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
if (files.Length == 0)
{
DrawText("Drop your files to this window!", 100, 40, 20, Color.DARKGRAY);
DrawText("Drop your files to this window!", 100, 40, 20, Color.DarkGray);
}
else
{
DrawText("Dropped files:", 100, 40, 20, Color.DARKGRAY);
DrawText("Dropped files:", 100, 40, 20, Color.DarkGray);
for (int i = 0; i < files.Length; i++)
{
if (i % 2 == 0)
{
DrawRectangle(0, 85 + 40 * i, screenWidth, 40, ColorAlpha(Color.LIGHTGRAY, 0.5f));
DrawRectangle(0, 85 + 40 * i, screenWidth, 40, ColorAlpha(Color.LightGray, 0.5f));
}
else
{
DrawRectangle(0, 85 + 40 * i, screenWidth, 40, ColorAlpha(Color.LIGHTGRAY, 0.3f));
DrawRectangle(0, 85 + 40 * i, screenWidth, 40, ColorAlpha(Color.LightGray, 0.3f));
}
DrawText(files[i], 120, 100 + 40 * i, 10, Color.GRAY);
DrawText(files[i], 120, 100 + 40 * i, 10, Color.Gray);
}
DrawText("Drop new files...", 100, 110 + 40 * files.Length, 20, Color.DARKGRAY);
DrawText("Drop new files...", 100, 110 + 40 * files.Length, 20, Color.DarkGray);
}
EndDrawing();

View File

@ -38,7 +38,7 @@ public class InputGamepad
const int screenHeight = 450;
// Set MSAA 4X hint before windows creation
SetConfigFlags(ConfigFlags.FLAG_MSAA_4X_HINT);
SetConfigFlags(ConfigFlags.Msaa4xHint);
InitWindow(screenWidth, screenHeight, "raylib [core] example - gamepad input");
Texture2D texPs3Pad = LoadTexture("resources/ps3.png");
@ -58,232 +58,232 @@ public class InputGamepad
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
if (IsGamepadAvailable(0))
{
string gamepadName = GetGamepadName_(0);
DrawText($"GP1: {gamepadName}", 10, 10, 10, Color.BLACK);
DrawText($"GP1: {gamepadName}", 10, 10, 10, Color.Black);
if (gamepadName == XBOX360_LEGACY_NAME_ID ||
gamepadName == XBOX360_NAME_ID ||
gamepadName == XBOX360_NAME_ID_RPI)
{
DrawTexture(texXboxPad, 0, 0, Color.DARKGRAY);
DrawTexture(texXboxPad, 0, 0, Color.DarkGray);
// Draw buttons: xbox home
if (IsGamepadButtonDown(0, GamepadButton.GAMEPAD_BUTTON_MIDDLE))
if (IsGamepadButtonDown(0, GamepadButton.Middle))
{
DrawCircle(394, 89, 19, Color.RED);
DrawCircle(394, 89, 19, Color.Red);
}
// Draw buttons: basic
if (IsGamepadButtonDown(0, GamepadButton.GAMEPAD_BUTTON_MIDDLE_RIGHT))
if (IsGamepadButtonDown(0, GamepadButton.MiddleRight))
{
DrawCircle(436, 150, 9, Color.RED);
DrawCircle(436, 150, 9, Color.Red);
}
if (IsGamepadButtonDown(0, GamepadButton.GAMEPAD_BUTTON_MIDDLE_LEFT))
if (IsGamepadButtonDown(0, GamepadButton.MiddleLeft))
{
DrawCircle(352, 150, 9, Color.RED);
DrawCircle(352, 150, 9, Color.Red);
}
if (IsGamepadButtonDown(0, GamepadButton.GAMEPAD_BUTTON_RIGHT_FACE_LEFT))
if (IsGamepadButtonDown(0, GamepadButton.RightFaceLeft))
{
DrawCircle(501, 151, 15, Color.BLUE);
DrawCircle(501, 151, 15, Color.Blue);
}
if (IsGamepadButtonDown(0, GamepadButton.GAMEPAD_BUTTON_RIGHT_FACE_DOWN))
if (IsGamepadButtonDown(0, GamepadButton.RightFaceDown))
{
DrawCircle(536, 187, 15, Color.LIME);
DrawCircle(536, 187, 15, Color.Lime);
}
if (IsGamepadButtonDown(0, GamepadButton.GAMEPAD_BUTTON_RIGHT_FACE_RIGHT))
if (IsGamepadButtonDown(0, GamepadButton.RightFaceRight))
{
DrawCircle(572, 151, 15, Color.MAROON);
DrawCircle(572, 151, 15, Color.Maroon);
}
if (IsGamepadButtonDown(0, GamepadButton.GAMEPAD_BUTTON_RIGHT_FACE_UP))
if (IsGamepadButtonDown(0, GamepadButton.RightFaceUp))
{
DrawCircle(536, 115, 15, Color.GOLD);
DrawCircle(536, 115, 15, Color.Gold);
}
// Draw buttons: d-pad
DrawRectangle(317, 202, 19, 71, Color.BLACK);
DrawRectangle(293, 228, 69, 19, Color.BLACK);
if (IsGamepadButtonDown(0, GamepadButton.GAMEPAD_BUTTON_LEFT_FACE_UP))
DrawRectangle(317, 202, 19, 71, Color.Black);
DrawRectangle(293, 228, 69, 19, Color.Black);
if (IsGamepadButtonDown(0, GamepadButton.LeftFaceUp))
{
DrawRectangle(317, 202, 19, 26, Color.RED);
DrawRectangle(317, 202, 19, 26, Color.Red);
}
if (IsGamepadButtonDown(0, GamepadButton.GAMEPAD_BUTTON_LEFT_FACE_DOWN))
if (IsGamepadButtonDown(0, GamepadButton.LeftFaceDown))
{
DrawRectangle(317, 202 + 45, 19, 26, Color.RED);
DrawRectangle(317, 202 + 45, 19, 26, Color.Red);
}
if (IsGamepadButtonDown(0, GamepadButton.GAMEPAD_BUTTON_LEFT_FACE_LEFT))
if (IsGamepadButtonDown(0, GamepadButton.LeftFaceLeft))
{
DrawRectangle(292, 228, 25, 19, Color.RED);
DrawRectangle(292, 228, 25, 19, Color.Red);
}
if (IsGamepadButtonDown(0, GamepadButton.GAMEPAD_BUTTON_LEFT_FACE_RIGHT))
if (IsGamepadButtonDown(0, GamepadButton.LeftFaceRight))
{
DrawRectangle(292 + 44, 228, 26, 19, Color.RED);
DrawRectangle(292 + 44, 228, 26, 19, Color.Red);
}
// Draw buttons: left-right back
if (IsGamepadButtonDown(0, GamepadButton.GAMEPAD_BUTTON_LEFT_TRIGGER_1))
if (IsGamepadButtonDown(0, GamepadButton.LeftTrigger1))
{
DrawCircle(259, 61, 20, Color.RED);
DrawCircle(259, 61, 20, Color.Red);
}
if (IsGamepadButtonDown(0, GamepadButton.GAMEPAD_BUTTON_RIGHT_TRIGGER_1))
if (IsGamepadButtonDown(0, GamepadButton.RightTrigger1))
{
DrawCircle(536, 61, 20, Color.RED);
DrawCircle(536, 61, 20, Color.Red);
}
// Draw axis: left joystick
DrawCircle(259, 152, 39, Color.BLACK);
DrawCircle(259, 152, 34, Color.LIGHTGRAY);
DrawCircle(259, 152, 39, Color.Black);
DrawCircle(259, 152, 34, Color.LightGray);
DrawCircle(
259 + (int)(GetGamepadAxisMovement(0, GamepadAxis.GAMEPAD_AXIS_LEFT_X) * 20),
152 + (int)(GetGamepadAxisMovement(0, GamepadAxis.GAMEPAD_AXIS_LEFT_Y) * 20),
259 + (int)(GetGamepadAxisMovement(0, GamepadAxis.LeftX) * 20),
152 + (int)(GetGamepadAxisMovement(0, GamepadAxis.LeftY) * 20),
25,
Color.BLACK
Color.Black
);
// Draw axis: right joystick
DrawCircle(461, 237, 38, Color.BLACK);
DrawCircle(461, 237, 33, Color.LIGHTGRAY);
DrawCircle(461, 237, 38, Color.Black);
DrawCircle(461, 237, 33, Color.LightGray);
DrawCircle(
461 + (int)(GetGamepadAxisMovement(0, GamepadAxis.GAMEPAD_AXIS_RIGHT_X) * 20),
237 + (int)(GetGamepadAxisMovement(0, GamepadAxis.GAMEPAD_AXIS_RIGHT_Y) * 20),
25, Color.BLACK
461 + (int)(GetGamepadAxisMovement(0, GamepadAxis.RightX) * 20),
237 + (int)(GetGamepadAxisMovement(0, GamepadAxis.RightY) * 20),
25, Color.Black
);
// Draw axis: left-right triggers
float leftTriggerX = GetGamepadAxisMovement(0, GamepadAxis.GAMEPAD_AXIS_LEFT_TRIGGER);
float rightTriggerX = GetGamepadAxisMovement(0, GamepadAxis.GAMEPAD_AXIS_RIGHT_TRIGGER);
DrawRectangle(170, 30, 15, 70, Color.GRAY);
DrawRectangle(604, 30, 15, 70, Color.GRAY);
DrawRectangle(170, 30, 15, (int)(((1.0f + leftTriggerX) / 2.0f) * 70), Color.RED);
DrawRectangle(604, 30, 15, (int)(((1.0f + rightTriggerX) / 2.0f) * 70), Color.RED);
float leftTriggerX = GetGamepadAxisMovement(0, GamepadAxis.LeftTrigger);
float rightTriggerX = GetGamepadAxisMovement(0, GamepadAxis.RightTrigger);
DrawRectangle(170, 30, 15, 70, Color.Gray);
DrawRectangle(604, 30, 15, 70, Color.Gray);
DrawRectangle(170, 30, 15, (int)(((1.0f + leftTriggerX) / 2.0f) * 70), Color.Red);
DrawRectangle(604, 30, 15, (int)(((1.0f + rightTriggerX) / 2.0f) * 70), Color.Red);
}
else if (gamepadName == PS3_NAME_ID)
{
DrawTexture(texPs3Pad, 0, 0, Color.DARKGRAY);
DrawTexture(texPs3Pad, 0, 0, Color.DarkGray);
// Draw buttons: ps
if (IsGamepadButtonDown(0, GamepadButton.GAMEPAD_BUTTON_MIDDLE))
if (IsGamepadButtonDown(0, GamepadButton.Middle))
{
DrawCircle(396, 222, 13, Color.RED);
DrawCircle(396, 222, 13, Color.Red);
}
// Draw buttons: basic
if (IsGamepadButtonDown(0, GamepadButton.GAMEPAD_BUTTON_MIDDLE_LEFT))
if (IsGamepadButtonDown(0, GamepadButton.MiddleLeft))
{
DrawRectangle(328, 170, 32, 13, Color.RED);
DrawRectangle(328, 170, 32, 13, Color.Red);
}
if (IsGamepadButtonDown(0, GamepadButton.GAMEPAD_BUTTON_MIDDLE_RIGHT))
if (IsGamepadButtonDown(0, GamepadButton.MiddleRight))
{
DrawTriangle(
new Vector2(436, 168),
new Vector2(436, 185),
new Vector2(464, 177),
Color.RED
Color.Red
);
}
if (IsGamepadButtonDown(0, GamepadButton.GAMEPAD_BUTTON_RIGHT_FACE_UP))
if (IsGamepadButtonDown(0, GamepadButton.RightFaceUp))
{
DrawCircle(557, 144, 13, Color.LIME);
DrawCircle(557, 144, 13, Color.Lime);
}
if (IsGamepadButtonDown(0, GamepadButton.GAMEPAD_BUTTON_RIGHT_FACE_RIGHT))
if (IsGamepadButtonDown(0, GamepadButton.RightFaceRight))
{
DrawCircle(586, 173, 13, Color.RED);
DrawCircle(586, 173, 13, Color.Red);
}
if (IsGamepadButtonDown(0, GamepadButton.GAMEPAD_BUTTON_RIGHT_FACE_DOWN))
if (IsGamepadButtonDown(0, GamepadButton.RightFaceDown))
{
DrawCircle(557, 203, 13, Color.VIOLET);
DrawCircle(557, 203, 13, Color.Violet);
}
if (IsGamepadButtonDown(0, GamepadButton.GAMEPAD_BUTTON_RIGHT_FACE_LEFT))
if (IsGamepadButtonDown(0, GamepadButton.RightFaceLeft))
{
DrawCircle(527, 173, 13, Color.PINK);
DrawCircle(527, 173, 13, Color.Pink);
}
// Draw buttons: d-pad
DrawRectangle(225, 132, 24, 84, Color.BLACK);
DrawRectangle(195, 161, 84, 25, Color.BLACK);
if (IsGamepadButtonDown(0, GamepadButton.GAMEPAD_BUTTON_LEFT_FACE_UP))
DrawRectangle(225, 132, 24, 84, Color.Black);
DrawRectangle(195, 161, 84, 25, Color.Black);
if (IsGamepadButtonDown(0, GamepadButton.LeftFaceUp))
{
DrawRectangle(225, 132, 24, 29, Color.RED);
DrawRectangle(225, 132, 24, 29, Color.Red);
}
if (IsGamepadButtonDown(0, GamepadButton.GAMEPAD_BUTTON_LEFT_FACE_DOWN))
if (IsGamepadButtonDown(0, GamepadButton.LeftFaceDown))
{
DrawRectangle(225, 132 + 54, 24, 30, Color.RED);
DrawRectangle(225, 132 + 54, 24, 30, Color.Red);
}
if (IsGamepadButtonDown(0, GamepadButton.GAMEPAD_BUTTON_LEFT_FACE_LEFT))
if (IsGamepadButtonDown(0, GamepadButton.LeftFaceLeft))
{
DrawRectangle(195, 161, 30, 25, Color.RED);
DrawRectangle(195, 161, 30, 25, Color.Red);
}
if (IsGamepadButtonDown(0, GamepadButton.GAMEPAD_BUTTON_LEFT_FACE_RIGHT))
if (IsGamepadButtonDown(0, GamepadButton.LeftFaceRight))
{
DrawRectangle(195 + 54, 161, 30, 25, Color.RED);
DrawRectangle(195 + 54, 161, 30, 25, Color.Red);
}
// Draw buttons: left-right back buttons
if (IsGamepadButtonDown(0, GamepadButton.GAMEPAD_BUTTON_LEFT_TRIGGER_1))
if (IsGamepadButtonDown(0, GamepadButton.LeftTrigger1))
{
DrawCircle(239, 82, 20, Color.RED);
DrawCircle(239, 82, 20, Color.Red);
}
if (IsGamepadButtonDown(0, GamepadButton.GAMEPAD_BUTTON_RIGHT_TRIGGER_1))
if (IsGamepadButtonDown(0, GamepadButton.RightTrigger1))
{
DrawCircle(557, 82, 20, Color.RED);
DrawCircle(557, 82, 20, Color.Red);
}
// Draw axis: left joystick
DrawCircle(319, 255, 35, Color.BLACK);
DrawCircle(319, 255, 31, Color.LIGHTGRAY);
DrawCircle(319, 255, 35, Color.Black);
DrawCircle(319, 255, 31, Color.LightGray);
DrawCircle(
319 + (int)(GetGamepadAxisMovement(0, GamepadAxis.GAMEPAD_AXIS_LEFT_X) * 20),
255 + (int)(GetGamepadAxisMovement(0, GamepadAxis.GAMEPAD_AXIS_LEFT_Y) * 20),
319 + (int)(GetGamepadAxisMovement(0, GamepadAxis.LeftX) * 20),
255 + (int)(GetGamepadAxisMovement(0, GamepadAxis.LeftY) * 20),
25,
Color.BLACK
Color.Black
);
// Draw axis: right joystick
DrawCircle(475, 255, 35, Color.BLACK);
DrawCircle(475, 255, 31, Color.LIGHTGRAY);
DrawCircle(475, 255, 35, Color.Black);
DrawCircle(475, 255, 31, Color.LightGray);
DrawCircle(
475 + (int)(GetGamepadAxisMovement(0, GamepadAxis.GAMEPAD_AXIS_RIGHT_X) * 20),
255 + (int)(GetGamepadAxisMovement(0, GamepadAxis.GAMEPAD_AXIS_RIGHT_Y) * 20),
475 + (int)(GetGamepadAxisMovement(0, GamepadAxis.RightX) * 20),
255 + (int)(GetGamepadAxisMovement(0, GamepadAxis.RightY) * 20),
25,
Color.BLACK
Color.Black
);
// Draw axis: left-right triggers
float leftTriggerX = GetGamepadAxisMovement(0, GamepadAxis.GAMEPAD_AXIS_LEFT_TRIGGER);
float rightTriggerX = GetGamepadAxisMovement(0, GamepadAxis.GAMEPAD_AXIS_RIGHT_TRIGGER);
DrawRectangle(169, 48, 15, 70, Color.GRAY);
DrawRectangle(611, 48, 15, 70, Color.GRAY);
DrawRectangle(169, 48, 15, (int)(((1.0f - leftTriggerX) / 2.0f) * 70), Color.RED);
DrawRectangle(611, 48, 15, (int)(((1.0f - rightTriggerX) / 2.0f) * 70), Color.RED);
float leftTriggerX = GetGamepadAxisMovement(0, GamepadAxis.LeftTrigger);
float rightTriggerX = GetGamepadAxisMovement(0, GamepadAxis.RightTrigger);
DrawRectangle(169, 48, 15, 70, Color.Gray);
DrawRectangle(611, 48, 15, 70, Color.Gray);
DrawRectangle(169, 48, 15, (int)(((1.0f - leftTriggerX) / 2.0f) * 70), Color.Red);
DrawRectangle(611, 48, 15, (int)(((1.0f - rightTriggerX) / 2.0f) * 70), Color.Red);
}
else
{
DrawText("- GENERIC GAMEPAD -", 280, 180, 20, Color.GRAY);
DrawText("- GENERIC GAMEPAD -", 280, 180, 20, Color.Gray);
// TODO: Draw generic gamepad
}
DrawText($"DETECTED AXIS [{GetGamepadAxisCount(0)}]:", 10, 50, 10, Color.MAROON);
DrawText($"DETECTED AXIS [{GetGamepadAxisCount(0)}]:", 10, 50, 10, Color.Maroon);
for (int i = 0; i < GetGamepadAxisCount(0); i++)
{
@ -292,23 +292,23 @@ public class InputGamepad
20,
70 + 20 * i,
10,
Color.DARKGRAY
Color.DarkGray
);
}
if (GetGamepadButtonPressed() != (int)GamepadButton.GAMEPAD_BUTTON_UNKNOWN)
if (GetGamepadButtonPressed() != (int)GamepadButton.Unknown)
{
DrawText($"DETECTED BUTTON: {GetGamepadButtonPressed()}", 10, 430, 10, Color.RED);
DrawText($"DETECTED BUTTON: {GetGamepadButtonPressed()}", 10, 430, 10, Color.Red);
}
else
{
DrawText("DETECTED BUTTON: NONE", 10, 430, 10, Color.GRAY);
DrawText("DETECTED BUTTON: NONE", 10, 430, 10, Color.Gray);
}
}
else
{
DrawText("GP1: NOT DETECTED", 10, 10, 10, Color.GRAY);
DrawTexture(texXboxPad, 0, 0, Color.LIGHTGRAY);
DrawText("GP1: NOT DETECTED", 10, 10, 10, Color.Gray);
DrawTexture(texXboxPad, 0, 0, Color.LightGray);
}
EndDrawing();

View File

@ -33,8 +33,8 @@ public class InputGestures
int gesturesCount = 0;
string[] gestureStrings = new string[MaxGestureStrings];
Gesture currentGesture = Gesture.GESTURE_NONE;
Gesture lastGesture = Gesture.GESTURE_NONE;
Gesture currentGesture = Gesture.None;
Gesture lastGesture = Gesture.None;
// SetGesturesEnabled(0b0000000000001001); // Enable only some gestures to be detected
@ -50,41 +50,41 @@ public class InputGestures
currentGesture = GetGestureDetected();
touchPosition = GetTouchPosition(0);
if (CheckCollisionPointRec(touchPosition, touchArea) && (currentGesture != Gesture.GESTURE_NONE))
if (CheckCollisionPointRec(touchPosition, touchArea) && (currentGesture != Gesture.None))
{
if (currentGesture != lastGesture)
{
// Store gesture string
switch ((Gesture)currentGesture)
{
case Gesture.GESTURE_TAP:
case Gesture.Tap:
gestureStrings[gesturesCount] = "GESTURE TAP";
break;
case Gesture.GESTURE_DOUBLETAP:
case Gesture.DoubleTap:
gestureStrings[gesturesCount] = "GESTURE DOUBLETAP";
break;
case Gesture.GESTURE_HOLD:
case Gesture.Hold:
gestureStrings[gesturesCount] = "GESTURE HOLD";
break;
case Gesture.GESTURE_DRAG:
case Gesture.Drag:
gestureStrings[gesturesCount] = "GESTURE DRAG";
break;
case Gesture.GESTURE_SWIPE_RIGHT:
case Gesture.SwipeRight:
gestureStrings[gesturesCount] = "GESTURE SWIPE RIGHT";
break;
case Gesture.GESTURE_SWIPE_LEFT:
case Gesture.SwipeLeft:
gestureStrings[gesturesCount] = "GESTURE SWIPE LEFT";
break;
case Gesture.GESTURE_SWIPE_UP:
case Gesture.SwipeUp:
gestureStrings[gesturesCount] = "GESTURE SWIPE UP";
break;
case Gesture.GESTURE_SWIPE_DOWN:
case Gesture.SwipeDown:
gestureStrings[gesturesCount] = "GESTURE SWIPE DOWN";
break;
case Gesture.GESTURE_PINCH_IN:
case Gesture.PinchIn:
gestureStrings[gesturesCount] = "GESTURE PINCH IN";
break;
case Gesture.GESTURE_PINCH_OUT:
case Gesture.PinchOut:
gestureStrings[gesturesCount] = "GESTURE PINCH OUT";
break;
default:
@ -109,40 +109,40 @@ public class InputGestures
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
DrawRectangleRec(touchArea, Color.GRAY);
DrawRectangle(225, 15, screenWidth - 240, screenHeight - 30, Color.RAYWHITE);
DrawRectangleRec(touchArea, Color.Gray);
DrawRectangle(225, 15, screenWidth - 240, screenHeight - 30, Color.RayWhite);
DrawText("GESTURES TEST AREA", screenWidth - 270, screenHeight - 40, 20, ColorAlpha(Color.GRAY, 0.5f));
DrawText("GESTURES TEST AREA", screenWidth - 270, screenHeight - 40, 20, ColorAlpha(Color.Gray, 0.5f));
for (int i = 0; i < gesturesCount; i++)
{
if (i % 2 == 0)
{
DrawRectangle(10, 30 + 20 * i, 200, 20, ColorAlpha(Color.LIGHTGRAY, 0.5f));
DrawRectangle(10, 30 + 20 * i, 200, 20, ColorAlpha(Color.LightGray, 0.5f));
}
else
{
DrawRectangle(10, 30 + 20 * i, 200, 20, ColorAlpha(Color.LIGHTGRAY, 0.3f));
DrawRectangle(10, 30 + 20 * i, 200, 20, ColorAlpha(Color.LightGray, 0.3f));
}
if (i < gesturesCount - 1)
{
DrawText(gestureStrings[i], 35, 36 + 20 * i, 10, Color.DARKGRAY);
DrawText(gestureStrings[i], 35, 36 + 20 * i, 10, Color.DarkGray);
}
else
{
DrawText(gestureStrings[i], 35, 36 + 20 * i, 10, Color.MAROON);
DrawText(gestureStrings[i], 35, 36 + 20 * i, 10, Color.Maroon);
}
}
DrawRectangleLines(10, 29, 200, screenHeight - 50, Color.GRAY);
DrawText("DETECTED GESTURES", 50, 15, 10, Color.GRAY);
DrawRectangleLines(10, 29, 200, screenHeight - 50, Color.Gray);
DrawText("DETECTED GESTURES", 50, 15, 10, Color.Gray);
if (currentGesture != Gesture.GESTURE_NONE)
if (currentGesture != Gesture.None)
{
DrawCircleV(touchPosition, 30, Color.MAROON);
DrawCircleV(touchPosition, 30, Color.Maroon);
}
EndDrawing();

View File

@ -35,22 +35,22 @@ public class InputKeys
{
// Update
//----------------------------------------------------------------------------------
if (IsKeyDown(KeyboardKey.KEY_RIGHT))
if (IsKeyDown(KeyboardKey.Right))
{
ballPosition.X += 2.0f;
}
if (IsKeyDown(KeyboardKey.KEY_LEFT))
if (IsKeyDown(KeyboardKey.Left))
{
ballPosition.X -= 2.0f;
}
if (IsKeyDown(KeyboardKey.KEY_UP))
if (IsKeyDown(KeyboardKey.Up))
{
ballPosition.Y -= 2.0f;
}
if (IsKeyDown(KeyboardKey.KEY_DOWN))
if (IsKeyDown(KeyboardKey.Down))
{
ballPosition.Y += 2.0f;
}
@ -59,11 +59,11 @@ public class InputKeys
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
DrawText("move the ball with arrow keys", 10, 10, 20, Color.DARKGRAY);
DrawText("move the ball with arrow keys", 10, 10, 20, Color.DarkGray);
DrawCircleV(ballPosition, 50, Color.MAROON);
DrawCircleV(ballPosition, 50, Color.Maroon);
EndDrawing();
//----------------------------------------------------------------------------------

View File

@ -26,7 +26,7 @@ public class InputMouse
InitWindow(screenWidth, screenHeight, "raylib [core] example - mouse input");
Vector2 ballPosition = new(-100.0f, -100.0f);
Color ballColor = Color.DARKBLUE;
Color ballColor = Color.DarkBlue;
SetTargetFPS(60);
//---------------------------------------------------------------------------------------
@ -38,28 +38,28 @@ public class InputMouse
//----------------------------------------------------------------------------------
ballPosition = GetMousePosition();
if (IsMouseButtonPressed(MouseButton.MOUSE_LEFT_BUTTON))
if (IsMouseButtonPressed(MouseButton.Left))
{
ballColor = Color.MAROON;
ballColor = Color.Maroon;
}
else if (IsMouseButtonPressed(MouseButton.MOUSE_MIDDLE_BUTTON))
else if (IsMouseButtonPressed(MouseButton.Middle))
{
ballColor = Color.LIME;
ballColor = Color.Lime;
}
else if (IsMouseButtonPressed(MouseButton.MOUSE_RIGHT_BUTTON))
else if (IsMouseButtonPressed(MouseButton.Right))
{
ballColor = Color.DARKBLUE;
ballColor = Color.DarkBlue;
}
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
DrawCircleV(ballPosition, 40, ballColor);
DrawText("move ball with mouse and click mouse button to change color", 10, 10, 20, Color.DARKGRAY);
DrawText("move ball with mouse and click mouse button to change color", 10, 10, 20, Color.DarkGray);
EndDrawing();
//----------------------------------------------------------------------------------

View File

@ -43,12 +43,12 @@ public class InputMouseWheel
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
DrawRectangle(screenWidth / 2 - 40, boxPositionY, 80, 80, Color.MAROON);
DrawRectangle(screenWidth / 2 - 40, boxPositionY, 80, 80, Color.Maroon);
DrawText("Use mouse wheel to move the cube up and down!", 10, 10, 20, Color.GRAY);
DrawText($"Box position Y: {boxPositionY}", 10, 40, 20, Color.LIGHTGRAY);
DrawText("Use mouse wheel to move the cube up and down!", 10, 10, 20, Color.Gray);
DrawText($"Box position Y: {boxPositionY}", 10, 40, 20, Color.LightGray);
EndDrawing();
//----------------------------------------------------------------------------------

View File

@ -57,7 +57,7 @@ public class InputMultitouch
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
for (int i = 0; i < tCount; i++)
{
@ -65,17 +65,17 @@ public class InputMultitouch
if ((touchPositions[i].X > 0) && (touchPositions[i].Y > 0))
{
// Draw circle and touch index number
DrawCircleV(touchPositions[i], 34, Color.ORANGE);
DrawCircleV(touchPositions[i], 34, Color.Orange);
DrawText(i.ToString(),
(int)touchPositions[i].X - 10,
(int)touchPositions[i].Y - 70,
40,
Color.BLACK
Color.Black
);
}
}
DrawText("touch the screen at multiple locations to get multiple balls", 10, 10, 20, Color.DARKGRAY);
DrawText("touch the screen at multiple locations to get multiple balls", 10, 10, 20, Color.DarkGray);
EndDrawing();
//----------------------------------------------------------------------------------

View File

@ -31,7 +31,7 @@ public class Picking3d
camera.Target = new Vector3(0.0f, 0.0f, 0.0f);
camera.Up = new Vector3(0.0f, 1.0f, 0.0f);
camera.FovY = 45.0f;
camera.Projection = CameraProjection.CAMERA_PERSPECTIVE;
camera.Projection = CameraProjection.Perspective;
Vector3 cubePosition = new(0.0f, 1.0f, 0.0f);
Vector3 cubeSize = new(2.0f, 2.0f, 2.0f);
@ -48,9 +48,9 @@ public class Picking3d
{
// Update
//----------------------------------------------------------------------------------
UpdateCamera(ref camera, CameraMode.CAMERA_FREE);
UpdateCamera(ref camera, CameraMode.Free);
if (IsMouseButtonPressed(MouseButton.MOUSE_LEFT_BUTTON))
if (IsMouseButtonPressed(MouseButton.Left))
{
if (!collision.Hit)
{
@ -75,34 +75,34 @@ public class Picking3d
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
BeginMode3D(camera);
if (collision.Hit)
{
DrawCube(cubePosition, cubeSize.X, cubeSize.Y, cubeSize.Z, Color.RED);
DrawCubeWires(cubePosition, cubeSize.X, cubeSize.Y, cubeSize.Z, Color.MAROON);
DrawCube(cubePosition, cubeSize.X, cubeSize.Y, cubeSize.Z, Color.Red);
DrawCubeWires(cubePosition, cubeSize.X, cubeSize.Y, cubeSize.Z, Color.Maroon);
DrawCubeWires(cubePosition, cubeSize.X + 0.2f, cubeSize.Y + 0.2f, cubeSize.Z + 0.2f, Color.GREEN);
DrawCubeWires(cubePosition, cubeSize.X + 0.2f, cubeSize.Y + 0.2f, cubeSize.Z + 0.2f, Color.Green);
}
else
{
DrawCube(cubePosition, cubeSize.X, cubeSize.Y, cubeSize.Z, Color.GRAY);
DrawCubeWires(cubePosition, cubeSize.X, cubeSize.Y, cubeSize.Z, Color.DARKGRAY);
DrawCube(cubePosition, cubeSize.X, cubeSize.Y, cubeSize.Z, Color.Gray);
DrawCubeWires(cubePosition, cubeSize.X, cubeSize.Y, cubeSize.Z, Color.DarkGray);
}
DrawRay(ray, Color.MAROON);
DrawRay(ray, Color.Maroon);
DrawGrid(10, 1.0f);
EndMode3D();
DrawText("Try selecting the box with mouse!", 240, 10, 20, Color.DARKGRAY);
DrawText("Try selecting the box with mouse!", 240, 10, 20, Color.DarkGray);
if (collision.Hit)
{
int posX = (screenWidth - MeasureText("BOX SELECTED", 30)) / 2;
DrawText("BOX SELECTED", posX, (int)(screenHeight * 0.1f), 30, Color.GREEN);
DrawText("BOX SELECTED", posX, (int)(screenHeight * 0.1f), 30, Color.Green);
}
DrawFPS(10, 10);

View File

@ -51,11 +51,11 @@ public class RandomValues
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
DrawText("Every 2 seconds a new random value is generated:", 130, 100, 20, Color.MAROON);
DrawText("Every 2 seconds a new random value is generated:", 130, 100, 20, Color.Maroon);
DrawText($"{randValue}", 360, 180, 80, Color.LIGHTGRAY);
DrawText($"{randValue}", 360, 180, 80, Color.LightGray);
EndDrawing();
//----------------------------------------------------------------------------------

View File

@ -37,7 +37,7 @@ public class ScissorTest
{
// Update
//----------------------------------------------------------------------------------
if (IsKeyPressed(KeyboardKey.KEY_S))
if (IsKeyPressed(KeyboardKey.S))
{
scissorMode = !scissorMode;
}
@ -50,7 +50,7 @@ public class ScissorTest
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
if (scissorMode)
{
@ -59,16 +59,16 @@ public class ScissorTest
// Draw full screen rectangle and some text
// NOTE: Only part defined by scissor area will be rendered
DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), Color.RED);
DrawText("Move the mouse around to reveal this text!", 190, 200, 20, Color.LIGHTGRAY);
DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), Color.Red);
DrawText("Move the mouse around to reveal this text!", 190, 200, 20, Color.LightGray);
if (scissorMode)
{
EndScissorMode();
}
DrawRectangleLinesEx(scissorArea, 1, Color.BLACK);
DrawText("Press S to toggle scissor test", 10, 10, 20, Color.BLACK);
DrawRectangleLinesEx(scissorArea, 1, Color.Black);
DrawText("Press S to toggle scissor test", 10, 10, 20, Color.Black);
EndDrawing();
//----------------------------------------------------------------------------------

View File

@ -100,25 +100,25 @@ public static class SmoothPixelPerfect
// Draw
//----------------------------------------------------------------------------------
BeginTextureMode(target);
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
BeginMode2D(worldSpaceCamera);
DrawRectanglePro(rec01, origin, rotation, Color.BLACK);
DrawRectanglePro(rec02, origin, -rotation, Color.RED);
DrawRectanglePro(rec03, origin, rotation + 45.0f, Color.BLUE);
DrawRectanglePro(rec01, origin, rotation, Color.Black);
DrawRectanglePro(rec02, origin, -rotation, Color.Red);
DrawRectanglePro(rec03, origin, rotation + 45.0f, Color.Blue);
EndMode2D();
EndTextureMode();
BeginDrawing();
ClearBackground(Color.RED);
ClearBackground(Color.Red);
BeginMode2D(screenSpaceCamera);
DrawTexturePro(target.Texture, sourceRec, destRec, origin, 0.0f, Color.WHITE);
DrawTexturePro(target.Texture, sourceRec, destRec, origin, 0.0f, Color.White);
EndMode2D();
DrawText($"Screen resolution: {screenWidth}x{screenHeight}", 10, 10, 20, Color.DARKBLUE);
DrawText($"World resolution: {virtualScreenWidth}x{virtualScreenHeight}", 10, 40, 20, Color.DARKGREEN);
DrawText($"Screen resolution: {screenWidth}x{screenHeight}", 10, 10, 20, Color.DarkBlue);
DrawText($"World resolution: {virtualScreenWidth}x{virtualScreenHeight}", 10, 40, 20, Color.DarkGreen);
DrawFPS(GetScreenWidth() - 95, 10);
EndDrawing();
//----------------------------------------------------------------------------------

View File

@ -30,20 +30,20 @@ public unsafe class SplitScreen
// Grid of cube trees on a plane to make a "world"
// Simple world plane
DrawPlane(new Vector3(0, 0, 0), new Vector2(50, 50), Color.BEIGE);
DrawPlane(new Vector3(0, 0, 0), new Vector2(50, 50), Color.Beige);
for (float x = -count * spacing; x <= count * spacing; x += spacing)
{
for (float z = -count * spacing; z <= count * spacing; z += spacing)
{
DrawCube(new Vector3(x, 1.5f, z), 1, 1, 1, Color.LIME);
DrawCube(new Vector3(x, 0.5f, z), 0.25f, 1, 0.25f, Color.BROWN);
DrawCube(new Vector3(x, 1.5f, z), 1, 1, 1, Color.Lime);
DrawCube(new Vector3(x, 0.5f, z), 0.25f, 1, 0.25f, Color.Brown);
}
}
// Draw a cube at each player's position
DrawCube(CameraPlayer1.Position, 1, 1, 1, Color.RED);
DrawCube(CameraPlayer2.Position, 1, 1, 1, Color.BLUE);
DrawCube(CameraPlayer1.Position, 1, 1, 1, Color.Red);
DrawCube(CameraPlayer2.Position, 1, 1, 1, Color.Blue);
}
public static int Main()
@ -56,11 +56,11 @@ public unsafe class SplitScreen
InitWindow(screenWidth, screenHeight, "raylib [core] example - split screen");
// Generate a simple texture to use for trees
Image img = GenImageChecked(256, 256, 32, 32, Color.DARKGRAY, Color.WHITE);
Image img = GenImageChecked(256, 256, 32, 32, Color.DarkGray, Color.White);
TextureGrid = LoadTextureFromImage(img);
UnloadImage(img);
SetTextureFilter(TextureGrid, TextureFilter.TEXTURE_FILTER_ANISOTROPIC_16X);
SetTextureWrap(TextureGrid, TextureWrap.TEXTURE_WRAP_CLAMP);
SetTextureFilter(TextureGrid, TextureFilter.Anisotropic16X);
SetTextureWrap(TextureGrid, TextureWrap.Clamp);
// Setup player 1 camera and screen
CameraPlayer1.FovY = 45.0f;
@ -101,24 +101,24 @@ public unsafe class SplitScreen
float offsetThisFrame = 10.0f * GetFrameTime();
// Move Player1 forward and backwards (no turning)
if (IsKeyDown(KeyboardKey.KEY_W))
if (IsKeyDown(KeyboardKey.W))
{
CameraPlayer1.Position.Z += offsetThisFrame;
CameraPlayer1.Target.Z += offsetThisFrame;
}
else if (IsKeyDown(KeyboardKey.KEY_S))
else if (IsKeyDown(KeyboardKey.S))
{
CameraPlayer1.Position.Z -= offsetThisFrame;
CameraPlayer1.Target.Z -= offsetThisFrame;
}
// Move Player2 forward and backwards (no turning)
if (IsKeyDown(KeyboardKey.KEY_UP))
if (IsKeyDown(KeyboardKey.Up))
{
CameraPlayer2.Position.X += offsetThisFrame;
CameraPlayer2.Target.X += offsetThisFrame;
}
else if (IsKeyDown(KeyboardKey.KEY_DOWN))
else if (IsKeyDown(KeyboardKey.Down))
{
CameraPlayer2.Position.X -= offsetThisFrame;
CameraPlayer2.Target.X -= offsetThisFrame;
@ -129,32 +129,32 @@ public unsafe class SplitScreen
//----------------------------------------------------------------------------------
// Draw Player1 view to the render texture
BeginTextureMode(screenPlayer1);
ClearBackground(Color.SKYBLUE);
ClearBackground(Color.SkyBlue);
BeginMode3D(CameraPlayer1);
DrawScene();
EndMode3D();
DrawText("PLAYER 1 W/S to move", 10, 10, 20, Color.RED);
DrawText("PLAYER 1 W/S to move", 10, 10, 20, Color.Red);
EndTextureMode();
// Draw Player2 view to the render texture
BeginTextureMode(screenPlayer2);
ClearBackground(Color.SKYBLUE);
ClearBackground(Color.SkyBlue);
BeginMode3D(CameraPlayer2);
DrawScene();
EndMode3D();
DrawText("PLAYER 2 UP/DOWN to move", 10, 10, 20, Color.BLUE);
DrawText("PLAYER 2 UP/DOWN to move", 10, 10, 20, Color.Blue);
EndTextureMode();
// Draw both views render textures to the screen side by side
BeginDrawing();
ClearBackground(Color.BLACK);
ClearBackground(Color.Black);
DrawTextureRec(screenPlayer1.Texture, splitScreenRect, new Vector2(0, 0), Color.WHITE);
DrawTextureRec(screenPlayer2.Texture, splitScreenRect, new Vector2(screenWidth / 2.0f, 0), Color.WHITE);
DrawTextureRec(screenPlayer1.Texture, splitScreenRect, new Vector2(0, 0), Color.White);
DrawTextureRec(screenPlayer2.Texture, splitScreenRect, new Vector2(screenWidth / 2.0f, 0), Color.White);
EndDrawing();
}

View File

@ -44,18 +44,18 @@ public class StorageValues
{
// Update
//----------------------------------------------------------------------------------
if (IsKeyPressed(KeyboardKey.KEY_R))
if (IsKeyPressed(KeyboardKey.R))
{
score = GetRandomValue(1000, 2000);
hiscore = GetRandomValue(2000, 4000);
}
if (IsKeyPressed(KeyboardKey.KEY_ENTER))
if (IsKeyPressed(KeyboardKey.Enter))
{
SaveStorageValue(storageDataFile, (int)StorageData.Score, score);
SaveStorageValue(storageDataFile, (int)StorageData.HiScore, hiscore);
}
else if (IsKeyPressed(KeyboardKey.KEY_SPACE))
else if (IsKeyPressed(KeyboardKey.Space))
{
// NOTE: If requested position could not be found, value 0 is returned
score = LoadStorageValue(storageDataFile, (int)StorageData.Score);
@ -68,16 +68,16 @@ public class StorageValues
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
DrawText($"SCORE: {score}", 280, 130, 40, Color.MAROON);
DrawText($"HI-SCORE: {hiscore}", 210, 200, 50, Color.BLACK);
DrawText($"SCORE: {score}", 280, 130, 40, Color.Maroon);
DrawText($"HI-SCORE: {hiscore}", 210, 200, 50, Color.Black);
DrawText($"frames: {framesCounter}", 10, 10, 20, Color.LIME);
DrawText($"frames: {framesCounter}", 10, 10, 20, Color.Lime);
DrawText("Press R to generate random numbers", 220, 40, 20, Color.LIGHTGRAY);
DrawText("Press ENTER to SAVE values", 250, 310, 20, Color.LIGHTGRAY);
DrawText("Press SPACE to LOAD values", 252, 350, 20, Color.LIGHTGRAY);
DrawText("Press R to generate random numbers", 220, 40, 20, Color.LightGray);
DrawText("Press ENTER to SAVE values", 250, 310, 20, Color.LightGray);
DrawText("Press SPACE to LOAD values", 252, 350, 20, Color.LightGray);
EndDrawing();
//----------------------------------------------------------------------------------
@ -123,7 +123,7 @@ public class StorageValues
// RL_REALLOC failed
uint positionInBytes = position * sizeof(int);
TraceLog(
TraceLogLevel.LOG_WARNING,
TraceLogLevel.Warning,
@$"FILEIO: [{fileName}] Failed to realloc data ({dataSize}),
position in bytes({positionInBytes}) bigger than actual file size"
);
@ -147,11 +147,11 @@ public class StorageValues
success = SaveFileData(fileNameBuffer.AsPointer(), newFileData, newDataSize);
MemFree(newFileData);
TraceLog(TraceLogLevel.LOG_INFO, $"FILEIO: [{fileName}] Saved storage value: {value}");
TraceLog(TraceLogLevel.Info, $"FILEIO: [{fileName}] Saved storage value: {value}");
}
else
{
TraceLog(TraceLogLevel.LOG_INFO, $"FILEIO: [{fileName}] File created successfully");
TraceLog(TraceLogLevel.Info, $"FILEIO: [{fileName}] File created successfully");
dataSize = (position + 1) * sizeof(int);
fileData = (byte*)MemAlloc((int)dataSize);
@ -161,7 +161,7 @@ public class StorageValues
success = SaveFileData(fileNameBuffer.AsPointer(), fileData, dataSize);
UnloadFileData(fileData);
TraceLog(TraceLogLevel.LOG_INFO, $"FILEIO: [{fileName}] Saved storage value: {value}");
TraceLog(TraceLogLevel.Info, $"FILEIO: [{fileName}] Saved storage value: {value}");
}
return success;
@ -182,7 +182,7 @@ public class StorageValues
if (dataSize < (position * 4))
{
TraceLog(
TraceLogLevel.LOG_WARNING,
TraceLogLevel.Warning,
$"FILEIO: [{fileName}] Failed to find storage position: {value}"
);
}
@ -194,7 +194,7 @@ public class StorageValues
UnloadFileData(fileData);
TraceLog(TraceLogLevel.LOG_INFO, $"FILEIO: [{fileName}] Loaded storage value: {value}");
TraceLog(TraceLogLevel.Info, $"FILEIO: [{fileName}] Loaded storage value: {value}");
}
return value;

View File

@ -24,7 +24,7 @@ public class VrSimulator
const int screenWidth = 1080;
const int screenHeight = 600;
SetConfigFlags(ConfigFlags.FLAG_MSAA_4X_HINT);
SetConfigFlags(ConfigFlags.Msaa4xHint);
InitWindow(screenWidth, screenHeight, "raylib [core] example - vr simulator");
// VR device parameters definition
@ -67,38 +67,38 @@ public class VrSimulator
distortion,
GetShaderLocation(distortion, "leftLensCenter"),
config.LeftLensCenter,
ShaderUniformDataType.SHADER_UNIFORM_VEC2
ShaderUniformDataType.Vec2
);
Raylib.SetShaderValue(
distortion,
GetShaderLocation(distortion, "rightLensCenter"),
config.RightLensCenter,
ShaderUniformDataType.SHADER_UNIFORM_VEC2
ShaderUniformDataType.Vec2
);
Raylib.SetShaderValue(
distortion,
GetShaderLocation(distortion, "leftScreenCenter"),
config.LeftScreenCenter,
ShaderUniformDataType.SHADER_UNIFORM_VEC2
ShaderUniformDataType.Vec2
);
Raylib.SetShaderValue(
distortion,
GetShaderLocation(distortion, "rightScreenCenter"),
config.RightScreenCenter,
ShaderUniformDataType.SHADER_UNIFORM_VEC2
ShaderUniformDataType.Vec2
);
Raylib.SetShaderValue(
distortion,
GetShaderLocation(distortion, "scale"),
config.Scale,
ShaderUniformDataType.SHADER_UNIFORM_VEC2
ShaderUniformDataType.Vec2
);
Raylib.SetShaderValue(
distortion,
GetShaderLocation(distortion, "scaleIn"),
config.ScaleIn,
ShaderUniformDataType.SHADER_UNIFORM_VEC2
ShaderUniformDataType.Vec2
);
unsafe
@ -107,13 +107,13 @@ public class VrSimulator
distortion,
GetShaderLocation(distortion, "deviceWarpParam"),
device.LensDistortionValues,
ShaderUniformDataType.SHADER_UNIFORM_VEC4
ShaderUniformDataType.Vec4
);
SetShaderValue(
distortion,
GetShaderLocation(distortion, "chromaAbParam"),
device.ChromaAbCorrection,
ShaderUniformDataType.SHADER_UNIFORM_VEC4
ShaderUniformDataType.Vec4
);
}
@ -127,7 +127,7 @@ public class VrSimulator
camera.Target = new Vector3(0.0f, 2.0f, 0.0f);
camera.Up = new Vector3(0.0f, 1.0f, 0.0f);
camera.FovY = 60.0f;
camera.Projection = CameraProjection.CAMERA_PERSPECTIVE;
camera.Projection = CameraProjection.Perspective;
Vector3 cubePosition = new(0.0f, 0.0f, 0.0f);
@ -139,22 +139,22 @@ public class VrSimulator
{
// Update
//----------------------------------------------------------------------------------
UpdateCamera(ref camera, CameraMode.CAMERA_FIRST_PERSON);
UpdateCamera(ref camera, CameraMode.FirstPerson);
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
BeginTextureMode(target);
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
BeginVrStereoMode(config);
BeginMode3D(camera);
DrawCube(cubePosition, 2.0f, 2.0f, 2.0f, Color.RED);
DrawCubeWires(cubePosition, 2.0f, 2.0f, 2.0f, Color.MAROON);
DrawCube(cubePosition, 2.0f, 2.0f, 2.0f, Color.Red);
DrawCubeWires(cubePosition, 2.0f, 2.0f, 2.0f, Color.Maroon);
DrawGrid(40, 1.0f);
EndMode3D();
@ -166,7 +166,7 @@ public class VrSimulator
target.Texture,
new Rectangle(0, 0, (float)target.Texture.Width, (float)-target.Texture.Height),
new Vector2(0.0f, 0.0f),
Color.WHITE
Color.White
);
EndShaderMode();

View File

@ -42,7 +42,7 @@ public class WindowFlags
*/
// Set configuration flags for window creation
SetConfigFlags(FLAG_VSYNC_HINT | FLAG_MSAA_4X_HINT);
SetConfigFlags(VSyncHint | Msaa4xHint);
InitWindow(screenWidth, screenHeight, "raylib [core] example - window flags");
Vector2 ballPosition = new(GetScreenWidth() / 2, GetScreenHeight() / 2);
@ -57,59 +57,59 @@ public class WindowFlags
{
// Update
//-----------------------------------------------------
if (IsKeyPressed(KeyboardKey.KEY_F))
if (IsKeyPressed(KeyboardKey.F))
{
// modifies window size when scaling!
ToggleFullscreen();
}
if (IsKeyPressed(KeyboardKey.KEY_R))
if (IsKeyPressed(KeyboardKey.R))
{
if (IsWindowState(FLAG_WINDOW_RESIZABLE))
if (IsWindowState(ResizableWindow))
{
ClearWindowState(FLAG_WINDOW_RESIZABLE);
ClearWindowState(ResizableWindow);
}
else
{
SetWindowState(FLAG_WINDOW_RESIZABLE);
SetWindowState(ResizableWindow);
}
}
if (IsKeyPressed(KeyboardKey.KEY_D))
if (IsKeyPressed(KeyboardKey.D))
{
if (IsWindowState(FLAG_WINDOW_UNDECORATED))
if (IsWindowState(UndecoratedWindow))
{
ClearWindowState(FLAG_WINDOW_UNDECORATED);
ClearWindowState(UndecoratedWindow);
}
else
{
SetWindowState(FLAG_WINDOW_UNDECORATED);
SetWindowState(UndecoratedWindow);
}
}
if (IsKeyPressed(KeyboardKey.KEY_H))
if (IsKeyPressed(KeyboardKey.H))
{
if (!IsWindowState(FLAG_WINDOW_HIDDEN))
if (!IsWindowState(HiddenWindow))
{
SetWindowState(FLAG_WINDOW_HIDDEN);
SetWindowState(HiddenWindow);
}
framesCounter = 0;
}
if (IsWindowState(FLAG_WINDOW_HIDDEN))
if (IsWindowState(HiddenWindow))
{
framesCounter++;
if (framesCounter >= 240)
{
// Show window after 3 seconds
ClearWindowState(FLAG_WINDOW_HIDDEN);
ClearWindowState(HiddenWindow);
}
}
if (IsKeyPressed(KeyboardKey.KEY_N))
if (IsKeyPressed(KeyboardKey.N))
{
if (!IsWindowState(FLAG_WINDOW_MINIMIZED))
if (!IsWindowState(MinimizedWindow))
{
MinimizeWindow();
}
@ -117,7 +117,7 @@ public class WindowFlags
framesCounter = 0;
}
if (IsWindowState(FLAG_WINDOW_MINIMIZED))
if (IsWindowState(MinimizedWindow))
{
framesCounter++;
if (framesCounter >= 240)
@ -127,10 +127,10 @@ public class WindowFlags
}
}
if (IsKeyPressed(KeyboardKey.KEY_M))
if (IsKeyPressed(KeyboardKey.M))
{
// NOTE: Requires FLAG_WINDOW_RESIZABLE enabled!
if (IsWindowState(FLAG_WINDOW_MAXIMIZED))
if (IsWindowState(MaximizedWindow))
{
RestoreWindow();
}
@ -140,51 +140,51 @@ public class WindowFlags
}
}
if (IsKeyPressed(KeyboardKey.KEY_U))
if (IsKeyPressed(KeyboardKey.U))
{
if (IsWindowState(FLAG_WINDOW_UNFOCUSED))
if (IsWindowState(UnfocusedWindow))
{
ClearWindowState(FLAG_WINDOW_UNFOCUSED);
ClearWindowState(UnfocusedWindow);
}
else
{
SetWindowState(FLAG_WINDOW_UNFOCUSED);
SetWindowState(UnfocusedWindow);
}
}
if (IsKeyPressed(KeyboardKey.KEY_T))
if (IsKeyPressed(KeyboardKey.T))
{
if (IsWindowState(FLAG_WINDOW_TOPMOST))
if (IsWindowState(TopmostWindow))
{
ClearWindowState(FLAG_WINDOW_TOPMOST);
ClearWindowState(TopmostWindow);
}
else
{
SetWindowState(FLAG_WINDOW_TOPMOST);
SetWindowState(TopmostWindow);
}
}
if (IsKeyPressed(KeyboardKey.KEY_A))
if (IsKeyPressed(KeyboardKey.A))
{
if (IsWindowState(FLAG_WINDOW_ALWAYS_RUN))
if (IsWindowState(AlwaysRunWindow))
{
ClearWindowState(FLAG_WINDOW_ALWAYS_RUN);
ClearWindowState(AlwaysRunWindow);
}
else
{
SetWindowState(FLAG_WINDOW_ALWAYS_RUN);
SetWindowState(AlwaysRunWindow);
}
}
if (IsKeyPressed(KeyboardKey.KEY_V))
if (IsKeyPressed(KeyboardKey.V))
{
if (IsWindowState(FLAG_VSYNC_HINT))
if (IsWindowState(VSyncHint))
{
ClearWindowState(FLAG_VSYNC_HINT);
ClearWindowState(VSyncHint);
}
else
{
SetWindowState(FLAG_VSYNC_HINT);
SetWindowState(VSyncHint);
}
}
@ -205,46 +205,46 @@ public class WindowFlags
//-----------------------------------------------------
BeginDrawing();
if (IsWindowState(FLAG_WINDOW_TRANSPARENT))
if (IsWindowState(TransparentWindow))
{
ClearBackground(Color.BLANK);
ClearBackground(Color.Blank);
}
else
{
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
}
DrawCircleV(ballPosition, ballRadius, Color.MAROON);
DrawRectangleLinesEx(new Rectangle(0, 0, GetScreenWidth(), GetScreenHeight()), 4, Color.RAYWHITE);
DrawCircleV(ballPosition, ballRadius, Color.Maroon);
DrawRectangleLinesEx(new Rectangle(0, 0, GetScreenWidth(), GetScreenHeight()), 4, Color.RayWhite);
DrawCircleV(GetMousePosition(), 10, Color.DARKBLUE);
DrawCircleV(GetMousePosition(), 10, Color.DarkBlue);
DrawFPS(10, 10);
DrawText($"Screen Size: [{GetScreenWidth()}, {GetScreenHeight()}]", 10, 40, 10, Color.GREEN);
DrawText($"Screen Size: [{GetScreenWidth()}, {GetScreenHeight()}]", 10, 40, 10, Color.Green);
// Draw window state info
Color on = Color.LIME;
Color off = Color.MAROON;
Color on = Color.Lime;
Color off = Color.Maroon;
DrawText("Following flags can be set after window creation:", 10, 60, 10, Color.GRAY);
DrawText("Following flags can be set after window creation:", 10, 60, 10, Color.Gray);
DrawWindowState(FLAG_FULLSCREEN_MODE, "[F] FLAG_FULLSCREEN_MODE: ", 10, 80, 10);
DrawWindowState(FLAG_WINDOW_RESIZABLE, "[R] FLAG_WINDOW_RESIZABLE: ", 10, 100, 10);
DrawWindowState(FLAG_WINDOW_UNDECORATED, "[D] FLAG_WINDOW_UNDECORATED: ", 10, 120, 10);
DrawWindowState(FLAG_WINDOW_HIDDEN, "[H] FLAG_WINDOW_HIDDEN: ", 10, 140, 10);
DrawWindowState(FLAG_WINDOW_MINIMIZED, "[N] FLAG_WINDOW_MINIMIZED: ", 10, 160, 10);
DrawWindowState(FLAG_WINDOW_MAXIMIZED, "[M] FLAG_WINDOW_MAXIMIZED: ", 10, 180, 10);
DrawWindowState(FLAG_WINDOW_UNFOCUSED, "[G] FLAG_WINDOW_UNFOCUSED: ", 10, 200, 10);
DrawWindowState(FLAG_WINDOW_TOPMOST, "[T] FLAG_WINDOW_TOPMOST: ", 10, 220, 10);
DrawWindowState(FLAG_WINDOW_ALWAYS_RUN, "[A] FLAG_WINDOW_ALWAYS_RUN: ", 10, 240, 10);
DrawWindowState(FLAG_VSYNC_HINT, "[V] FLAG_VSYNC_HINT: ", 10, 260, 10);
DrawWindowState(FullscreenMode, "[F] FLAG_FULLSCREEN_MODE: ", 10, 80, 10);
DrawWindowState(ResizableWindow, "[R] FLAG_WINDOW_RESIZABLE: ", 10, 100, 10);
DrawWindowState(UndecoratedWindow, "[D] FLAG_WINDOW_UNDECORATED: ", 10, 120, 10);
DrawWindowState(HiddenWindow, "[H] FLAG_WINDOW_HIDDEN: ", 10, 140, 10);
DrawWindowState(MinimizedWindow, "[N] FLAG_WINDOW_MINIMIZED: ", 10, 160, 10);
DrawWindowState(MaximizedWindow, "[M] FLAG_WINDOW_MAXIMIZED: ", 10, 180, 10);
DrawWindowState(UnfocusedWindow, "[G] FLAG_WINDOW_UNFOCUSED: ", 10, 200, 10);
DrawWindowState(TopmostWindow, "[T] FLAG_WINDOW_TOPMOST: ", 10, 220, 10);
DrawWindowState(AlwaysRunWindow, "[A] FLAG_WINDOW_ALWAYS_RUN: ", 10, 240, 10);
DrawWindowState(VSyncHint, "[V] FLAG_VSYNC_HINT: ", 10, 260, 10);
DrawText("Following flags can only be set before window creation:", 10, 300, 10, Color.GRAY);
DrawText("Following flags can only be set before window creation:", 10, 300, 10, Color.Gray);
DrawWindowState(FLAG_WINDOW_HIGHDPI, "[F] FLAG_WINDOW_HIGHDPI: ", 10, 320, 10);
DrawWindowState(FLAG_WINDOW_TRANSPARENT, "[F] FLAG_WINDOW_TRANSPARENT: ", 10, 340, 10);
DrawWindowState(FLAG_MSAA_4X_HINT, "[F] FLAG_MSAA_4X_HINT: ", 10, 360, 10);
DrawWindowState(HighDpiWindow, "[F] FLAG_WINDOW_HIGHDPI: ", 10, 320, 10);
DrawWindowState(TransparentWindow, "[F] FLAG_WINDOW_TRANSPARENT: ", 10, 340, 10);
DrawWindowState(Msaa4xHint, "[F] FLAG_MSAA_4X_HINT: ", 10, 360, 10);
EndDrawing();
//-----------------------------------------------------
@ -260,8 +260,8 @@ public class WindowFlags
static void DrawWindowState(ConfigFlags flag, string text, int posX, int posY, int fontSize)
{
Color onColor = Color.LIME;
Color offColor = Color.MAROON;
Color onColor = Color.Lime;
Color offColor = Color.Maroon;
if (Raylib.IsWindowState(flag))
{

View File

@ -25,7 +25,7 @@ public class WindowLetterbox
const int windowHeight = 450;
// Enable config flags for resizable window and vertical synchro
SetConfigFlags(ConfigFlags.FLAG_WINDOW_RESIZABLE | ConfigFlags.FLAG_VSYNC_HINT);
SetConfigFlags(ConfigFlags.ResizableWindow | ConfigFlags.VSyncHint);
InitWindow(windowWidth, windowHeight, "raylib [core] example - window scale letterbox");
SetWindowMinSize(320, 240);
@ -34,7 +34,7 @@ public class WindowLetterbox
// Render texture initialization, used to hold the rendering result so we can easily resize it
RenderTexture2D target = LoadRenderTexture(gameScreenWidth, gameScreenHeight);
SetTextureFilter(target.Texture, TextureFilter.TEXTURE_FILTER_BILINEAR);
SetTextureFilter(target.Texture, TextureFilter.Bilinear);
Color[] colors = new Color[10];
for (int i = 0; i < 10; i++)
@ -56,7 +56,7 @@ public class WindowLetterbox
(float)GetScreenHeight() / gameScreenHeight
);
if (IsKeyPressed(KeyboardKey.KEY_SPACE))
if (IsKeyPressed(KeyboardKey.Space))
{
// Recalculate random colors for the bars
for (int i = 0; i < 10; i++)
@ -83,11 +83,11 @@ public class WindowLetterbox
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.BLACK);
ClearBackground(Color.Black);
// Draw everything in the render texture, note this will not be rendered on screen, yet
BeginTextureMode(target);
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
for (int i = 0; i < 10; i++)
{
@ -99,11 +99,11 @@ public class WindowLetterbox
10,
25,
20,
Color.WHITE
Color.White
);
DrawText($"Default Mouse: [{(int)mouse.X} {(int)mouse.Y}]", 350, 25, 20, Color.GREEN);
DrawText($"Virtual Mouse: [{(int)virtualMouse.X}, {(int)virtualMouse.Y}]", 350, 55, 20, Color.YELLOW);
DrawText($"Default Mouse: [{(int)mouse.X} {(int)mouse.Y}]", 350, 25, 20, Color.Green);
DrawText($"Virtual Mouse: [{(int)virtualMouse.X}, {(int)virtualMouse.Y}]", 350, 55, 20, Color.Yellow);
EndTextureMode();
@ -120,7 +120,7 @@ public class WindowLetterbox
(float)gameScreenWidth * scale,
(float)gameScreenHeight * scale
);
DrawTexturePro(target.Texture, sourceRec, destRec, new Vector2(0, 0), 0.0f, Color.WHITE);
DrawTexturePro(target.Texture, sourceRec, destRec, new Vector2(0, 0), 0.0f, Color.White);
EndDrawing();
//--------------------------------------------------------------------------------------

View File

@ -31,7 +31,7 @@ public class WorldScreen
camera.Target = new Vector3(0.0f, 0.0f, 0.0f);
camera.Up = new Vector3(0.0f, 1.0f, 0.0f);
camera.FovY = 45.0f;
camera.Projection = CameraProjection.CAMERA_PERSPECTIVE;
camera.Projection = CameraProjection.Perspective;
Vector3 cubePosition = new(0.0f, 0.0f, 0.0f);
Vector2 cubeScreenPosition;
@ -44,7 +44,7 @@ public class WorldScreen
{
// Update
//----------------------------------------------------------------------------------
UpdateCamera(ref camera, CameraMode.CAMERA_FREE);
UpdateCamera(ref camera, CameraMode.Free);
// Calculate cube screen space position (with a little offset to be in top)
cubeScreenPosition = GetWorldToScreen(
@ -56,12 +56,12 @@ public class WorldScreen
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
BeginMode3D(camera);
DrawCube(cubePosition, 2.0f, 2.0f, 2.0f, Color.RED);
DrawCubeWires(cubePosition, 2.0f, 2.0f, 2.0f, Color.MAROON);
DrawCube(cubePosition, 2.0f, 2.0f, 2.0f, Color.Red);
DrawCubeWires(cubePosition, 2.0f, 2.0f, 2.0f, Color.Maroon);
DrawGrid(10, 1.0f);
@ -72,14 +72,14 @@ public class WorldScreen
(int)cubeScreenPosition.X - MeasureText("Enemy: 100 / 100", 20) / 2,
(int)cubeScreenPosition.Y,
20,
Color.BLACK
Color.Black
);
DrawText(
"Text is always on top of the cube",
(screenWidth - MeasureText("Text is always on top of the cube", 20)) / 2,
25,
20,
Color.GRAY
Color.Gray
);
EndDrawing();