fix build and basic_window example

some restructuring due to the recent changes to usingnamespace.

also cleaned up some deprecated stuff from raylib 3.7.

- appended the contents of raylib-wa.zig into raylib-zig.zig
- using raylib functions requires `const rl = @import("raylib");`
    (and accesing the identifiers inside rl, like `rl.InitWindow`)

only the basic_window example was updated, and it looks like it crashes
on keyboard inputs.

many thanks to @nektro :)
This commit is contained in:
Francisco Demartino 2022-01-08 04:20:11 -03:00
parent 3f19a5742a
commit 5e275e93df
14 changed files with 237 additions and 166 deletions

View file

@ -5,22 +5,21 @@
// Date: 2020-02-15
//
usingnamespace @import("raylib");
const rl = @import("raylib");
pub fn main() anyerror!void
{
pub fn main() anyerror!void {
// Initialization
//--------------------------------------------------------------------------------------
const screenWidth = 800;
const screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib-zig [core] example - basic window");
rl.InitWindow(screenWidth, screenHeight, "raylib-zig [core] example - basic window");
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
rl.SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------
// Main game loop
while (!WindowShouldClose()) // Detect window close button or ESC key
while (!rl.WindowShouldClose()) // Detect window close button or ESC key
{
// Update
//----------------------------------------------------------------------------------
@ -29,18 +28,18 @@ pub fn main() anyerror!void
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
rl.BeginDrawing();
ClearBackground(WHITE);
rl.ClearBackground(rl.WHITE);
DrawText("Congrats! You created your first window!", 190, 200, 20, LIGHTGRAY);
rl.DrawText("Congrats! You created your first window!", 190, 200, 20, rl.LIGHTGRAY);
EndDrawing();
rl.EndDrawing();
//----------------------------------------------------------------------------------
}
// De-Initialization
//--------------------------------------------------------------------------------------
CloseWindow(); // Close window and OpenGL context
rl.CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
}