Watch
3
0
Fork
You've already forked raylib-cs
0

Initial example update

- Updating examples with new changes.
This commit is contained in:
ChrisDill 2019-02-11 11:30:02 +00:00
commit b841a28177
45 changed files with 419 additions and 389 deletions

View file

@ -34,7 +34,7 @@ public partial class audio_module_playing
int screenWidth = 800; int screenWidth = 800;
int screenHeight = 450; int screenHeight = 450;
SetConfigFlags(FLAG_MSAA_4X_HINT); // NOTE: Try to enable MSAA 4X SetConfigFlags(ConfigFlag.FLAG_MSAA_4X_HINT); // NOTE: Try to enable MSAA 4X
InitWindow(screenWidth, screenHeight, "raylib [audio] example - module playing (streaming)"); InitWindow(screenWidth, screenHeight, "raylib [audio] example - module playing (streaming)");
@ -74,14 +74,14 @@ public partial class audio_module_playing
UpdateMusicStream(xm); // Update music buffer with new stream data UpdateMusicStream(xm); // Update music buffer with new stream data
// Restart music playing (stop and play) // Restart music playing (stop and play)
if (IsKeyPressed(KEY_SPACE)) if (IsKeyPressed(KeyboardKey.KEY_SPACE))
{ {
StopMusicStream(xm); StopMusicStream(xm);
PlayMusicStream(xm); PlayMusicStream(xm);
} }
// Pause/Resume music playing // Pause/Resume music playing
if (IsKeyPressed(KEY_P)) if (IsKeyPressed(KeyboardKey.KEY_P))
{ {
pause = !pause; pause = !pause;

View file

@ -46,14 +46,14 @@ public partial class audio_music_stream
UpdateMusicStream(music); // Update music buffer with new stream data UpdateMusicStream(music); // Update music buffer with new stream data
// Restart music playing (stop and play) // Restart music playing (stop and play)
if (IsKeyPressed(KEY_SPACE)) if (IsKeyPressed(KeyboardKey.KEY_SPACE))
{ {
StopMusicStream(music); StopMusicStream(music);
PlayMusicStream(music); PlayMusicStream(music);
} }
// Pause/Resume music playing // Pause/Resume music playing
if (IsKeyPressed(KEY_P)) if (IsKeyPressed(KeyboardKey.KEY_P))
{ {
pause = !pause; pause = !pause;

View file

@ -39,8 +39,8 @@ public partial class audio_sound_loading
{ {
// Update // Update
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
if (IsKeyPressed(KEY_SPACE)) PlaySound(fxWav); // Play WAV sound if (IsKeyPressed(KeyboardKey.KEY_SPACE)) PlaySound(fxWav); // Play WAV sound
if (IsKeyPressed(KEY_ENTER)) PlaySound(fxOgg); // Play OGG sound if (IsKeyPressed(KeyboardKey.KEY_ENTER)) PlaySound(fxOgg); // Play OGG sound
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Draw // Draw

View file

@ -58,12 +58,12 @@ public partial class core_2d_camera
{ {
// Update // Update
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
if (IsKeyDown(KEY_RIGHT)) if (IsKeyDown(KeyboardKey.KEY_RIGHT))
{ {
player.x += 2; // Player movement player.x += 2; // Player movement
camera.offset.x -= 2; // Camera3D displacement with player movement camera.offset.x -= 2; // Camera3D displacement with player movement
} }
else if (IsKeyDown(KEY_LEFT)) else if (IsKeyDown(KeyboardKey.KEY_LEFT))
{ {
player.x -= 2; // Player movement player.x -= 2; // Player movement
camera.offset.x += 2; // Camera3D displacement with player movement camera.offset.x += 2; // Camera3D displacement with player movement
@ -73,8 +73,8 @@ public partial class core_2d_camera
camera.target = new Vector2( player.x + 20, player.y + 20 ); camera.target = new Vector2( player.x + 20, player.y + 20 );
// Camera3D rotation controls // Camera3D rotation controls
if (IsKeyDown(KEY_A)) camera.rotation--; if (IsKeyDown(KeyboardKey.KEY_A)) camera.rotation--;
else if (IsKeyDown(KEY_S)) camera.rotation++; else if (IsKeyDown(KeyboardKey.KEY_S)) camera.rotation++;
// Limit camera rotation to 80 degrees (-40 to 40) // Limit camera rotation to 80 degrees (-40 to 40)
if (camera.rotation > 40) camera.rotation = 40; if (camera.rotation > 40) camera.rotation = 40;
@ -87,7 +87,7 @@ public partial class core_2d_camera
else if (camera.zoom < 0.1f) camera.zoom = 0.1f; else if (camera.zoom < 0.1f) camera.zoom = 0.1f;
// Camera3D reset (zoom and rotation) // Camera3D reset (zoom and rotation)
if (IsKeyPressed((int)KEY_R)) if (IsKeyPressed(KeyboardKey.KEY_R))
{ {
camera.zoom = 1.0f; camera.zoom = 1.0f;
camera.rotation = 0.0f; camera.rotation = 0.0f;

View file

@ -48,7 +48,7 @@ public partial class core_3d_camera_first_person
colors[i] = new Color( GetRandomValue(20, 255), GetRandomValue(10, 55), 30, 255 ); colors[i] = new Color( GetRandomValue(20, 255), GetRandomValue(10, 55), 30, 255 );
} }
SetCameraMode(camera, (int)CAMERA_FIRST_PERSON); // Set a first person camera mode SetCameraMode(camera, CameraMode.CAMERA_FIRST_PERSON); // Set a first person camera mode
SetTargetFPS(60); // Set our game to run at 60 frames-per-second SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------

View file

@ -36,7 +36,7 @@ public partial class core_3d_camera_free
Vector3 cubePosition = new Vector3( 0.0f, 0.0f, 0.0f ); Vector3 cubePosition = new Vector3( 0.0f, 0.0f, 0.0f );
SetCameraMode(camera, (int)CAMERA_FREE); // Set a free camera mode SetCameraMode(camera, CameraMode.CAMERA_FREE); // Set a free camera mode
SetTargetFPS(60); // Set our game to run at 60 frames-per-second SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
@ -48,7 +48,7 @@ public partial class core_3d_camera_free
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
UpdateCamera(ref camera); // Update camera UpdateCamera(ref camera); // Update camera
if (IsKeyDown('Z')) camera.target = new Vector3( 0.0f, 0.0f, 0.0f ); if (IsKeyDown(KeyboardKey.KEY_Z)) camera.target = new Vector3( 0.0f, 0.0f, 0.0f );
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Draw // Draw

View file

@ -41,7 +41,7 @@ public partial class core_3d_picking
bool collision = false; bool collision = false;
SetCameraMode(camera, (int)CAMERA_FREE); // Set a free camera mode SetCameraMode(camera, CameraMode.CAMERA_FREE); // Set a free camera mode
SetTargetFPS(60); // Set our game to run at 60 frames-per-second SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
@ -53,7 +53,7 @@ public partial class core_3d_picking
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
UpdateCamera(ref camera); // Update camera UpdateCamera(ref camera); // Update camera
if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) if (IsMouseButtonPressed(MouseButton.MOUSE_LEFT_BUTTON))
{ {
ray = GetMouseRay(GetMousePosition(), camera); ray = GetMouseRay(GetMousePosition(), camera);

View file

@ -59,7 +59,7 @@ public partial class core_color_select
{ {
colors[i].a = 120; colors[i].a = 120;
if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) selected[i] = !selected[i]; if (IsMouseButtonPressed(MouseButton.MOUSE_LEFT_BUTTON)) selected[i] = !selected[i];
} }
else colors[i].a = 255; else colors[i].a = 255;
} }

View file

@ -1,6 +1,10 @@
using Raylib; using Raylib;
using static Raylib.Raylib; using static Raylib.Raylib;
// using static Raylib.Gamepad; using static Raylib.GamepadNumber;
using static Raylib.GamepadPS3Axis;
using static Raylib.GamepadPS3Button;
using static Raylib.GamepadXbox360Axis;
using static Raylib.GamepadXbox360Button;
public partial class core_input_gamepad public partial class core_input_gamepad
{ {
@ -35,7 +39,7 @@ public partial class core_input_gamepad
int screenWidth = 800; int screenWidth = 800;
int screenHeight = 450; int screenHeight = 450;
SetConfigFlags(FLAG_MSAA_4X_HINT); // Set MSAA 4X hint before windows creation SetConfigFlags(ConfigFlag.FLAG_MSAA_4X_HINT); // Set MSAA 4X hint before windows creation
InitWindow(screenWidth, screenHeight, "raylib [core] example - gamepad input"); InitWindow(screenWidth, screenHeight, "raylib [core] example - gamepad input");
@ -68,45 +72,45 @@ public partial class core_input_gamepad
DrawTexture(texXboxPad, 0, 0, DARKGRAY); DrawTexture(texXboxPad, 0, 0, DARKGRAY);
// Draw buttons: xbox home // Draw buttons: xbox home
if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_XBOX_BUTTON_HOME)) DrawCircle(394, 89, 19, RED); if (IsGamepadButtonDown(GAMEPAD_PLAYER1, (int)GAMEPAD_XBOX_BUTTON_HOME)) DrawCircle(394, 89, 19, RED);
// Draw buttons: basic // Draw buttons: basic
if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_XBOX_BUTTON_START)) DrawCircle(436, 150, 9, RED); if (IsGamepadButtonDown(GAMEPAD_PLAYER1, (int)GAMEPAD_XBOX_BUTTON_START)) DrawCircle(436, 150, 9, RED);
if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_XBOX_BUTTON_SELECT)) DrawCircle(352, 150, 9, RED); if (IsGamepadButtonDown(GAMEPAD_PLAYER1, (int)GAMEPAD_XBOX_BUTTON_SELECT)) DrawCircle(352, 150, 9, RED);
if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_XBOX_BUTTON_X)) DrawCircle(501, 151, 15, BLUE); if (IsGamepadButtonDown(GAMEPAD_PLAYER1, (int)GAMEPAD_XBOX_BUTTON_X)) DrawCircle(501, 151, 15, BLUE);
if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_XBOX_BUTTON_A)) DrawCircle(536, 187, 15, LIME); if (IsGamepadButtonDown(GAMEPAD_PLAYER1, (int)GAMEPAD_XBOX_BUTTON_A)) DrawCircle(536, 187, 15, LIME);
if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_XBOX_BUTTON_B)) DrawCircle(572, 151, 15, MAROON); if (IsGamepadButtonDown(GAMEPAD_PLAYER1, (int)GAMEPAD_XBOX_BUTTON_B)) DrawCircle(572, 151, 15, MAROON);
if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_XBOX_BUTTON_Y)) DrawCircle(536, 115, 15, GOLD); if (IsGamepadButtonDown(GAMEPAD_PLAYER1, (int)GAMEPAD_XBOX_BUTTON_Y)) DrawCircle(536, 115, 15, GOLD);
// Draw buttons: d-pad // Draw buttons: d-pad
DrawRectangle(317, 202, 19, 71, BLACK); DrawRectangle(317, 202, 19, 71, BLACK);
DrawRectangle(293, 228, 69, 19, BLACK); DrawRectangle(293, 228, 69, 19, BLACK);
if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_XBOX_BUTTON_UP)) DrawRectangle(317, 202, 19, 26, RED); if (IsGamepadButtonDown(GAMEPAD_PLAYER1, (int)GAMEPAD_XBOX_BUTTON_UP)) DrawRectangle(317, 202, 19, 26, RED);
if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_XBOX_BUTTON_DOWN)) DrawRectangle(317, 202 + 45, 19, 26, RED); if (IsGamepadButtonDown(GAMEPAD_PLAYER1, (int)GAMEPAD_XBOX_BUTTON_DOWN)) DrawRectangle(317, 202 + 45, 19, 26, RED);
if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_XBOX_BUTTON_LEFT)) DrawRectangle(292, 228, 25, 19, RED); if (IsGamepadButtonDown(GAMEPAD_PLAYER1, (int)GAMEPAD_XBOX_BUTTON_LEFT)) DrawRectangle(292, 228, 25, 19, RED);
if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_XBOX_BUTTON_RIGHT)) DrawRectangle(292 + 44, 228, 26, 19, RED); if (IsGamepadButtonDown(GAMEPAD_PLAYER1, (int)GAMEPAD_XBOX_BUTTON_RIGHT)) DrawRectangle(292 + 44, 228, 26, 19, RED);
// Draw buttons: left-right back // Draw buttons: left-right back
if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_XBOX_BUTTON_LB)) DrawCircle(259, 61, 20, RED); if (IsGamepadButtonDown(GAMEPAD_PLAYER1, (int)GAMEPAD_XBOX_BUTTON_LB)) DrawCircle(259, 61, 20, RED);
if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_XBOX_BUTTON_RB)) DrawCircle(536, 61, 20, RED); if (IsGamepadButtonDown(GAMEPAD_PLAYER1, (int)GAMEPAD_XBOX_BUTTON_RB)) DrawCircle(536, 61, 20, RED);
// Draw axis: left joystick // Draw axis: left joystick
DrawCircle(259, 152, 39, BLACK); DrawCircle(259, 152, 39, BLACK);
DrawCircle(259, 152, 34, LIGHTGRAY); DrawCircle(259, 152, 34, LIGHTGRAY);
DrawCircle(259 + (int)(GetGamepadAxisMovement(GAMEPAD_PLAYER1, GAMEPAD_XBOX_AXIS_LEFT_X) * 20), DrawCircle(259 + (int)(GetGamepadAxisMovement(GAMEPAD_PLAYER1, (int)GAMEPAD_XBOX_AXIS_LEFT_X) * 20),
152 - (int)(GetGamepadAxisMovement(GAMEPAD_PLAYER1, GAMEPAD_XBOX_AXIS_LEFT_Y) * 20), 25, BLACK); 152 - (int)(GetGamepadAxisMovement(GAMEPAD_PLAYER1, (int)GAMEPAD_XBOX_AXIS_LEFT_Y) * 20), 25, BLACK);
// Draw axis: right joystick // Draw axis: right joystick
DrawCircle(461, 237, 38, BLACK); DrawCircle(461, 237, 38, BLACK);
DrawCircle(461, 237, 33, LIGHTGRAY); DrawCircle(461, 237, 33, LIGHTGRAY);
DrawCircle(461 + (int)(GetGamepadAxisMovement(GAMEPAD_PLAYER1, GAMEPAD_XBOX_AXIS_RIGHT_X) * 20), DrawCircle(461 + (int)(GetGamepadAxisMovement(GAMEPAD_PLAYER1, (int)GAMEPAD_XBOX_AXIS_RIGHT_X) * 20),
237 - (int)(GetGamepadAxisMovement(GAMEPAD_PLAYER1, GAMEPAD_XBOX_AXIS_RIGHT_Y) * 20), 25, BLACK); 237 - (int)(GetGamepadAxisMovement(GAMEPAD_PLAYER1, (int)GAMEPAD_XBOX_AXIS_RIGHT_Y) * 20), 25, BLACK);
// Draw axis: left-right triggers // Draw axis: left-right triggers
DrawRectangle(170, 30, 15, 70, GRAY); DrawRectangle(170, 30, 15, 70, GRAY);
DrawRectangle(604, 30, 15, 70, GRAY); DrawRectangle(604, 30, 15, 70, GRAY);
DrawRectangle(170, 30, 15, (int)(((1.0f + GetGamepadAxisMovement(GAMEPAD_PLAYER1, GAMEPAD_XBOX_AXIS_LT)) / 2.0f) * 70), RED); DrawRectangle(170, 30, 15, (int)(((1.0f + GetGamepadAxisMovement(GAMEPAD_PLAYER1, (int)GAMEPAD_XBOX_AXIS_LT)) / 2.0f) * 70), RED);
DrawRectangle(604, 30, 15, (int)(((1.0f + GetGamepadAxisMovement(GAMEPAD_PLAYER1, GAMEPAD_XBOX_AXIS_RT)) / 2.0f) * 70), RED); DrawRectangle(604, 30, 15, (int)(((1.0f + GetGamepadAxisMovement(GAMEPAD_PLAYER1, (int)GAMEPAD_XBOX_AXIS_RT)) / 2.0f) * 70), RED);
//DrawText(string.Format("Xbox axis LT: {0:00.00}", GetGamepadAxisMovement(GAMEPAD_PLAYER1, GAMEPAD_XBOX_AXIS_LT)), 10, 40, 10, BLACK); //DrawText(string.Format("Xbox axis LT: {0:00.00}", GetGamepadAxisMovement(GAMEPAD_PLAYER1, GAMEPAD_XBOX_AXIS_LT)), 10, 40, 10, BLACK);
//DrawText(string.Format("Xbox axis RT: {0:00.00}", GetGamepadAxisMovement(GAMEPAD_PLAYER1, GAMEPAD_XBOX_AXIS_RT)), 10, 60, 10, BLACK); //DrawText(string.Format("Xbox axis RT: {0:00.00}", GetGamepadAxisMovement(GAMEPAD_PLAYER1, GAMEPAD_XBOX_AXIS_RT)), 10, 60, 10, BLACK);
@ -116,46 +120,46 @@ public partial class core_input_gamepad
DrawTexture(texPs3Pad, 0, 0, DARKGRAY); DrawTexture(texPs3Pad, 0, 0, DARKGRAY);
// Draw buttons: ps // Draw buttons: ps
if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_PS3_BUTTON_PS)) DrawCircle(396, 222, 13, RED); if (IsGamepadButtonDown(GAMEPAD_PLAYER1, (int)GAMEPAD_PS3_BUTTON_PS)) DrawCircle(396, 222, 13, RED);
// Draw buttons: basic // Draw buttons: basic
if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_PS3_BUTTON_SELECT)) DrawRectangle(328, 170, 32, 13, RED); if (IsGamepadButtonDown(GAMEPAD_PLAYER1, (int)GAMEPAD_PS3_BUTTON_SELECT)) DrawRectangle(328, 170, 32, 13, RED);
if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_PS3_BUTTON_START)) DrawTriangle(new Vector2(436, 168), new Vector2(436, 185), new Vector2( if (IsGamepadButtonDown(GAMEPAD_PLAYER1, (int)GAMEPAD_PS3_BUTTON_START)) DrawTriangle(new Vector2(436, 168), new Vector2(436, 185), new Vector2(
464, 177 ), RED); 464, 177 ), RED);
if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_PS3_BUTTON_TRIANGLE)) DrawCircle(557, 144, 13, LIME); if (IsGamepadButtonDown(GAMEPAD_PLAYER1, (int)GAMEPAD_PS3_BUTTON_TRIANGLE)) DrawCircle(557, 144, 13, LIME);
if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_PS3_BUTTON_CIRCLE)) DrawCircle(586, 173, 13, RED); if (IsGamepadButtonDown(GAMEPAD_PLAYER1, (int)GAMEPAD_PS3_BUTTON_CIRCLE)) DrawCircle(586, 173, 13, RED);
if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_PS3_BUTTON_CROSS)) DrawCircle(557, 203, 13, VIOLET); if (IsGamepadButtonDown(GAMEPAD_PLAYER1, (int)GAMEPAD_PS3_BUTTON_CROSS)) DrawCircle(557, 203, 13, VIOLET);
if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_PS3_BUTTON_SQUARE)) DrawCircle(527, 173, 13, PINK); if (IsGamepadButtonDown(GAMEPAD_PLAYER1, (int)GAMEPAD_PS3_BUTTON_SQUARE)) DrawCircle(527, 173, 13, PINK);
// Draw buttons: d-pad // Draw buttons: d-pad
DrawRectangle(225, 132, 24, 84, BLACK); DrawRectangle(225, 132, 24, 84, BLACK);
DrawRectangle(195, 161, 84, 25, BLACK); DrawRectangle(195, 161, 84, 25, BLACK);
if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_PS3_BUTTON_UP)) DrawRectangle(225, 132, 24, 29, RED); if (IsGamepadButtonDown(GAMEPAD_PLAYER1, (int)GAMEPAD_PS3_BUTTON_UP)) DrawRectangle(225, 132, 24, 29, RED);
if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_PS3_BUTTON_DOWN)) DrawRectangle(225, 132 + 54, 24, 30, RED); if (IsGamepadButtonDown(GAMEPAD_PLAYER1, (int)GAMEPAD_PS3_BUTTON_DOWN)) DrawRectangle(225, 132 + 54, 24, 30, RED);
if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_PS3_BUTTON_LEFT)) DrawRectangle(195, 161, 30, 25, RED); if (IsGamepadButtonDown(GAMEPAD_PLAYER1, (int)GAMEPAD_PS3_BUTTON_LEFT)) DrawRectangle(195, 161, 30, 25, RED);
if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_PS3_BUTTON_RIGHT)) DrawRectangle(195 + 54, 161, 30, 25, RED); if (IsGamepadButtonDown(GAMEPAD_PLAYER1, (int)GAMEPAD_PS3_BUTTON_RIGHT)) DrawRectangle(195 + 54, 161, 30, 25, RED);
// Draw buttons: left-right back buttons // Draw buttons: left-right back buttons
if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_PS3_BUTTON_L1)) DrawCircle(239, 82, 20, RED); if (IsGamepadButtonDown(GAMEPAD_PLAYER1, (int)GAMEPAD_PS3_BUTTON_L1)) DrawCircle(239, 82, 20, RED);
if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_PS3_BUTTON_R1)) DrawCircle(557, 82, 20, RED); if (IsGamepadButtonDown(GAMEPAD_PLAYER1, (int)GAMEPAD_PS3_BUTTON_R1)) DrawCircle(557, 82, 20, RED);
// Draw axis: left joystick // Draw axis: left joystick
DrawCircle(319, 255, 35, BLACK); DrawCircle(319, 255, 35, BLACK);
DrawCircle(319, 255, 31, LIGHTGRAY); DrawCircle(319, 255, 31, LIGHTGRAY);
DrawCircle(319 + (int)(GetGamepadAxisMovement(GAMEPAD_PLAYER1, GAMEPAD_PS3_AXIS_LEFT_X) * 20), DrawCircle(319 + (int)(GetGamepadAxisMovement(GAMEPAD_PLAYER1, (int)GAMEPAD_PS3_AXIS_LEFT_X) * 20),
255 + (int)(GetGamepadAxisMovement(GAMEPAD_PLAYER1, GAMEPAD_PS3_AXIS_LEFT_Y) * 20), 25, BLACK); 255 + (int)(GetGamepadAxisMovement(GAMEPAD_PLAYER1, (int)GAMEPAD_PS3_AXIS_LEFT_Y) * 20), 25, BLACK);
// Draw axis: right joystick // Draw axis: right joystick
DrawCircle(475, 255, 35, BLACK); DrawCircle(475, 255, 35, BLACK);
DrawCircle(475, 255, 31, LIGHTGRAY); DrawCircle(475, 255, 31, LIGHTGRAY);
DrawCircle(475 + (int)(GetGamepadAxisMovement(GAMEPAD_PLAYER1, GAMEPAD_PS3_AXIS_RIGHT_X) * 20), DrawCircle(475 + (int)(GetGamepadAxisMovement(GAMEPAD_PLAYER1, (int)GAMEPAD_PS3_AXIS_RIGHT_X) * 20),
255 + (int)(GetGamepadAxisMovement(GAMEPAD_PLAYER1, GAMEPAD_PS3_AXIS_RIGHT_Y) * 20), 25, BLACK); 255 + (int)(GetGamepadAxisMovement(GAMEPAD_PLAYER1, (int)GAMEPAD_PS3_AXIS_RIGHT_Y) * 20), 25, BLACK);
// Draw axis: left-right triggers // Draw axis: left-right triggers
DrawRectangle(169, 48, 15, 70, GRAY); DrawRectangle(169, 48, 15, 70, GRAY);
DrawRectangle(611, 48, 15, 70, GRAY); DrawRectangle(611, 48, 15, 70, GRAY);
DrawRectangle(169, 48, 15, (int)(((1.0f - GetGamepadAxisMovement(GAMEPAD_PLAYER1, GAMEPAD_PS3_AXIS_L2)) / 2.0f) * 70), RED); DrawRectangle(169, 48, 15, (int)(((1.0f - GetGamepadAxisMovement(GAMEPAD_PLAYER1, (int)GAMEPAD_PS3_AXIS_L2)) / 2.0f) * 70), RED);
DrawRectangle(611, 48, 15, (int)(((1.0f - GetGamepadAxisMovement(GAMEPAD_PLAYER1, GAMEPAD_PS3_AXIS_R2)) / 2.0f) * 70), RED); DrawRectangle(611, 48, 15, (int)(((1.0f - GetGamepadAxisMovement(GAMEPAD_PLAYER1, (int)GAMEPAD_PS3_AXIS_R2)) / 2.0f) * 70), RED);
} }
else else
{ {

View file

@ -34,10 +34,10 @@ public partial class core_input_keys
{ {
// Update // Update
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
if (IsKeyDown(KEY_RIGHT)) ballPosition.x += 2.0f; if (IsKeyDown(KeyboardKey.KEY_RIGHT)) ballPosition.x += 2.0f;
if (IsKeyDown(KEY_LEFT)) ballPosition.x -= 2.0f; if (IsKeyDown(KeyboardKey.KEY_LEFT)) ballPosition.x -= 2.0f;
if (IsKeyDown(KEY_UP)) ballPosition.y -= 2.0f; if (IsKeyDown(KeyboardKey.KEY_UP)) ballPosition.y -= 2.0f;
if (IsKeyDown(KEY_DOWN)) ballPosition.y += 2.0f; if (IsKeyDown(KeyboardKey.KEY_DOWN)) ballPosition.y += 2.0f;
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Draw // Draw

View file

@ -37,9 +37,9 @@ public partial class core_input_mouse
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
ballPosition = GetMousePosition(); ballPosition = GetMousePosition();
if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) ballColor = MAROON; if (IsMouseButtonPressed(MouseButton.MOUSE_LEFT_BUTTON)) ballColor = MAROON;
else if (IsMouseButtonPressed(MOUSE_MIDDLE_BUTTON)) ballColor = LIME; else if (IsMouseButtonPressed(MouseButton.MOUSE_MIDDLE_BUTTON)) ballColor = LIME;
else if (IsMouseButtonPressed(MOUSE_RIGHT_BUTTON)) ballColor = DARKBLUE; else if (IsMouseButtonPressed(MouseButton.MOUSE_RIGHT_BUTTON)) ballColor = DARKBLUE;
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Draw // Draw

View file

@ -39,18 +39,18 @@ public partial class core_storage_values
{ {
// Update // Update
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
if (IsKeyPressed(KEY_R)) if (IsKeyPressed(KeyboardKey.KEY_R))
{ {
score = GetRandomValue(1000, 2000); score = GetRandomValue(1000, 2000);
hiscore = GetRandomValue(2000, 4000); hiscore = GetRandomValue(2000, 4000);
} }
if (IsKeyPressed(KEY_ENTER)) if (IsKeyPressed(KeyboardKey.KEY_ENTER))
{ {
StorageSaveValue((int)StorageData.STORAGE_SCORE, score); StorageSaveValue((int)StorageData.STORAGE_SCORE, score);
StorageSaveValue((int)StorageData.STORAGE_HISCORE, hiscore); StorageSaveValue((int)StorageData.STORAGE_HISCORE, hiscore);
} }
else if (IsKeyPressed(KEY_SPACE)) else if (IsKeyPressed(KeyboardKey.KEY_SPACE))
{ {
// NOTE: If requested position could not be found, value 0 is returned // NOTE: If requested position could not be found, value 0 is returned
score = StorageLoadValue((int)StorageData.STORAGE_SCORE); score = StorageLoadValue((int)StorageData.STORAGE_SCORE);

View file

@ -29,7 +29,7 @@ public partial class core_vr_simulator
InitWindow(screenWidth, screenHeight, "raylib [core] example - vr simulator"); InitWindow(screenWidth, screenHeight, "raylib [core] example - vr simulator");
// Init VR simulator (Oculus Rift CV1 parameters) // Init VR simulator (Oculus Rift CV1 parameters)
InitVrSimulator(GetVrDeviceInfo((int)HMD_OCULUS_RIFT_CV1)); InitVrSimulator(GetVrDeviceInfo(HMD_OCULUS_RIFT_CV1));
// Define the camera to look into our 3d world // Define the camera to look into our 3d world
Camera3D camera; Camera3D camera;
@ -41,7 +41,7 @@ public partial class core_vr_simulator
Vector3 cubePosition = new Vector3( 0.0f, 0.0f, 0.0f ); Vector3 cubePosition = new Vector3( 0.0f, 0.0f, 0.0f );
SetCameraMode(camera, (int)CAMERA_FIRST_PERSON); // Set first person camera mode SetCameraMode(camera, CameraMode.CAMERA_FIRST_PERSON); // Set first person camera mode
SetTargetFPS(90); // Set our game to run at 90 frames-per-second SetTargetFPS(90); // Set our game to run at 90 frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
@ -53,7 +53,7 @@ public partial class core_vr_simulator
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
UpdateCamera(ref camera); // Update camera (simulator mode) UpdateCamera(ref camera); // Update camera (simulator mode)
if (IsKeyPressed(KEY_SPACE)) ToggleVrMode(); // Toggle VR mode if (IsKeyPressed(KeyboardKey.KEY_SPACE)) ToggleVrMode(); // Toggle VR mode
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Draw // Draw

View file

@ -38,7 +38,7 @@ public partial class core_world_screen
Vector2 cubeScreenPosition; Vector2 cubeScreenPosition;
SetCameraMode(camera, (int)CAMERA_FREE); // Set a free camera mode SetCameraMode(camera, CameraMode.CAMERA_FREE); // Set a free camera mode
SetTargetFPS(60); // Set our game to run at 60 frames-per-second SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------

View file

@ -37,7 +37,7 @@ public partial class models_billboard
Texture2D bill = LoadTexture("resources/billboard.png"); // Our texture billboard Texture2D bill = LoadTexture("resources/billboard.png"); // Our texture billboard
Vector3 billPosition = new Vector3( 0.0f, 2.0f, 0.0f ); // Position where draw billboard Vector3 billPosition = new Vector3( 0.0f, 2.0f, 0.0f ); // Position where draw billboard
SetCameraMode(camera, (int)CAMERA_ORBITAL); // Set an orbital camera mode SetCameraMode(camera, CameraMode.CAMERA_ORBITAL); // Set an orbital camera mode
SetTargetFPS(60); // Set our game to run at 60 frames-per-second SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------

View file

@ -49,10 +49,10 @@ public partial class models_box_collisions
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Move player // Move player
if (IsKeyDown(KEY_RIGHT)) playerPosition.x += 0.2f; if (IsKeyDown(KeyboardKey.KEY_RIGHT)) playerPosition.x += 0.2f;
else if (IsKeyDown(KEY_LEFT)) playerPosition.x -= 0.2f; else if (IsKeyDown(KeyboardKey.KEY_LEFT)) playerPosition.x -= 0.2f;
else if (IsKeyDown(KEY_DOWN)) playerPosition.z += 0.2f; else if (IsKeyDown(KeyboardKey.KEY_DOWN)) playerPosition.z += 0.2f;
else if (IsKeyDown(KEY_UP)) playerPosition.z -= 0.2f; else if (IsKeyDown(KeyboardKey.KEY_UP)) playerPosition.z -= 0.2f;
collision = false; collision = false;

View file

@ -43,7 +43,7 @@ public partial class models_cubicmap
UnloadImage(image); // Unload cubesmap image from RAM, already uploaded to VRAM UnloadImage(image); // Unload cubesmap image from RAM, already uploaded to VRAM
SetCameraMode(camera, (int)CAMERA_ORBITAL); // Set an orbital camera mode SetCameraMode(camera, CameraMode.CAMERA_ORBITAL); // Set an orbital camera mode
SetTargetFPS(60); // Set our game to run at 60 frames-per-second SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------

View file

@ -40,7 +40,7 @@ public partial class models_heightmap
UnloadImage(image); // Unload heightmap image from RAM, already uploaded to VRAM UnloadImage(image); // Unload heightmap image from RAM, already uploaded to VRAM
SetCameraMode(camera, (int)CAMERA_ORBITAL); // Set an orbital camera mode SetCameraMode(camera, CameraMode.CAMERA_ORBITAL); // Set an orbital camera mode
SetTargetFPS(60); // Set our game to run at 60 frames-per-second SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------

View file

@ -25,7 +25,16 @@ public struct Light
public partial class models_material_pbr public partial class models_material_pbr
{ {
/******************************************************************************************* * * raylib [models] example - PBR material * * This example has been created using raylib 1.8 (www.raylib.com) * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) * * Copyright (c) 2017 Ramon Santamaria (@raysan5) * ********************************************************************************************/ /*******************************************************************************************
*
* raylib [models] example - PBR material
*
* This example has been created using raylib 1.8 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
*
* Copyright (c) 2017 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
public const int CUBEMAP_SIZE = 512; public const int CUBEMAP_SIZE = 512;
public const int IRRADIANCE_SIZE = 32; public const int IRRADIANCE_SIZE = 32;
@ -47,7 +56,7 @@ public partial class models_material_pbr
int screenHeight = 450; int screenHeight = 450;
SetConfigFlags(FLAG_MSAA_4X_HINT); // Enable Multi Sampling Anti Aliasing 4x (if available) SetConfigFlags(ConfigFlag.FLAG_MSAA_4X_HINT); // Enable Multi Sampling Anti Aliasing 4x (if available)
InitWindow(screenWidth, screenHeight, "raylib [models] example - pbr material"); InitWindow(screenWidth, screenHeight, "raylib [models] example - pbr material");
// Define the camera to look into our 3d world // Define the camera to look into our 3d world
@ -64,10 +73,11 @@ public partial class models_material_pbr
{ {
CreateLight(LightType.LIGHT_POINT, new Vector3( LIGHT_DISTANCE, LIGHT_HEIGHT, 0.0f ), new Vector3( 0.0f, 0.0f, 0.0f ), new Color( 255, 0, 0, 255 ), model.material.shader), CreateLight(LightType.LIGHT_POINT, new Vector3( LIGHT_DISTANCE, LIGHT_HEIGHT, 0.0f ), new Vector3( 0.0f, 0.0f, 0.0f ), new Color( 255, 0, 0, 255 ), model.material.shader),
CreateLight(LightType.LIGHT_POINT, new Vector3( 0.0f, LIGHT_HEIGHT, LIGHT_DISTANCE ), new Vector3( 0.0f, 0.0f, 0.0f ), new Color( 0, 255, 0, 255 ), model.material.shader), CreateLight(LightType.LIGHT_POINT, new Vector3( 0.0f, LIGHT_HEIGHT, LIGHT_DISTANCE ), new Vector3( 0.0f, 0.0f, 0.0f ), new Color( 0, 255, 0, 255 ), model.material.shader),
CreateLight(LightType.LIGHT_POINT, new Vector3( -LIGHT_DISTANCE, LIGHT_HEIGHT, 0.0f ), new Vector3( 0.0f, 0.0f, 0.0f ),new Color( 0, 0, 255, 255 ), model.material.shader), CreateLight(LightType.LIGHT_DIRECTIONAL, new Vector3(0.0f, LIGHT_HEIGHT * 2.0f, -LIGHT_DISTANCE ), new Vector3( 0.0f, 0.0f, 0.0f ), new Color(255, 0, 255, 255 ), model.material.shader) CreateLight(LightType.LIGHT_POINT, new Vector3( -LIGHT_DISTANCE, LIGHT_HEIGHT, 0.0f ), new Vector3( 0.0f, 0.0f, 0.0f ),new Color( 0, 0, 255, 255 ), model.material.shader),
CreateLight(LightType.LIGHT_DIRECTIONAL, new Vector3(0.0f, LIGHT_HEIGHT * 2.0f, -LIGHT_DISTANCE ), new Vector3( 0.0f, 0.0f, 0.0f ), new Color(255, 0, 255, 255 ), model.material.shader)
}; };
SetCameraMode(camera, (int)CameraMode.CAMERA_ORBITAL); // Set an orbital camera mode SetCameraMode(camera, CameraMode.CAMERA_ORBITAL); // Set an orbital camera mode
SetTargetFPS(60); // Set our game to run at 60 frames-per-second SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
@ -110,7 +120,9 @@ public partial class models_material_pbr
CloseWindow(); // Close window and OpenGL context CloseWindow(); // Close window and OpenGL context
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
return 0; } return 0;
}
// Load PBR material (Supports: ALBEDO, NORMAL, METALNESS, ROUGHNESS, AO, EMMISIVE, HEIGHT maps) // Load PBR material (Supports: ALBEDO, NORMAL, METALNESS, ROUGHNESS, AO, EMMISIVE, HEIGHT maps)
// NOTE: PBR shader is loaded inside this function // NOTE: PBR shader is loaded inside this function
unsafe public static Material LoadMaterialPBR(Color albedo, float metalness, float roughness) unsafe public static Material LoadMaterialPBR(Color albedo, float metalness, float roughness)
@ -162,7 +174,9 @@ public partial class models_material_pbr
Shader shdrBRDF = LoadShader(PATH_BRDF_VS, PATH_BRDF_FS); Shader shdrBRDF = LoadShader(PATH_BRDF_VS, PATH_BRDF_FS);
// Setup required shader locations // Setup required shader locations
SetShaderValuei(shdrCubemap, GetShaderLocation(shdrCubemap, "equirectangularMap"), new int[] { 0 }, 1); SetShaderValuei(shdrIrradiance, GetShaderLocation(shdrIrradiance, "environmentMap"), new int[] { 0 }, 1); SetShaderValuei(shdrPrefilter, GetShaderLocation(shdrPrefilter, "environmentMap"), new int[] { 0 }, 1); SetShaderValuei(shdrCubemap, GetShaderLocation(shdrCubemap, "equirectangularMap"), new int[] { 0 }, 1);
SetShaderValuei(shdrIrradiance, GetShaderLocation(shdrIrradiance, "environmentMap"), new int[] { 0 }, 1);
SetShaderValuei(shdrPrefilter, GetShaderLocation(shdrPrefilter, "environmentMap"), new int[] { 0 }, 1);
Texture2D texHDR = LoadTexture("resources/dresden_square.hdr"); Texture2D texHDR = LoadTexture("resources/dresden_square.hdr");
Texture2D cubemap = GenTextureCubemap(shdrCubemap, texHDR, CUBEMAP_SIZE); Texture2D cubemap = GenTextureCubemap(shdrCubemap, texHDR, CUBEMAP_SIZE);
@ -179,21 +193,30 @@ public partial class models_material_pbr
UnloadShader(shdrBRDF); UnloadShader(shdrBRDF);
// Set textures filtering for better quality // Set textures filtering for better quality
SetTextureFilter(mat.maps[(int)TexmapIndex.MAP_ALBEDO].texture, (int)TextureFilterMode.FILTER_BILINEAR); SetTextureFilter(mat.maps[(int)TexmapIndex.MAP_ALBEDO].texture, TextureFilterMode.FILTER_BILINEAR);
SetTextureFilter(mat.maps[(int)TexmapIndex.MAP_NORMAL].texture, (int)TextureFilterMode.FILTER_BILINEAR); SetTextureFilter(mat.maps[(int)TexmapIndex.MAP_NORMAL].texture, TextureFilterMode.FILTER_BILINEAR);
SetTextureFilter(mat.maps[(int)TexmapIndex.MAP_METALNESS].texture, (int)TextureFilterMode.FILTER_BILINEAR); SetTextureFilter(mat.maps[(int)TexmapIndex.MAP_METALNESS].texture, TextureFilterMode.FILTER_BILINEAR);
SetTextureFilter(mat.maps[(int)TexmapIndex.MAP_ROUGHNESS].texture, (int)TextureFilterMode.FILTER_BILINEAR); SetTextureFilter(mat.maps[(int)TexmapIndex.MAP_ROUGHNESS].texture, TextureFilterMode.FILTER_BILINEAR);
SetTextureFilter(mat.maps[(int)TexmapIndex.MAP_OCCLUSION].texture, (int)TextureFilterMode.FILTER_BILINEAR); SetTextureFilter(mat.maps[(int)TexmapIndex.MAP_OCCLUSION].texture, TextureFilterMode.FILTER_BILINEAR);
// Enable sample usage in shader for assigned textures // Enable sample usage in shader for assigned textures
SetShaderValuei(mat.shader, GetShaderLocation(mat.shader, "albedo.useSampler"), new int[] { 1 }, 1); SetShaderValuei(mat.shader, GetShaderLocation(mat.shader, "normals.useSampler"), new int[] { 1 }, 1); SetShaderValuei(mat.shader, GetShaderLocation(mat.shader, "metalness.useSampler"), new int[] { 1 }, 1); SetShaderValuei(mat.shader, GetShaderLocation(mat.shader, "roughness.useSampler"), new int[] { 1 }, 1); SetShaderValuei(mat.shader, GetShaderLocation(mat.shader, "occlusion.useSampler"), new int[] { 1 }, 1); SetShaderValuei(mat.shader, GetShaderLocation(mat.shader, "albedo.useSampler"), new int[] { 1 }, 1);
SetShaderValuei(mat.shader, GetShaderLocation(mat.shader, "normals.useSampler"), new int[] { 1 }, 1);
SetShaderValuei(mat.shader, GetShaderLocation(mat.shader, "metalness.useSampler"), new int[] { 1 }, 1);
SetShaderValuei(mat.shader, GetShaderLocation(mat.shader, "roughness.useSampler"), new int[] { 1 }, 1);
SetShaderValuei(mat.shader, GetShaderLocation(mat.shader, "occlusion.useSampler"), new int[] { 1 }, 1);
int renderModeLoc = GetShaderLocation(mat.shader, "renderMode"); int renderModeLoc = GetShaderLocation(mat.shader, "renderMode");
SetShaderValuei(mat.shader, renderModeLoc, new int[] { 0 }, 1); SetShaderValuei(mat.shader, renderModeLoc, new int[] { 0 }, 1);
// Set up material properties color // Set up material properties color
mat.maps[(int)TexmapIndex.MAP_ALBEDO].color = albedo; mat.maps[(int)TexmapIndex.MAP_NORMAL].color = new Color(128, 128, 255, 255); mat.maps[(int)TexmapIndex.MAP_ALBEDO].color = albedo;
mat.maps[(int)TexmapIndex.MAP_METALNESS].value = metalness; mat.maps[(int)TexmapIndex.MAP_ROUGHNESS].value = roughness; mat.maps[(int)TexmapIndex.MAP_OCCLUSION].value = 1.0f; mat.maps[(int)TexmapIndex.MAP_EMISSION].value = 0.5f; mat.maps[(int)TexmapIndex.MAP_HEIGHT].value = 0.5f; mat.maps[(int)TexmapIndex.MAP_NORMAL].color = new Color(128, 128, 255, 255);
mat.maps[(int)TexmapIndex.MAP_METALNESS].value = metalness;
mat.maps[(int)TexmapIndex.MAP_ROUGHNESS].value = roughness;
mat.maps[(int)TexmapIndex.MAP_OCCLUSION].value = 1.0f;
mat.maps[(int)TexmapIndex.MAP_EMISSION].value = 0.5f;
mat.maps[(int)TexmapIndex.MAP_HEIGHT].value = 0.5f;
return mat; return mat;
} }

View file

@ -54,7 +54,7 @@ public partial class models_mesh_generation
int currentModel = 0; int currentModel = 0;
SetCameraMode(camera, (int)CAMERA_ORBITAL); // Set a orbital camera mode SetCameraMode(camera, CameraMode.CAMERA_ORBITAL); // Set a orbital camera mode
SetTargetFPS(60); // Set our game to run at 60 frames-per-second SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
@ -66,7 +66,7 @@ public partial class models_mesh_generation
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
UpdateCamera(ref camera); // Update internal camera and our camera UpdateCamera(ref camera); // Update internal camera and our camera
if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) if (IsMouseButtonPressed(MouseButton.MOUSE_LEFT_BUTTON))
{ {
currentModel = (currentModel + 1)%NUM_MODELS; // Cycle between the textures currentModel = (currentModel + 1)%NUM_MODELS; // Cycle between the textures
} }

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