This library it's really important to me, however I've been focusing on my own game framework and thus this library got unmaintained.
If you need bindings of raylib for Nelua, you should check out Kenta's one, it's updated and covers more of raylib stack: https://github.com/Its-Kenta/Raylib.nelua
This is a Raylib binding for Nelua language.
First, install Nelua language and Raylib library.
Then, you can use raylib.nelua, you can use it as a project file or as a external library:
Just move raylib.nelua file to your project.
Clone or download this repository somewhere and then either:
- use the
-Loption, for example:nelua -L ~/path/to/nelua-raylib my-game.nelua - use a
neluacfg.luascript on the project's root directory or on your$HOME/.config/neluawith the contentreturn { add_path = {'/path/to/nelua-raylib'} }(See about this here)
This binding contains some extra features to better integrate with nelua language:
- unbounded arrays are specified on arguments and return types; for example,
Raylib.GetWaveDatareturns a*[0]float32instead of just*float32 - for every record an
is_*field is defined on the type information; for example,## rAudioBuffer.value.is_raudiobufferistrue; - several functions are also applied to records, for example,
function Camera.UpdateCamera(camera: *Camera)is defined, which can be used as a methodcamera:UpdateCamera(); - operator overloading functions for
raymath.hfunctions defined:Vector2:__add: callsVector2Add__sub: callsVector2Subtract__len: callsVector2Length__unm: callsVector2Negate__div: callsVector2DivideorVector2DivideV__mul: callsVector2ScaleorVector2MultiplyV
Vector3:__add: callsVector3Add__sub: callsVector3Subtract__len: callsVector3Length__unm: callsVector3Negate__mul: callsVector3ScaleorVector3Multiply__div: callsVector3DivideorVector3DivideV
Matrix:__add: callsMatrixAdd__sub: callsMatrixSubtract__mul: callsMatrixMultiply
Quaternion:__len: callsQuaternionLength__mul: callsQuaternionMultiply
NOTE: TraceLogCallback and SetTraceLogCallback aren't imported
require 'raylib'
-- [[ Initialization [[
local screen_width: integer <comptime> = 800
local screen_height: integer <comptime> = 450
Raylib.InitWindow(screen_width, screen_height, "raylib-nelua [core] example - keyboard input")
local ball_position: Vector2 = { screen_width / 2, screen_height / 2}
Raylib.SetTargetFPS(60) -- Set our game to run at 60 frames-per-second
-- ]] Initialization ]]
-- [[ Main game loop [[
while not Raylib.WindowShouldClose() do -- Detect window close button or ESC key
-- [[ Update [[
if Raylib.IsKeyDown(KeyboardKey.KEY_RIGHT) then
ball_position.x = ball_position.x + 2
end
if Raylib.IsKeyDown(KeyboardKey.KEY_LEFT) then
ball_position.x = ball_position.x - 2
end
if Raylib.IsKeyDown(KeyboardKey.KEY_UP) then
ball_position.y = ball_position.y - 2
end
if Raylib.IsKeyDown(KeyboardKey.KEY_DOWN) then
ball_position.y = ball_position.y + 2
end
-- ]] Update ]]
-- [[ Draw [[
Raylib.BeginDrawing()
Raylib.ClearBackground(RAYWHITE)
Raylib.DrawText("move the ball with arrow keys", 10, 10, 20, DARKGRAY)
Raylib.DrawCircleV(ball_position, 50, MAROON)
Raylib.EndDrawing()
-- ]] Draw ]]
end
-- [[ De-Initialization [[
Raylib.CloseWindow() -- Close window and OpenGL context
-- ]] De-Initialization ]]