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
-L
option, for example:nelua -L ~/path/to/nelua-raylib my-game.nelua
- use a
neluacfg.lua
script on the project's root directory or on your$HOME/.config/nelua
with 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.GetWaveData
returns a*[0]float32
instead of just*float32
- for every record an
is_*
field is defined on the type information; for example,## rAudioBuffer.value.is_raudiobuffer
istrue
; - 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.h
functions defined:Vector2
:__add
: callsVector2Add
__sub
: callsVector2Subtract
__len
: callsVector2Length
__unm
: callsVector2Negate
__div
: callsVector2Divide
orVector2DivideV
__mul
: callsVector2Scale
orVector2MultiplyV
Vector3
:__add
: callsVector3Add
__sub
: callsVector3Subtract
__len
: callsVector3Length
__unm
: callsVector3Negate
__mul
: callsVector3Scale
orVector3Multiply
__div
: callsVector3Divide
orVector3DivideV
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 ]]