mirror of
https://github.com/Not-Nik/raylib-zig.git
synced 2025-09-09 12:07:27 +00:00
Some minor improvements
This commit is contained in:
parent
53be5d5871
commit
5f8226f8d8
0
.gitignore
vendored
Normal file → Executable file
0
.gitignore
vendored
Normal file → Executable file
2
ReadMe.md
Normal file → Executable file
2
ReadMe.md
Normal file → Executable file
@ -1,6 +1,6 @@
|
||||
# raylib-zig
|
||||
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
|
||||
Basically we can copy the default example with some minor changes:
|
||||
|
6
build.zig
Normal file → Executable file
6
build.zig
Normal file → Executable file
@ -72,9 +72,9 @@ pub fn build(b: *Builder) void
|
||||
const inputMouseWheelStep = b.step("input_mouse_wheel", "Mouse wheel input");
|
||||
inputMouseWheelStep.dependOn(&runInputMouseWheel.step);
|
||||
|
||||
const runInputMouseWheel = inputMouseWheel.run();
|
||||
const inputMouseWheelStep = b.step("input_mouse_wheel", "Mouse wheel input");
|
||||
inputMouseWheelStep.dependOn(&runInputMouseWheel.step);
|
||||
const runInputMultitouch = inputMultitouch.run();
|
||||
const inputMultitouchStep = b.step("input_multitouch", "Multitouch (duh)");
|
||||
inputMultitouchStep.dependOn(&runInputMultitouch.step);
|
||||
|
||||
const run2DCamera = twoDCamera.run();
|
||||
const twoDCameraStep = b.step("2d_camera", "Shows the functionality of a 2D camera");
|
||||
|
0
examples/ReadMe.md
Normal file → Executable file
0
examples/ReadMe.md
Normal file → Executable file
0
examples/core/2d_camera.zig
Normal file → Executable file
0
examples/core/2d_camera.zig
Normal file → Executable file
0
examples/core/basic_window.zig
Normal file → Executable file
0
examples/core/basic_window.zig
Normal file → Executable file
0
examples/core/input_keys.zig
Normal file → Executable file
0
examples/core/input_keys.zig
Normal file → Executable file
0
examples/core/input_mouse.zig
Normal file → Executable file
0
examples/core/input_mouse.zig
Normal file → Executable file
0
examples/core/input_mouse_wheel.zig
Normal file → Executable file
0
examples/core/input_mouse_wheel.zig
Normal file → Executable file
27
examples/core/input_multitouch.zig
Normal file → Executable file
27
examples/core/input_multitouch.zig
Normal file → Executable file
@ -19,7 +19,7 @@ pub fn main() anyerror!void
|
||||
var ballPosition = Vector2 { .x = -100.0, .y = -100.0 };
|
||||
var ballColor = BEIGE;
|
||||
|
||||
var touchCounter: i32 = 0;
|
||||
var touchCounter: f32 = 0;
|
||||
var touchPosition = Vector2 { .x = 0.0, .y = 0.0 };
|
||||
|
||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||
@ -34,15 +34,15 @@ pub fn main() anyerror!void
|
||||
|
||||
ballColor = BEIGE;
|
||||
|
||||
if (IsMouseButtonDown(MouseButton.MOUSE_LEFT_BUTTON)) { ballColor = MAROON };
|
||||
if (IsMouseButtonDown(MouseButton.MOUSE_MIDDLE_BUTTON)) { ballColor = LIME };
|
||||
if (IsMouseButtonDown(MouseButton.MOUSE_RIGHT_BUTTON)) { ballColor = DARKBLUE };
|
||||
if (IsMouseButtonDown(MouseButton.MOUSE_LEFT_BUTTON)) { ballColor = MAROON; }
|
||||
if (IsMouseButtonDown(MouseButton.MOUSE_MIDDLE_BUTTON)) { ballColor = LIME; }
|
||||
if (IsMouseButtonDown(MouseButton.MOUSE_RIGHT_BUTTON)) { ballColor = DARKBLUE; }
|
||||
|
||||
if (IsMouseButtonPressed(MouseButton.MOUSE_LEFT_BUTTON)) { touchCounter = 10 };
|
||||
if (IsMouseButtonPressed(MouseButton.MOUSE_MIDDLE_BUTTON)) { touchCounter = 10 };
|
||||
if (IsMouseButtonPressed(MouseButton.MOUSE_RIGHT_BUTTON)) { touchCounter = 10 };
|
||||
if (IsMouseButtonPressed(MouseButton.MOUSE_LEFT_BUTTON)) { touchCounter = 10; }
|
||||
if (IsMouseButtonPressed(MouseButton.MOUSE_MIDDLE_BUTTON)) { touchCounter = 10; }
|
||||
if (IsMouseButtonPressed(MouseButton.MOUSE_RIGHT_BUTTON)) { touchCounter = 10; }
|
||||
|
||||
if (touchCounter > 0) { touchCounter -= 1; };
|
||||
if (touchCounter > 0) { touchCounter -= 1; }
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
@ -51,16 +51,17 @@ pub fn main() anyerror!void
|
||||
|
||||
ClearBackground(RAYWHITE);
|
||||
|
||||
// Multitouch
|
||||
for (int i = 0; i < MAX_TOUCH_POINTS; ++i)
|
||||
const nums = [_]i32{0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
|
||||
for (nums) |i|
|
||||
{
|
||||
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
|
||||
DrawCircleV(touchPosition, 34, ORANGE);
|
||||
DrawText(FormatText("%d", i), touchPosition.x - 10, touchPosition.y - 70, 40, BLACK);
|
||||
DrawCircle(@floatToInt(c_int, touchPosition.x), @floatToInt(c_int, touchPosition.y), 34, ORANGE);
|
||||
//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
0
examples/models/models_loading.zig
Normal file → Executable file
0
lib/raylib-zig-math.zig
Normal file → Executable file
0
lib/raylib-zig-math.zig
Normal file → Executable file
0
lib/raylib-zig.zig
Normal file → Executable file
0
lib/raylib-zig.zig
Normal file → Executable file
Loading…
x
Reference in New Issue
Block a user