Some minor improvements

This commit is contained in:
G3bE 2020-02-22 20:43:30 +10:00
parent 53be5d5871
commit 5f8226f8d8
No known key found for this signature in database
GPG Key ID: 08BB71E672DB3BFD
14 changed files with 18 additions and 17 deletions

0
.gitignore vendored Normal file → Executable file
View File

0
LICENSE Normal file → Executable file
View File

2
ReadMe.md Normal file → Executable file
View File

@ -1,6 +1,6 @@
# raylib-zig # raylib-zig
Manually tweaked, auto generated [raylib](https://github.com/raysan5/raylib) bindings for zig.<br> Manually tweaked, auto generated [raylib](https://github.com/raysan5/raylib) bindings for zig.<br>
Be aware these bindings are for the 2.5.0 release of raylib. 2.6.0 bindings will follow soon. Bindings tested onn raylib version 2.6
## Example ## Example
Basically we can copy the default example with some minor changes: Basically we can copy the default example with some minor changes:

6
build.zig Normal file → Executable file
View File

@ -72,9 +72,9 @@ pub fn build(b: *Builder) void
const inputMouseWheelStep = b.step("input_mouse_wheel", "Mouse wheel input"); const inputMouseWheelStep = b.step("input_mouse_wheel", "Mouse wheel input");
inputMouseWheelStep.dependOn(&runInputMouseWheel.step); inputMouseWheelStep.dependOn(&runInputMouseWheel.step);
const runInputMouseWheel = inputMouseWheel.run(); const runInputMultitouch = inputMultitouch.run();
const inputMouseWheelStep = b.step("input_mouse_wheel", "Mouse wheel input"); const inputMultitouchStep = b.step("input_multitouch", "Multitouch (duh)");
inputMouseWheelStep.dependOn(&runInputMouseWheel.step); inputMultitouchStep.dependOn(&runInputMultitouch.step);
const run2DCamera = twoDCamera.run(); const run2DCamera = twoDCamera.run();
const twoDCameraStep = b.step("2d_camera", "Shows the functionality of a 2D camera"); const twoDCameraStep = b.step("2d_camera", "Shows the functionality of a 2D camera");

0
examples/ReadMe.md Normal file → Executable file
View File

0
examples/core/2d_camera.zig Normal file → Executable file
View File

0
examples/core/basic_window.zig Normal file → Executable file
View File

0
examples/core/input_keys.zig Normal file → Executable file
View File

0
examples/core/input_mouse.zig Normal file → Executable file
View File

0
examples/core/input_mouse_wheel.zig Normal file → Executable file
View File

27
examples/core/input_multitouch.zig Normal file → Executable file
View File

@ -19,7 +19,7 @@ pub fn main() anyerror!void
var ballPosition = Vector2 { .x = -100.0, .y = -100.0 }; var ballPosition = Vector2 { .x = -100.0, .y = -100.0 };
var ballColor = BEIGE; var ballColor = BEIGE;
var touchCounter: i32 = 0; var touchCounter: f32 = 0;
var touchPosition = Vector2 { .x = 0.0, .y = 0.0 }; var touchPosition = Vector2 { .x = 0.0, .y = 0.0 };
SetTargetFPS(60); // Set our game to run at 60 frames-per-second SetTargetFPS(60); // Set our game to run at 60 frames-per-second
@ -34,15 +34,15 @@ pub fn main() anyerror!void
ballColor = BEIGE; ballColor = BEIGE;
if (IsMouseButtonDown(MouseButton.MOUSE_LEFT_BUTTON)) { ballColor = MAROON }; if (IsMouseButtonDown(MouseButton.MOUSE_LEFT_BUTTON)) { ballColor = MAROON; }
if (IsMouseButtonDown(MouseButton.MOUSE_MIDDLE_BUTTON)) { ballColor = LIME }; if (IsMouseButtonDown(MouseButton.MOUSE_MIDDLE_BUTTON)) { ballColor = LIME; }
if (IsMouseButtonDown(MouseButton.MOUSE_RIGHT_BUTTON)) { ballColor = DARKBLUE }; if (IsMouseButtonDown(MouseButton.MOUSE_RIGHT_BUTTON)) { ballColor = DARKBLUE; }
if (IsMouseButtonPressed(MouseButton.MOUSE_LEFT_BUTTON)) { touchCounter = 10 }; if (IsMouseButtonPressed(MouseButton.MOUSE_LEFT_BUTTON)) { touchCounter = 10; }
if (IsMouseButtonPressed(MouseButton.MOUSE_MIDDLE_BUTTON)) { touchCounter = 10 }; if (IsMouseButtonPressed(MouseButton.MOUSE_MIDDLE_BUTTON)) { touchCounter = 10; }
if (IsMouseButtonPressed(MouseButton.MOUSE_RIGHT_BUTTON)) { touchCounter = 10 }; if (IsMouseButtonPressed(MouseButton.MOUSE_RIGHT_BUTTON)) { touchCounter = 10; }
if (touchCounter > 0) { touchCounter -= 1; }; if (touchCounter > 0) { touchCounter -= 1; }
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Draw // Draw
@ -51,16 +51,17 @@ pub fn main() anyerror!void
ClearBackground(RAYWHITE); ClearBackground(RAYWHITE);
// Multitouch const nums = [_]i32{0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
for (int i = 0; i < MAX_TOUCH_POINTS; ++i) for (nums) |i|
{ {
touchPosition = GetTouchPosition(i); // Get the touch point touchPosition = GetTouchPosition(i); // Get the touch point
if ((touchPosition.x >= 0) && (touchPosition.y >= 0)) // Make sure point is not (-1,-1) as this means there is no touch for it if ((touchPosition.x >= 0) and (touchPosition.y >= 0)) // Make sure point is not (-1,-1) as this means there is no touch for it
{ {
// Draw circle and touch index number // Draw circle and touch index number
DrawCircleV(touchPosition, 34, ORANGE); DrawCircle(@floatToInt(c_int, touchPosition.x), @floatToInt(c_int, touchPosition.y), 34, ORANGE);
DrawText(FormatText("%d", i), touchPosition.x - 10, touchPosition.y - 70, 40, BLACK); //DrawCircleV(touchPosition, 34, ORANGE);
DrawText(FormatText(c"%d", i), @floatToInt(c_int, touchPosition.x) - 10, @floatToInt(c_int, touchPosition.y) - 70, 40, BLACK);
} }
} }

0
examples/models/models_loading.zig Normal file → Executable file
View File

0
lib/raylib-zig-math.zig Normal file → Executable file
View File

0
lib/raylib-zig.zig Normal file → Executable file
View File