mirror of
https://github.com/Not-Nik/raylib-zig.git
synced 2025-09-09 03:57:29 +00:00
Merge pull request #1 from sacredbirdman/master
zig 0.6.0 compatibility
This commit is contained in:
commit
98e83d7a09
@ -14,7 +14,7 @@ pub fn main() anyerror!void
|
||||
const screenWidth = 800;
|
||||
const screenHeight = 450;
|
||||
|
||||
InitWindow(screenWidth, screenHeight, c"MyWindow");
|
||||
InitWindow(screenWidth, screenHeight, "MyWindow");
|
||||
|
||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||
//--------------------------------------------------------------------------------------
|
||||
@ -28,7 +28,7 @@ pub fn main() anyerror!void
|
||||
|
||||
ClearBackground(WHITE);
|
||||
|
||||
DrawText(c"Congrats! You created your first window!", 190, 200, 20, LIGHTGRAY);
|
||||
DrawText("Congrats! You created your first window!", 190, 200, 20, LIGHTGRAY);
|
||||
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
|
@ -1,6 +1,6 @@
|
||||
//
|
||||
// build
|
||||
// Zig version: 0.5.0
|
||||
// Zig version: 0.6.0
|
||||
// Author: Nikolas Wipper
|
||||
// Date: 2020-02-15
|
||||
//
|
||||
|
@ -17,7 +17,7 @@ pub fn main() anyerror!void
|
||||
const screenWidth = 800;
|
||||
const screenHeight = 450;
|
||||
|
||||
InitWindow(screenWidth, screenHeight, c"raylib-zig [core] example - 2d camera");
|
||||
InitWindow(screenWidth, screenHeight, "raylib-zig [core] example - 2d camera");
|
||||
|
||||
var player = Rectangle { .x = 400, .y = 280, .width = 40, .height = 40 };
|
||||
var buildings: [MAX_BUILDINGS]Rectangle = undefined;
|
||||
@ -107,7 +107,7 @@ pub fn main() anyerror!void
|
||||
|
||||
EndMode2D();
|
||||
|
||||
DrawText(c"SCREEN AREA", 640, 10, 20, RED);
|
||||
DrawText("SCREEN AREA", 640, 10, 20, RED);
|
||||
|
||||
DrawRectangle(0, 0, screenWidth, 5, RED);
|
||||
DrawRectangle(0, 5, 5, screenHeight - 10, RED);
|
||||
@ -117,11 +117,11 @@ pub fn main() anyerror!void
|
||||
DrawRectangle( 10, 10, 250, 113, Fade(SKYBLUE, 0.5));
|
||||
DrawRectangleLines( 10, 10, 250, 113, BLUE);
|
||||
|
||||
DrawText(c"Free 2d camera controls:", 20, 20, 10, BLACK);
|
||||
DrawText(c"- Right/Left to move Offset", 40, 40, 10, DARKGRAY);
|
||||
DrawText(c"- Mouse Wheel to Zoom in-out", 40, 60, 10, DARKGRAY);
|
||||
DrawText(c"- A / S to Rotate", 40, 80, 10, DARKGRAY);
|
||||
DrawText(c"- R to reset Zoom and Rotation", 40, 100, 10, DARKGRAY);
|
||||
DrawText("Free 2d camera controls:", 20, 20, 10, BLACK);
|
||||
DrawText("- Right/Left to move Offset", 40, 40, 10, DARKGRAY);
|
||||
DrawText("- Mouse Wheel to Zoom in-out", 40, 60, 10, DARKGRAY);
|
||||
DrawText("- A / S to Rotate", 40, 80, 10, DARKGRAY);
|
||||
DrawText("- R to reset Zoom and Rotation", 40, 100, 10, DARKGRAY);
|
||||
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
|
@ -1,6 +1,6 @@
|
||||
//
|
||||
// basic_window
|
||||
// Zig version: 0.5.0
|
||||
// Zig version: 0.6.0
|
||||
// Author: Nikolas Wipper
|
||||
// Date: 2020-02-15
|
||||
//
|
||||
@ -14,7 +14,7 @@ pub fn main() anyerror!void
|
||||
const screenWidth = 800;
|
||||
const screenHeight = 450;
|
||||
|
||||
InitWindow(screenWidth, screenHeight, c"raylib-zig [core] example - basic window");
|
||||
InitWindow(screenWidth, screenHeight, "raylib-zig [core] example - basic window");
|
||||
|
||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||
//--------------------------------------------------------------------------------------
|
||||
@ -33,7 +33,7 @@ pub fn main() anyerror!void
|
||||
|
||||
ClearBackground(WHITE);
|
||||
|
||||
DrawText(c"Congrats! You created your first window!", 190, 200, 20, LIGHTGRAY);
|
||||
DrawText("Congrats! You created your first window!", 190, 200, 20, LIGHTGRAY);
|
||||
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
|
@ -14,7 +14,7 @@ pub fn main() anyerror!void
|
||||
const screenWidth = 800;
|
||||
const screenHeight = 450;
|
||||
|
||||
InitWindow(screenWidth, screenHeight, c"raylib-zig [core] example - keyboard input");
|
||||
InitWindow(screenWidth, screenHeight, "raylib-zig [core] example - keyboard input");
|
||||
|
||||
var ballPosition = Vector2 { .x = screenWidth/2, .y = screenHeight/2 };
|
||||
|
||||
@ -38,7 +38,7 @@ pub fn main() anyerror!void
|
||||
|
||||
ClearBackground(RAYWHITE);
|
||||
|
||||
DrawText(c"move the ball with arrow keys", 10, 10, 20, DARKGRAY);
|
||||
DrawText("move the ball with arrow keys", 10, 10, 20, DARKGRAY);
|
||||
|
||||
DrawCircle(@floatToInt(c_int, ballPosition.x), @floatToInt(c_int, ballPosition.y), 50, MAROON);
|
||||
//DrawCircleV(ballPosition, 50, MAROON);
|
||||
|
@ -14,7 +14,7 @@ pub fn main() anyerror!void
|
||||
const screenWidth = 800;
|
||||
const screenHeight = 450;
|
||||
|
||||
InitWindow(screenWidth, screenHeight, c"raylib-zig [core] example - mouse input");
|
||||
InitWindow(screenWidth, screenHeight, "raylib-zig [core] example - mouse input");
|
||||
|
||||
var ballPosition = Vector2 { .x = -100.0, .y = -100.0 };
|
||||
var ballColor = DARKBLUE;
|
||||
@ -43,7 +43,7 @@ pub fn main() anyerror!void
|
||||
DrawCircle(@floatToInt(c_int, ballPosition.x), @floatToInt(c_int, ballPosition.y), 50, ballColor);
|
||||
//DrawCircleV(ballPosition, 40, ballColor);
|
||||
|
||||
DrawText(c"move ball with mouse and click mouse button to change color", 10, 10, 20, DARKGRAY);
|
||||
DrawText("move ball with mouse and click mouse button to change color", 10, 10, 20, DARKGRAY);
|
||||
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
|
@ -14,7 +14,7 @@ pub fn main() anyerror!void
|
||||
const screenWidth = 800;
|
||||
const screenHeight = 450;
|
||||
|
||||
InitWindow(screenWidth, screenHeight, c"raylib-zig [core] example - basic window");
|
||||
InitWindow(screenWidth, screenHeight, "raylib-zig [core] example - basic window");
|
||||
|
||||
var boxPositionY: i32 = screenHeight / 2 - 40;
|
||||
var scrollSpeed: i32 = 4; // Scrolling speed in pixels
|
||||
@ -38,8 +38,8 @@ pub fn main() anyerror!void
|
||||
|
||||
DrawRectangle(screenWidth/2 - 40, boxPositionY, 80, 80, MAROON);
|
||||
|
||||
DrawText(c"Use mouse wheel to move the cube up and down!", 10, 10, 20, GRAY);
|
||||
DrawText(FormatText(c"Box position Y: %03i", boxPositionY), 10, 40, 20, LIGHTGRAY);
|
||||
DrawText("Use mouse wheel to move the cube up and down!", 10, 10, 20, GRAY);
|
||||
DrawText(FormatText("Box position Y: %03i", boxPositionY), 10, 40, 20, LIGHTGRAY);
|
||||
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
|
@ -14,7 +14,7 @@ pub fn main() anyerror!void
|
||||
const screenWidth = 800;
|
||||
const screenHeight = 450;
|
||||
|
||||
InitWindow(screenWidth, screenHeight, c"raylib-zig [core] example - basic window");
|
||||
InitWindow(screenWidth, screenHeight, "raylib-zig [core] example - basic window");
|
||||
|
||||
var ballPosition = Vector2 { .x = -100.0, .y = -100.0 };
|
||||
var ballColor = BEIGE;
|
||||
@ -61,7 +61,7 @@ pub fn main() anyerror!void
|
||||
// Draw circle and touch index number
|
||||
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);
|
||||
DrawText(FormatText("%d", i), @floatToInt(c_int, touchPosition.x) - 10, @floatToInt(c_int, touchPosition.y) - 70, 40, BLACK);
|
||||
}
|
||||
}
|
||||
|
||||
@ -69,8 +69,8 @@ pub fn main() anyerror!void
|
||||
DrawCircle(@floatToInt(c_int, ballPosition.x), @floatToInt(c_int, ballPosition.y), 30 + (touchCounter*3), ballColor);
|
||||
//DrawCircleV(ballPosition, 30 + (touchCounter*3), ballColor);
|
||||
|
||||
DrawText(c"move ball with mouse and click mouse button to change color", 10, 10, 20, DARKGRAY);
|
||||
DrawText(c"touch the screen at multiple locations to get multiple balls", 10, 30, 20, DARKGRAY);
|
||||
DrawText("move ball with mouse and click mouse button to change color", 10, 10, 20, DARKGRAY);
|
||||
DrawText("touch the screen at multiple locations to get multiple balls", 10, 30, 20, DARKGRAY);
|
||||
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
|
@ -14,7 +14,7 @@ pub fn main() anyerror!void
|
||||
const screenWidth = 800;
|
||||
const screenHeight = 450;
|
||||
|
||||
InitWindow(screenWidth, screenHeight, c"raylib [models] example - models loading");
|
||||
InitWindow(screenWidth, screenHeight, "raylib [models] example - models loading");
|
||||
|
||||
// Define the camera to look into our 3d world
|
||||
var camera = Camera {
|
||||
@ -25,8 +25,8 @@ pub fn main() anyerror!void
|
||||
.type = CameraType.CAMERA_PERSPECTIVE // Camera mode type
|
||||
};
|
||||
|
||||
var model = LoadModel(c"resources/models/castle.obj"); // Load model
|
||||
var texture = LoadTexture(c"resources/models/castle_diffuse.png"); // Load model texture
|
||||
var model = LoadModel("resources/models/castle.obj"); // Load model
|
||||
var texture = LoadTexture("resources/models/castle_diffuse.png"); // Load model texture
|
||||
model.materials[0].maps[@enumToInt(MAP_DIFFUSE)].texture = texture; // Set map diffuse texture
|
||||
|
||||
var position = Vector3 { .x = 0.0, .y = 0.0, .z = 0.0 }; // Set model position
|
||||
@ -58,9 +58,9 @@ pub fn main() anyerror!void
|
||||
|
||||
if (count == 1) // Only support one file dropped
|
||||
{
|
||||
if (IsFileExtension(droppedFiles[0], c".obj") or
|
||||
IsFileExtension(droppedFiles[0], c".gltf") or
|
||||
IsFileExtension(droppedFiles[0], c".iqm")) // Model file formats supported
|
||||
if (IsFileExtension(droppedFiles[0], ".obj") or
|
||||
IsFileExtension(droppedFiles[0], ".gltf") or
|
||||
IsFileExtension(droppedFiles[0], ".iqm")) // Model file formats supported
|
||||
{
|
||||
UnloadModel(model); // Unload previous model
|
||||
model = LoadModel(droppedFiles[0]); // Load new model
|
||||
@ -70,7 +70,7 @@ pub fn main() anyerror!void
|
||||
|
||||
// TODO: Move camera position from target enough distance to visualize model properly
|
||||
}
|
||||
else if (IsFileExtension(droppedFiles[0], c".png")) // Texture file formats supported
|
||||
else if (IsFileExtension(droppedFiles[0], ".png")) // Texture file formats supported
|
||||
{
|
||||
// Unload current model texture and load new one
|
||||
UnloadTexture(texture);
|
||||
@ -113,10 +113,10 @@ pub fn main() anyerror!void
|
||||
|
||||
EndMode3D();
|
||||
|
||||
DrawText(c"Drag & drop model to load mesh/texture.", 10, GetScreenHeight() - 20, 10, DARKGRAY);
|
||||
if (selected) DrawText(c"MODEL SELECTED", GetScreenWidth() - 110, 10, 10, GREEN);
|
||||
DrawText("Drag & drop model to load mesh/texture.", 10, GetScreenHeight() - 20, 10, DARKGRAY);
|
||||
if (selected) DrawText("MODEL SELECTED", GetScreenWidth() - 110, 10, 10, GREEN);
|
||||
|
||||
DrawText(c"(c) Castle 3D model by Alberto Cano", screenWidth - 200, screenHeight - 20, 10, GRAY);
|
||||
DrawText("(c) Castle 3D model by Alberto Cano", screenWidth - 200, screenHeight - 20, 10, GRAY);
|
||||
|
||||
DrawFPS(10, 10);
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
//
|
||||
// rayzig_math
|
||||
// Zig version: 0.5.0
|
||||
// Zig version: 0.6.0
|
||||
// Author: Nikolas Wipper
|
||||
// Date: 2020-02-15
|
||||
//
|
||||
|
Loading…
x
Reference in New Issue
Block a user