|
6 months ago | |
---|---|---|
binding_generator | 6 months ago | |
examples | 6 months ago | |
.gitattributes | 8 months ago | |
.gitignore | 1 year ago | |
LICENSE | 1 year ago | |
README.md | 6 months ago | |
raylib.nelua | 6 months ago |
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:
-L
option, for example: nelua -L ~/path/to/nelua-raylib my-game.nelua
neluacfg.lua
script on the project’s root directory or on your $HOME/config/
with the content return { add_path = {'/path/to/nelua-raylib'} }
(See about this here)This binding contains some extra features to better integrate with nelua
language:
Raylib.GetWaveData
returns a *[0]float32
instead of just *float32
is_*
field is defined on the type information; for example, ## rAudioBuffer.value.is_raudiobuffer
is true
;function Camera.UpdateCamera(camera: *Camera)
is defined, which can be used as a method camera:UpdateCamera()
;raymath.h
functions defined:
Vector2
:
__add
: calls Vector2Add
__sub
: calls Vector2Subtract
__len
: calls Vector2Length
__unm
: calls Vector2Negate
__div
: calls Vector2Divide
or Vector2DivideV
__mul
: calls Vector2Scale
or Vector2MultiplyV
Vector3
:
__add
: calls Vector3Add
__sub
: calls Vector3Subtract
__len
: calls Vector3Length
__unm
: calls Vector3Negate
__mul
: calls Vector3Scale
or Vector3Multiply
__div
: calls Vector3Divide
or Vector3DivideV
Matrix
:
__add
: calls MatrixAdd
__sub
: calls MatrixSubtract
__mul
: calls MatrixMultiply
Quaternion
:
__len
: calls QuaternionLength
__mul
: calls QuaternionMultiply
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 ]