Pong example, type named fields and vector lib changes.
This commit is contained in:
16
API.md
16
API.md
@@ -563,25 +563,25 @@ Raylib structs in Lua
|
||||
|
||||
---
|
||||
|
||||
> Vector2 = { 1.0, 1.0 }
|
||||
> Vector2 = { 1.0, 1.0 } or { x = 1.0, y = 1.0 }
|
||||
|
||||
Vector2 type
|
||||
|
||||
---
|
||||
|
||||
> Vector3 = { 1.0, 1.0, 1.0 }
|
||||
> Vector3 = { 1.0, 1.0, 1.0 } or { x = 1.0, y = 1.0, z = 1.0 }
|
||||
|
||||
Vector3 type
|
||||
|
||||
---
|
||||
|
||||
> Vector4 = { 1.0, 1.0, 1.0, 1.0 }
|
||||
> Vector4 = { 1.0, 1.0, 1.0, 1.0 } or { x = 1.0, y = 1.0, z = 1.0, w = 1.0 }
|
||||
|
||||
Vector4 type
|
||||
|
||||
---
|
||||
|
||||
> Quaternion = { 1.0, 1.0, 1.0, 1.0 }
|
||||
> Quaternion = { 1.0, 1.0, 1.0, 1.0 } or { x = 1.0, y = 1.0, z = 1.0, w = 1.0 }
|
||||
|
||||
Quaternion type
|
||||
|
||||
@@ -593,13 +593,13 @@ OpenGL style 4x4. Identity matrix example
|
||||
|
||||
---
|
||||
|
||||
> Color = { 255, 255, 255, 255 }
|
||||
> Color = { 255, 255, 255, 255 } or { r = 255, g = 255, b = 255, a = 255 }
|
||||
|
||||
{ r, g, b ,a }. Color type, RGBA (32bit)
|
||||
|
||||
---
|
||||
|
||||
> Rectangle = { 0.0, 0.0, 1.0, 1.0 }
|
||||
> Rectangle = { 0.0, 0.0, 1.0, 1.0 } or { x = 0.0, y = 0.0, width = 1.0, height = 1.0 }
|
||||
|
||||
{ x, y, w ,h }. Rectangle type
|
||||
|
||||
@@ -683,7 +683,7 @@ int id. Basic 3d Model type
|
||||
|
||||
---
|
||||
|
||||
> Ray = { { 0.0, 0.0, 0.0 }, { 1.0, 0.0, 0.0 } }
|
||||
> Ray = { { 0.0, 0.0, 0.0 }, { 1.0, 0.0, 0.0 } } or { position = { 0.0, 0.0, 0.0 }, direction = { 1.0, 0.0, 0.0 } }
|
||||
|
||||
{ position, direction }. Ray type (useful for raycast)
|
||||
|
||||
@@ -707,7 +707,7 @@ int id. Basic Sound source and buffer
|
||||
|
||||
---
|
||||
|
||||
> NPatchInfo = { { 0, 0, 24, 24 }, 0, 0, 0, 0, NPATCH_NINE_PATCH }
|
||||
> NPatchInfo = { { 0, 0, 24, 24 }, 0, 0, 0, 0, NPATCH_NINE_PATCH } or { source = { 0, 0, 24, 24 }, left = 0, top = 0, right = 0, bottom = 0, layout = NPATCH_NINE_PATCH }
|
||||
|
||||
{ Rectangle source, int left, int top, int right, int bottom, int layout }.
|
||||
{ Texture source rectangle, Left border offset, Top border offset, Right border offset, Bottom border offset, Layout of the n-patch: 3x3, 1x3 or 3x1 }
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
Idea of this project was to bring the power and simplicity of raylib to easy beginner friendly language like Lua in a very straight forward manner. It is loose binding to Raylib, some functions will not be included and some are added. The idea of pointing "main.lua" file and access functions "init", "process" and "draw" are borrowed from Löve game engine.
|
||||
|
||||
Need for boilerplate code is minimal and in true Lua fashion (in better and worse) you don't need to worry about types since all Raylib types are just lua tables and object id's. Also what Lua cannot handle, the engine is simple enough to be fairly easily extended with new functionality or by using Lua C-libraries.
|
||||
Need for boilerplate code is minimal and in true Lua fashion (in better and worse) you don't need to worry about strict type rules since all Raylib types are lua tables or object id's. Also what Lua cannot handle, the engine is simple enough to be fairly easily extended with new functionality or by using Lua C-libraries.
|
||||
|
||||
ReiLua is not planned to be a one-to-one binding to raylib. If you want more direct bindings, there are other projects like https://github.com/TSnake41/raylib-lua.
|
||||
|
||||
@@ -10,7 +10,7 @@ Reilua means fair in finnish.
|
||||
|
||||
## Status
|
||||
|
||||
ReiLua is WIP and some planned raylib functionality is still missing but it already has over 400 functions. Current Raylib version 4.0.0.
|
||||
ReiLua is WIP and some planned raylib functionality is still missing but it already has over 400 functions and should include all functions to make most 2d and 3d games. Current Raylib version 4.0.0.
|
||||
|
||||
List of some MISSING features that are planned to be included. For specific function, check API.
|
||||
|
||||
|
||||
@@ -70,19 +70,19 @@ srcFile:close()
|
||||
apiFile:write( "\n## Types\n\
|
||||
Raylib structs in Lua\n\n---\n" )
|
||||
|
||||
apiFile:write( "\n> Vector2 = { 1.0, 1.0 }\n\
|
||||
apiFile:write( "\n> Vector2 = { 1.0, 1.0 } or { x = 1.0, y = 1.0 }\n\
|
||||
Vector2 type\n\n---\n" )
|
||||
apiFile:write( "\n> Vector3 = { 1.0, 1.0, 1.0 }\n\
|
||||
apiFile:write( "\n> Vector3 = { 1.0, 1.0, 1.0 } or { x = 1.0, y = 1.0, z = 1.0 }\n\
|
||||
Vector3 type\n\n---\n" )
|
||||
apiFile:write( "\n> Vector4 = { 1.0, 1.0, 1.0, 1.0 }\n\
|
||||
apiFile:write( "\n> Vector4 = { 1.0, 1.0, 1.0, 1.0 } or { x = 1.0, y = 1.0, z = 1.0, w = 1.0 }\n\
|
||||
Vector4 type\n\n---\n" )
|
||||
apiFile:write( "\n> Quaternion = { 1.0, 1.0, 1.0, 1.0 }\n\
|
||||
apiFile:write( "\n> Quaternion = { 1.0, 1.0, 1.0, 1.0 } or { x = 1.0, y = 1.0, z = 1.0, w = 1.0 }\n\
|
||||
Quaternion type\n\n---\n" )
|
||||
apiFile:write( "\n> Matrix = { { 1.0, 0.0, 0.0, 0.0 }, { 0.0, 1.0, 0.0, 0.0 }, { 0.0, 0.0, 1.0, 0.0 }, { 0.0, 0.0, 0.0, 1.0 } }\n\
|
||||
OpenGL style 4x4. Identity matrix example\n\n---\n" )
|
||||
apiFile:write( "\n> Color = { 255, 255, 255, 255 }\n\
|
||||
apiFile:write( "\n> Color = { 255, 255, 255, 255 } or { r = 255, g = 255, b = 255, a = 255 }\n\
|
||||
{ r, g, b ,a }. Color type, RGBA (32bit)\n\n---\n" )
|
||||
apiFile:write( "\n> Rectangle = { 0.0, 0.0, 1.0, 1.0 }\n\
|
||||
apiFile:write( "\n> Rectangle = { 0.0, 0.0, 1.0, 1.0 } or { x = 0.0, y = 0.0, width = 1.0, height = 1.0 }\n\
|
||||
{ x, y, w ,h }. Rectangle type\n\n---\n" )
|
||||
apiFile:write( "\n> Image = ImageId\n\
|
||||
int id. Image type (multiple pixel formats supported). NOTE: Data stored in CPU memory (RAM)\n\n---\n" )
|
||||
@@ -128,7 +128,7 @@ material{} = {\
|
||||
```\n\n---\n" )
|
||||
apiFile:write( "\n> Model = ModelId\n\
|
||||
int id. Basic 3d Model type\n\n---\n" )
|
||||
apiFile:write( "\n> Ray = { { 0.0, 0.0, 0.0 }, { 1.0, 0.0, 0.0 } }\n\
|
||||
apiFile:write( "\n> Ray = { { 0.0, 0.0, 0.0 }, { 1.0, 0.0, 0.0 } } or { position = { 0.0, 0.0, 0.0 }, direction = { 1.0, 0.0, 0.0 } }\n\
|
||||
{ position, direction }. Ray type (useful for raycast)\n\n---\n" )
|
||||
apiFile:write( "\n> RayCollision = { hit = true, distance = 1.0, point = { 0.0, 0.0, 0.0 }, normal = { 0.0, 0.0, 1.0 } }\n\
|
||||
Raycast hit information. NOTE: Data in named keys\n\n---\n" )
|
||||
@@ -136,7 +136,7 @@ apiFile:write( "\n> BoundingBox = { { 0.0, 0.0, 0.0 }, { 1.0, 1.0, 1.0 } }\n\
|
||||
{ min, max }. Bounding box type for 3d mesh\n\n---\n" )
|
||||
apiFile:write( "\n> Sound = SoundId\n\
|
||||
int id. Basic Sound source and buffer\n\n---\n" )
|
||||
apiFile:write( "\n> NPatchInfo = { { 0, 0, 24, 24 }, 0, 0, 0, 0, NPATCH_NINE_PATCH }\n\
|
||||
apiFile:write( "\n> NPatchInfo = { { 0, 0, 24, 24 }, 0, 0, 0, 0, NPATCH_NINE_PATCH } or { source = { 0, 0, 24, 24 }, left = 0, top = 0, right = 0, bottom = 0, layout = NPATCH_NINE_PATCH }\n\
|
||||
{ Rectangle source, int left, int top, int right, int bottom, int layout }.\
|
||||
{ Texture source rectangle, Left border offset, Top border offset, Right border offset, Bottom border offset, Layout of the n-patch: 3x3, 1x3 or 3x1 }\n\n---\n" )
|
||||
apiFile:write( "\n> ModelAnimations = ModelAnimationsId\n\
|
||||
|
||||
125
examples/pong/main.lua
Normal file
125
examples/pong/main.lua
Normal file
@@ -0,0 +1,125 @@
|
||||
-- Settings.
|
||||
local winSize = { 800, 600 }
|
||||
local monitor = 0
|
||||
|
||||
-- Constants.
|
||||
local PLAYER_SPEED = 300
|
||||
local BALL_SPEED = 330
|
||||
|
||||
-- Game objects.
|
||||
local playerLeft = {
|
||||
pos = { 0, 0 },
|
||||
size = { 10, 70 },
|
||||
score = 0,
|
||||
}
|
||||
local playerRight = {
|
||||
pos = { 0, 0 },
|
||||
size = { 10, 70 },
|
||||
score = 0,
|
||||
}
|
||||
local ball = {
|
||||
pos = { 0, 0 },
|
||||
radius = 8.0,
|
||||
vel = { 0, 0 },
|
||||
}
|
||||
|
||||
local function reset()
|
||||
-- Initialize player positions.
|
||||
playerLeft.pos[1] = playerLeft.size[1]
|
||||
playerLeft.pos[2] = winSize[2] / 2 - playerLeft.size[2] / 2
|
||||
|
||||
playerRight.pos[1] = winSize[1] - playerRight.size[1] * 2
|
||||
playerRight.pos[2] = winSize[2] / 2 - playerRight.size[2] / 2
|
||||
|
||||
-- Set ball to center.
|
||||
ball.pos = { winSize[1] / 2, winSize[2] / 2 }
|
||||
-- Short for if math random result 1, set BALL_SPEED otherwise set -BALL_SPEED.
|
||||
ball.vel[1] = math.random( 0, 1 ) == 1 and BALL_SPEED or -BALL_SPEED
|
||||
-- Start slow.
|
||||
ball.vel[2] = 0
|
||||
end
|
||||
|
||||
local function ballHit( padPos, padSize )
|
||||
ball.vel[1] = -ball.vel[1]
|
||||
|
||||
local padCenter = padPos[2] + padSize[2] / 2
|
||||
local relHitPos = ball.pos[2] - padCenter
|
||||
ball.vel[2] = BALL_SPEED * relHitPos / padSize[2] * 2
|
||||
end
|
||||
|
||||
function init()
|
||||
-- Set window to center of monitor.
|
||||
local mPos = RL_GetMonitorPosition( monitor )
|
||||
local mSize = RL_GetMonitorSize( monitor )
|
||||
|
||||
RL_SetWindowSize( winSize )
|
||||
RL_SetWindowPosition( { mPos[1] + mSize[1] / 2 - winSize[1] / 2, mPos[2] + mSize[2] / 2 - winSize[2] / 2 } )
|
||||
RL_SetWindowTitle( "Pong" )
|
||||
|
||||
-- Initialize ball pos.
|
||||
math.randomseed( os.time() )
|
||||
reset()
|
||||
end
|
||||
|
||||
function process( delta )
|
||||
-- Left player controls.
|
||||
if RL_IsKeyDown( string.byte( "W" ) ) and 0 < playerLeft.pos[2] then
|
||||
playerLeft.pos[2] = playerLeft.pos[2] - PLAYER_SPEED * delta
|
||||
elseif RL_IsKeyDown( string.byte( "S" ) ) and playerLeft.pos[2] + playerLeft.size[2] < winSize[2] then
|
||||
playerLeft.pos[2] = playerLeft.pos[2] + PLAYER_SPEED * delta
|
||||
end
|
||||
|
||||
-- Right player controls.
|
||||
if RL_IsKeyDown( KEY_UP ) and 0 < playerRight.pos[2] then
|
||||
playerRight.pos[2] = playerRight.pos[2] - PLAYER_SPEED * delta
|
||||
elseif RL_IsKeyDown( KEY_DOWN ) and playerRight.pos[2] + playerRight.size[2] < winSize[2] then
|
||||
playerRight.pos[2] = playerRight.pos[2] + PLAYER_SPEED * delta
|
||||
end
|
||||
|
||||
-- Move ball.
|
||||
ball.pos = { ball.pos[1] + ball.vel[1] * delta,
|
||||
ball.pos[2] + ball.vel[2] * delta }
|
||||
|
||||
-- Bounce from window edge.
|
||||
if ( ball.pos[2] < ball.radius and ball.vel[2] < 0 )
|
||||
or ( winSize[2] < ball.pos[2] + ball.radius and 0 < ball.vel[2] ) then
|
||||
ball.vel[2] = -ball.vel[2]
|
||||
end
|
||||
|
||||
-- Bounce from players.
|
||||
local playerLeftRect = { playerLeft.pos[1], playerLeft.pos[2],
|
||||
playerLeft.size[1], playerLeft.size[2] }
|
||||
local playerRightRect = { playerRight.pos[1], playerRight.pos[2],
|
||||
playerRight.size[1], playerRight.size[2] }
|
||||
|
||||
if RL_CheckCollisionCircleRec( ball.pos, ball.radius, playerLeftRect ) and ball.vel[1] < 0 then
|
||||
ballHit( playerLeft.pos, playerLeft.size )
|
||||
elseif RL_CheckCollisionCircleRec( ball.pos, ball.radius, playerRightRect ) and 0 < ball.vel[1] then
|
||||
ballHit( playerRight.pos, playerRight.size )
|
||||
end
|
||||
|
||||
-- Score.
|
||||
if ball.pos[1] < 0 then
|
||||
playerRight.score = playerRight.score + 1
|
||||
reset()
|
||||
elseif winSize[1] < ball.pos[1] then
|
||||
playerLeft.score = playerLeft.score + 1
|
||||
reset()
|
||||
end
|
||||
end
|
||||
|
||||
function draw()
|
||||
RL_ClearBackground( BLACK )
|
||||
|
||||
-- Draw players.
|
||||
RL_DrawRectangle( { playerLeft.pos[1], playerLeft.pos[2], playerLeft.size[1], playerLeft.size[2] }, WHITE )
|
||||
RL_DrawRectangle( { playerRight.pos[1], playerRight.pos[2], playerRight.size[1], playerRight.size[2] }, WHITE )
|
||||
|
||||
-- Draw ball. Ball position will be the center in drawCircle.
|
||||
RL_DrawCircle( ball.pos, ball.radius, WHITE )
|
||||
|
||||
-- Draw scire
|
||||
RL_DrawText( 0, playerLeft.score, { 50, 10 }, 40, 2, WHITE )
|
||||
local rightTextSize = RL_MeasureText( 0, playerRight.score, 40, 2 )
|
||||
RL_DrawText( 0, playerRight.score, { winSize[1] - 50 - rightTextSize[1], 10 }, 40, 2, WHITE )
|
||||
end
|
||||
130
examples/pong_vec/main.lua
Normal file
130
examples/pong_vec/main.lua
Normal file
@@ -0,0 +1,130 @@
|
||||
-- Pong example using Vector2 library.
|
||||
|
||||
package.path = package.path..";"..RL_GetBasePath().."../resources/lib/?.lua"
|
||||
|
||||
Vec2 = require "vector2"
|
||||
|
||||
-- Settings.
|
||||
local winSize = Vec2:new( 800, 600 )
|
||||
local monitor = 0
|
||||
|
||||
-- Constants.
|
||||
local PLAYER_SPEED = 300
|
||||
local BALL_SPEED = 330
|
||||
|
||||
-- Game objects.
|
||||
local playerLeft = {
|
||||
pos = Vec2:new( 0, 0 ),
|
||||
size = Vec2:new( 10, 70 ),
|
||||
score = 0,
|
||||
}
|
||||
local playerRight = {
|
||||
pos = Vec2:new( 0, 0 ),
|
||||
size = Vec2:new( 10, 70 ),
|
||||
score = 0,
|
||||
}
|
||||
local ball = {
|
||||
pos = Vec2:new( 0, 0 ),
|
||||
radius = 8.0,
|
||||
vel = Vec2:new( 0, 0 ),
|
||||
}
|
||||
|
||||
local function reset()
|
||||
-- Initialize player positions.
|
||||
playerLeft.pos.x = playerLeft.size.x
|
||||
playerLeft.pos.y = winSize.y / 2 - playerLeft.size.y / 2
|
||||
|
||||
playerRight.pos.x = winSize.x - playerRight.size.x * 2
|
||||
playerRight.pos.y = winSize.y / 2 - playerRight.size.y / 2
|
||||
|
||||
-- Set ball to center.
|
||||
ball.pos:set( winSize.x / 2, winSize.y / 2 )
|
||||
-- Short for if math random result 1, set BALL_SPEED otherwise set -BALL_SPEED.
|
||||
ball.vel.x = math.random( 0, 1 ) == 1 and BALL_SPEED or -BALL_SPEED
|
||||
-- Start slow.
|
||||
ball.vel.y = 0
|
||||
end
|
||||
|
||||
local function ballHit( padPos, padSize )
|
||||
ball.vel.x = -ball.vel.x
|
||||
|
||||
local padCenter = padPos.y + padSize.y / 2
|
||||
local relHitPos = ball.pos.y - padCenter
|
||||
ball.vel.y = BALL_SPEED * relHitPos / padSize.y * 2
|
||||
end
|
||||
|
||||
function init()
|
||||
-- Set window to center of monitor.
|
||||
local mPos = Vec2:new( RL_GetMonitorPosition( monitor ) )
|
||||
local mSize = Vec2:new( RL_GetMonitorSize( monitor ) )
|
||||
|
||||
RL_SetWindowSize( winSize )
|
||||
RL_SetWindowPosition( { mPos.x + mSize.x / 2 - winSize.x / 2, mPos.y + mSize.y / 2 - winSize.y / 2 } )
|
||||
RL_SetWindowTitle( "Pong" )
|
||||
|
||||
-- Initialize ball pos.
|
||||
math.randomseed( os.time() )
|
||||
reset()
|
||||
end
|
||||
|
||||
function process( delta )
|
||||
-- Left player controls.
|
||||
if RL_IsKeyDown( string.byte( "W" ) ) and 0 < playerLeft.pos.y then
|
||||
playerLeft.pos.y = playerLeft.pos.y - PLAYER_SPEED * delta
|
||||
elseif RL_IsKeyDown( string.byte( "S" ) ) and playerLeft.pos.y + playerLeft.size.y < winSize.y then
|
||||
playerLeft.pos.y = playerLeft.pos.y + PLAYER_SPEED * delta
|
||||
end
|
||||
|
||||
-- Right player controls.
|
||||
if RL_IsKeyDown( KEY_UP ) and 0 < playerRight.pos.y then
|
||||
playerRight.pos.y = playerRight.pos.y - PLAYER_SPEED * delta
|
||||
elseif RL_IsKeyDown( KEY_DOWN ) and playerRight.pos.y + playerRight.size.y < winSize.y then
|
||||
playerRight.pos.y = playerRight.pos.y + PLAYER_SPEED * delta
|
||||
end
|
||||
|
||||
-- Move ball.
|
||||
ball.pos = ball.pos + ball.vel:scale( delta )
|
||||
|
||||
-- Bounce from window edge.
|
||||
if ( ball.pos.y < ball.radius and ball.vel.y < 0 )
|
||||
or ( winSize.y < ball.pos.y + ball.radius and 0 < ball.vel.y ) then
|
||||
ball.vel.y = -ball.vel.y
|
||||
end
|
||||
|
||||
-- Bounce from players.
|
||||
local playerLeftRect = { playerLeft.pos.x, playerLeft.pos.y,
|
||||
playerLeft.size.x, playerLeft.size.y }
|
||||
local playerRightRect = { playerRight.pos.x, playerRight.pos.y,
|
||||
playerRight.size.x, playerRight.size.y }
|
||||
|
||||
if RL_CheckCollisionCircleRec( ball.pos, ball.radius, playerLeftRect ) and ball.vel.x < 0 then
|
||||
ballHit( playerLeft.pos, playerLeft.size )
|
||||
elseif RL_CheckCollisionCircleRec( ball.pos, ball.radius, playerRightRect ) and 0 < ball.vel.x then
|
||||
ballHit( playerRight.pos, playerRight.size )
|
||||
end
|
||||
|
||||
-- Score.
|
||||
if ball.pos.x < 0 then
|
||||
playerRight.score = playerRight.score + 1
|
||||
reset()
|
||||
elseif winSize.x < ball.pos.x then
|
||||
playerLeft.score = playerLeft.score + 1
|
||||
reset()
|
||||
end
|
||||
end
|
||||
|
||||
function draw()
|
||||
RL_ClearBackground( BLACK )
|
||||
|
||||
-- Draw players.
|
||||
RL_DrawRectangle( { playerLeft.pos.x, playerLeft.pos.y, playerLeft.size.x, playerLeft.size.y }, WHITE )
|
||||
RL_DrawRectangle( { playerRight.pos.x, playerRight.pos.y, playerRight.size.x, playerRight.size.y }, WHITE )
|
||||
|
||||
-- Draw ball. Ball position will be the center in drawCircle.
|
||||
RL_DrawCircle( ball.pos, ball.radius, WHITE )
|
||||
|
||||
-- Draw scire
|
||||
RL_DrawText( 0, playerLeft.score, { 50, 10 }, 40, 2, WHITE )
|
||||
local rightTextSize = Vec2:new( RL_MeasureText( 0, playerRight.score, 40, 2 ) )
|
||||
RL_DrawText( 0, playerRight.score, { winSize.x - 50 - rightTextSize.x, 10 }, 40, 2, WHITE )
|
||||
end
|
||||
@@ -43,6 +43,10 @@ Vector2.meta = {
|
||||
}
|
||||
|
||||
function Vector2:new( x, y )
|
||||
if type( x ) == "table" then
|
||||
x, y = table.unpack( x )
|
||||
end
|
||||
|
||||
local o = {
|
||||
x = x,
|
||||
y = y,
|
||||
@@ -51,15 +55,23 @@ function Vector2:new( x, y )
|
||||
return o
|
||||
end
|
||||
|
||||
function Vector2:set( vec )
|
||||
self.x = vec[1]
|
||||
self.y = vec[2]
|
||||
function Vector2:set( x, y )
|
||||
if type( x ) == "table" then
|
||||
x, y = table.unpack( x )
|
||||
end
|
||||
|
||||
self.x = x
|
||||
self.y = y
|
||||
end
|
||||
|
||||
function Vector2:arr()
|
||||
return { self.x, self.y }
|
||||
end
|
||||
|
||||
function Vector2:unpack()
|
||||
return self.x, self.y
|
||||
end
|
||||
|
||||
function Vector2:clone()
|
||||
return Vector2:new( self.x, self.y )
|
||||
end
|
||||
@@ -68,45 +80,64 @@ function Vector2:abs()
|
||||
return Vector2:new( math.abs( self.x ), math.abs( self.y ) )
|
||||
end
|
||||
|
||||
function Vector2:min( v2 )
|
||||
return Vector2:new( math.min( self.x, v2.x ), math.min( self.y, v2.y ) )
|
||||
end
|
||||
|
||||
function Vector2:max( v2 )
|
||||
return Vector2:new( math.max( self.x, v2.x ), math.max( self.y, v2.y ) )
|
||||
end
|
||||
|
||||
function Vector2:addValue( value )
|
||||
return Vector2:new( RL_Vector2AddValue( self, value ) )
|
||||
end
|
||||
|
||||
function Vector2:subValue( value )
|
||||
return Vector2:new( RL_Vector2SubtractValue( self, value ) )
|
||||
end
|
||||
|
||||
function Vector2:length()
|
||||
return RL_Vector2Length( self:arr() )
|
||||
return RL_Vector2Length( self )
|
||||
end
|
||||
|
||||
function Vector2:lengthSqr()
|
||||
return RL_Vector2LengthSqr( self )
|
||||
end
|
||||
|
||||
function Vector2:dot( v2 )
|
||||
return RL_Vector2DotProduct( self:arr(), v2:arr() )
|
||||
return RL_Vector2DotProduct( self, v2 )
|
||||
end
|
||||
|
||||
function Vector2:distance( v2 )
|
||||
return RL_Vector2Distance( self:arr(), v2:arr() )
|
||||
return RL_Vector2Distance( self, v2 )
|
||||
end
|
||||
|
||||
function Vector2:angle( v2 )
|
||||
return RL_Vector2Angle( self:arr(), v2:arr() )
|
||||
return RL_Vector2Angle( self, v2 )
|
||||
end
|
||||
|
||||
function Vector2:scale( scale )
|
||||
return Vector2:new( RL_Vector2Scale( self, scale ) )
|
||||
end
|
||||
|
||||
function Vector2:normalize()
|
||||
local r = RL_Vector2Normalize( self:arr() )
|
||||
return Vector2:new( r[1], r[2] )
|
||||
return Vector2:new( RL_Vector2Normalize( self ) )
|
||||
end
|
||||
|
||||
function Vector2:lerp( v2, value )
|
||||
local r = RL_Vector2Lerp( self:arr(), v2:arr(), value )
|
||||
return Vector2:new( r[1], r[2] )
|
||||
return Vector2:new( RL_Vector2Lerp( self, v2, value ) )
|
||||
end
|
||||
|
||||
function Vector2:reflect( normal )
|
||||
local r = RL_Vector2Reflect( self:arr(), normal:arr() )
|
||||
return Vector2:new( r[1], r[2] )
|
||||
return Vector2:new( RL_Vector2Reflect( self, normal ) )
|
||||
end
|
||||
|
||||
function Vector2:rotate( angle )
|
||||
local r = RL_Vector2Rotate( self:arr(), angle )
|
||||
return Vector2:new( r[1], r[2] )
|
||||
return Vector2:new( RL_Vector2Rotate( self, angle ) )
|
||||
end
|
||||
|
||||
function Vector2:moveTowards( target, maxDistance )
|
||||
local r = RL_Vector2MoveTowards( self:arr(), target:arr(), maxDistance )
|
||||
return Vector2:new( r[1], r[2] )
|
||||
return Vector2:new( RL_Vector2MoveTowards( self, target, maxDistance ) )
|
||||
end
|
||||
|
||||
return Vector2
|
||||
|
||||
@@ -43,6 +43,10 @@ Vector3.meta = {
|
||||
}
|
||||
|
||||
function Vector3:new( x, y, z )
|
||||
if type( x ) == "table" then
|
||||
x, y, z = table.unpack( x )
|
||||
end
|
||||
|
||||
local o = {
|
||||
x = x,
|
||||
y = y,
|
||||
@@ -52,16 +56,24 @@ function Vector3:new( x, y, z )
|
||||
return o
|
||||
end
|
||||
|
||||
function Vector3:set( vec )
|
||||
self.x = vec[1]
|
||||
self.y = vec[2]
|
||||
self.z = vec[3]
|
||||
function Vector3:set( x, y, z )
|
||||
if type( x ) == "table" then
|
||||
x, y, z = table.unpack( x )
|
||||
end
|
||||
|
||||
self.x = x
|
||||
self.y = y
|
||||
self.z = z
|
||||
end
|
||||
|
||||
function Vector3:arr()
|
||||
return { self.x, self.y, self.z }
|
||||
end
|
||||
|
||||
function Vector3:unpack()
|
||||
return self.x, self.y, self.z
|
||||
end
|
||||
|
||||
function Vector3:clone()
|
||||
return Vector3:new( self.x, self.y, self.z )
|
||||
end
|
||||
@@ -70,60 +82,81 @@ function Vector3:abs()
|
||||
return Vector3:new( math.abs( self.x ), math.abs( self.y ), math.abs( self.z ) )
|
||||
end
|
||||
|
||||
function Vector3:min( v2 )
|
||||
return Vector3:new( RL_Vector3Min( self, v2 ) )
|
||||
end
|
||||
|
||||
function Vector3:max( v2 )
|
||||
return Vector3:new( RL_Vector3Max( self, v2 ) )
|
||||
end
|
||||
|
||||
function Vector3:addValue( value )
|
||||
return Vector3:new( RL_Vector3AddValue( self, value ) )
|
||||
end
|
||||
|
||||
function Vector3:subValue( value )
|
||||
return Vector3:new( RL_Vector3SubtractValue( self, value ) )
|
||||
end
|
||||
|
||||
function Vector3:scale( scalar )
|
||||
return Vector3:new( RL_Vector3Scale( self, scalar ) )
|
||||
end
|
||||
|
||||
function Vector3:cross( v2 )
|
||||
local r = RL_Vector3CrossProduct( self:arr(), v2:arr() )
|
||||
return Vector3:new( r[1], r[2], r[3] )
|
||||
return Vector3:new( RL_Vector3CrossProduct( self, v2 ) )
|
||||
end
|
||||
|
||||
function Vector3:perpendicular()
|
||||
local r = RL_Vector3Perpendicular( self:arr() )
|
||||
return Vector3:new( r[1], r[2], r[3] )
|
||||
return Vector3:new( RL_Vector3Perpendicular( self ) )
|
||||
end
|
||||
|
||||
function Vector3:length()
|
||||
return RL_Vector3Length( self:arr() )
|
||||
return RL_Vector3Length( self )
|
||||
end
|
||||
|
||||
function Vector3:lengthSqr()
|
||||
return RL_Vector3LengthSqr( self:arr() )
|
||||
return RL_Vector3LengthSqr( self )
|
||||
end
|
||||
|
||||
function Vector3:dot( v2 )
|
||||
return RL_Vector3DotProduct( self:arr(), v2:arr() )
|
||||
return RL_Vector3DotProduct( self, v2 )
|
||||
end
|
||||
|
||||
function Vector3:distance( v2 )
|
||||
return RL_Vector3Distance( self:arr(), v2:arr() )
|
||||
return RL_Vector3Distance( self, v2 )
|
||||
end
|
||||
|
||||
function Vector3:angle( v2 )
|
||||
return RL_Vector3Angle( self, v2 )
|
||||
end
|
||||
|
||||
function Vector3:negate()
|
||||
return Vector3:new( RL_Vector3Negate( self ) )
|
||||
end
|
||||
|
||||
function Vector3:normalize()
|
||||
local r = RL_Vector3Normalize( self:arr() )
|
||||
return Vector3:new( r[1], r[2], r[3] )
|
||||
return Vector3:new( RL_Vector3Normalize( self ) )
|
||||
end
|
||||
|
||||
function Vector3:orthoNormalize( v2 )
|
||||
local r1, r2 = RL_Vector3OrthoNormalize( self:arr(), v2:arr() )
|
||||
local r1, r2 = RL_Vector3OrthoNormalize( self, v2 )
|
||||
return Vector3:new( r1[1], r1[2], r1[3] ), Vector3:new( r2[1], r2[2], r2[3] )
|
||||
end
|
||||
|
||||
function Vector3:transform( mat )
|
||||
local r = RL_Vector3Transform( self:arr(), mat )
|
||||
return Vector3:new( r[1], r[2], r[3] )
|
||||
return Vector3:new( RL_Vector3Transform( self, mat ) )
|
||||
end
|
||||
|
||||
function Vector3:rotateByQuaternion( qua )
|
||||
local r = RL_Vector3RotateByQuaternion( self:arr(), qua )
|
||||
return Vector3:new( r[1], r[2], r[3] )
|
||||
function Vector3:rotateByQuaternion( q )
|
||||
return Vector3:new( RL_Vector3RotateByQuaternion( self, q ) )
|
||||
end
|
||||
|
||||
function Vector3:lerp( v2, value )
|
||||
local r = RL_Vector3Lerp( self:arr(), v2:arr(), value )
|
||||
return Vector3:new( r[1], r[2], r[3] )
|
||||
return Vector3:new( RL_Vector3Lerp( self, v2, value ) )
|
||||
end
|
||||
|
||||
function Vector3:reflect( normal )
|
||||
local r = RL_Vector3Reflect( self:arr(), normal:arr() )
|
||||
return Vector3:new( r[1], r[2], r[3] )
|
||||
return Vector3:new( RL_Vector3Reflect( self, normal ) )
|
||||
end
|
||||
|
||||
return Vector3
|
||||
|
||||
@@ -3,8 +3,9 @@
|
||||
#define STRING_LEN 1024
|
||||
|
||||
#define VERSION_MAJOR 0
|
||||
#define VERSION_MINOR 2
|
||||
#define VERSION_MINOR 3
|
||||
#define VERSION_PATCH 0
|
||||
#define VERSION_DEV 1
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
136
src/lua_core.c
136
src/lua_core.c
@@ -1024,6 +1024,7 @@ Color uluaGetColor( lua_State *L ) {
|
||||
|
||||
while ( lua_next( L, t ) != 0 ) {
|
||||
if ( lua_isnumber( L, -1 ) ) {
|
||||
if ( lua_isnumber( L, -2 ) ) {
|
||||
switch ( i ) {
|
||||
case 0:
|
||||
color.r = (uint8_t)lua_tointeger( L, -1 );
|
||||
@@ -1041,9 +1042,24 @@ Color uluaGetColor( lua_State *L ) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if ( lua_isstring( L, -2 ) ) {
|
||||
if ( strcmp( "r", (char*)lua_tostring( L, -2 ) ) == 0 ) {
|
||||
color.r = (uint8_t)lua_tointeger( L, -1 );
|
||||
}
|
||||
else if ( strcmp( "g", (char*)lua_tostring( L, -2 ) ) == 0 ) {
|
||||
color.g = (uint8_t)lua_tointeger( L, -1 );
|
||||
}
|
||||
else if ( strcmp( "b", (char*)lua_tostring( L, -2 ) ) == 0 ) {
|
||||
color.b = (uint8_t)lua_tointeger( L, -1 );
|
||||
}
|
||||
else if ( strcmp( "a", (char*)lua_tostring( L, -2 ) ) == 0 ) {
|
||||
color.a = (uint8_t)lua_tointeger( L, -1 );
|
||||
}
|
||||
}
|
||||
i++;
|
||||
lua_pop( L, 1 );
|
||||
}
|
||||
}
|
||||
return color;
|
||||
}
|
||||
|
||||
@@ -1059,6 +1075,7 @@ Vector2 uluaGetVector2( lua_State *L ) {
|
||||
|
||||
while ( lua_next( L, t ) != 0 ) {
|
||||
if ( lua_isnumber( L, -1 ) ) {
|
||||
if ( lua_isnumber( L, -2 ) ) {
|
||||
switch ( i ) {
|
||||
case 0:
|
||||
vector.x = lua_tonumber( L, -1 );
|
||||
@@ -1070,9 +1087,18 @@ Vector2 uluaGetVector2( lua_State *L ) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if ( lua_isstring( L, -2 ) ) {
|
||||
if ( strcmp( "x", (char*)lua_tostring( L, -2 ) ) == 0 ) {
|
||||
vector.x = lua_tonumber( L, -1 );
|
||||
}
|
||||
else if ( strcmp( "y", (char*)lua_tostring( L, -2 ) ) == 0 ) {
|
||||
vector.y = lua_tonumber( L, -1 );
|
||||
}
|
||||
}
|
||||
i++;
|
||||
lua_pop( L, 1 );
|
||||
}
|
||||
}
|
||||
return vector;
|
||||
}
|
||||
|
||||
@@ -1088,6 +1114,7 @@ Vector3 uluaGetVector3( lua_State *L ) {
|
||||
|
||||
while ( lua_next( L, t ) != 0 ) {
|
||||
if ( lua_isnumber( L, -1 ) ) {
|
||||
if ( lua_isnumber( L, -2 ) ) {
|
||||
switch ( i ) {
|
||||
case 0:
|
||||
vector.x = lua_tonumber( L, -1 );
|
||||
@@ -1102,6 +1129,18 @@ Vector3 uluaGetVector3( lua_State *L ) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if ( lua_isstring( L, -2 ) ) {
|
||||
if ( strcmp( "x", (char*)lua_tostring( L, -2 ) ) == 0 ) {
|
||||
vector.x = lua_tonumber( L, -1 );
|
||||
}
|
||||
else if ( strcmp( "y", (char*)lua_tostring( L, -2 ) ) == 0 ) {
|
||||
vector.y = lua_tonumber( L, -1 );
|
||||
}
|
||||
else if ( strcmp( "z", (char*)lua_tostring( L, -2 ) ) == 0 ) {
|
||||
vector.z = lua_tonumber( L, -1 );
|
||||
}
|
||||
}
|
||||
}
|
||||
i++;
|
||||
lua_pop( L, 1 );
|
||||
}
|
||||
@@ -1120,6 +1159,7 @@ Vector4 uluaGetVector4( lua_State *L ) {
|
||||
|
||||
while ( lua_next( L, t ) != 0 ) {
|
||||
if ( lua_isnumber( L, -1 ) ) {
|
||||
if ( lua_isnumber( L, -2 ) ) {
|
||||
switch ( i ) {
|
||||
case 0:
|
||||
vector.x = lua_tonumber( L, -1 );
|
||||
@@ -1137,6 +1177,21 @@ Vector4 uluaGetVector4( lua_State *L ) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if ( lua_isstring( L, -2 ) ) {
|
||||
if ( strcmp( "x", (char*)lua_tostring( L, -2 ) ) == 0 ) {
|
||||
vector.x = lua_tonumber( L, -1 );
|
||||
}
|
||||
else if ( strcmp( "y", (char*)lua_tostring( L, -2 ) ) == 0 ) {
|
||||
vector.y = lua_tonumber( L, -1 );
|
||||
}
|
||||
else if ( strcmp( "z", (char*)lua_tostring( L, -2 ) ) == 0 ) {
|
||||
vector.z = lua_tonumber( L, -1 );
|
||||
}
|
||||
else if ( strcmp( "w", (char*)lua_tostring( L, -2 ) ) == 0 ) {
|
||||
vector.w = lua_tonumber( L, -1 );
|
||||
}
|
||||
}
|
||||
}
|
||||
i++;
|
||||
lua_pop( L, 1 );
|
||||
}
|
||||
@@ -1155,6 +1210,7 @@ Rectangle uluaGetRectangle( lua_State *L ) {
|
||||
|
||||
while ( lua_next( L, t ) != 0 ) {
|
||||
if ( lua_isnumber( L, -1 ) ) {
|
||||
if ( lua_isnumber( L, -2 ) ) {
|
||||
switch ( i ) {
|
||||
case 0:
|
||||
rect.x = lua_tonumber( L, -1 );
|
||||
@@ -1172,6 +1228,21 @@ Rectangle uluaGetRectangle( lua_State *L ) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if ( lua_isstring( L, -2 ) ) {
|
||||
if ( strcmp( "x", (char*)lua_tostring( L, -2 ) ) == 0 ) {
|
||||
rect.x = lua_tonumber( L, -1 );
|
||||
}
|
||||
else if ( strcmp( "y", (char*)lua_tostring( L, -2 ) ) == 0 ) {
|
||||
rect.y = lua_tonumber( L, -1 );
|
||||
}
|
||||
else if ( strcmp( "width", (char*)lua_tostring( L, -2 ) ) == 0 ) {
|
||||
rect.width = lua_tonumber( L, -1 );
|
||||
}
|
||||
else if ( strcmp( "height", (char*)lua_tostring( L, -2 ) ) == 0 ) {
|
||||
rect.height = lua_tonumber( L, -1 );
|
||||
}
|
||||
}
|
||||
}
|
||||
i++;
|
||||
lua_pop( L, 1 );
|
||||
}
|
||||
@@ -1190,6 +1261,7 @@ Quaternion uluaGetQuaternion( lua_State *L ) {
|
||||
|
||||
while ( lua_next( L, t ) != 0 ) {
|
||||
if ( lua_isnumber( L, -1 ) ) {
|
||||
if ( lua_isnumber( L, -2 ) ) {
|
||||
switch ( i ) {
|
||||
case 0:
|
||||
quaternion.x = lua_tonumber( L, -1 );
|
||||
@@ -1207,6 +1279,21 @@ Quaternion uluaGetQuaternion( lua_State *L ) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if ( lua_isstring( L, -2 ) ) {
|
||||
if ( strcmp( "x", (char*)lua_tostring( L, -2 ) ) == 0 ) {
|
||||
quaternion.x = lua_tonumber( L, -1 );
|
||||
}
|
||||
else if ( strcmp( "y", (char*)lua_tostring( L, -2 ) ) == 0 ) {
|
||||
quaternion.y = lua_tonumber( L, -1 );
|
||||
}
|
||||
else if ( strcmp( "z", (char*)lua_tostring( L, -2 ) ) == 0 ) {
|
||||
quaternion.z = lua_tonumber( L, -1 );
|
||||
}
|
||||
else if ( strcmp( "w", (char*)lua_tostring( L, -2 ) ) == 0 ) {
|
||||
quaternion.w = lua_tonumber( L, -1 );
|
||||
}
|
||||
}
|
||||
}
|
||||
i++;
|
||||
lua_pop( L, 1 );
|
||||
}
|
||||
@@ -1259,7 +1346,8 @@ BoundingBox uluaGetBoundingBox( lua_State *L ) {
|
||||
lua_pushnil( L );
|
||||
|
||||
while ( lua_next( L, t ) != 0 ) {
|
||||
if ( lua_istable( L, -1 ) ) {
|
||||
if ( lua_isnumber( L, -1 ) ) {
|
||||
if ( lua_isnumber( L, -2 ) ) {
|
||||
switch ( i ) {
|
||||
case 0:
|
||||
box.min = uluaGetVector3( L );
|
||||
@@ -1271,9 +1359,18 @@ BoundingBox uluaGetBoundingBox( lua_State *L ) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if ( lua_isstring( L, -2 ) ) {
|
||||
if ( strcmp( "min", (char*)lua_tostring( L, -2 ) ) == 0 ) {
|
||||
box.min = uluaGetVector3( L );
|
||||
}
|
||||
else if ( strcmp( "max", (char*)lua_tostring( L, -2 ) ) == 0 ) {
|
||||
box.max = uluaGetVector3( L );
|
||||
}
|
||||
}
|
||||
i++;
|
||||
lua_pop( L, 1 );
|
||||
}
|
||||
}
|
||||
|
||||
return box;
|
||||
}
|
||||
@@ -1289,7 +1386,8 @@ Ray uluaGetRay( lua_State *L ) {
|
||||
lua_pushnil( L );
|
||||
|
||||
while ( lua_next( L, t ) != 0 ) {
|
||||
if ( lua_istable( L, -1 ) ) {
|
||||
if ( lua_isnumber( L, -1 ) ) {
|
||||
if ( lua_isnumber( L, -2 ) ) {
|
||||
switch ( i ) {
|
||||
case 0:
|
||||
ray.position = uluaGetVector3( L );
|
||||
@@ -1301,9 +1399,18 @@ Ray uluaGetRay( lua_State *L ) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if ( lua_isstring( L, -2 ) ) {
|
||||
if ( strcmp( "position", (char*)lua_tostring( L, -2 ) ) == 0 ) {
|
||||
ray.position = uluaGetVector3( L );
|
||||
}
|
||||
else if ( strcmp( "direction", (char*)lua_tostring( L, -2 ) ) == 0 ) {
|
||||
ray.direction = uluaGetVector3( L );
|
||||
}
|
||||
}
|
||||
i++;
|
||||
lua_pop( L, 1 );
|
||||
}
|
||||
}
|
||||
|
||||
return ray;
|
||||
}
|
||||
@@ -1319,6 +1426,8 @@ NPatchInfo uluaGetNPatchInfo( lua_State *L ) {
|
||||
lua_pushnil( L );
|
||||
|
||||
while ( lua_next( L, t ) != 0 ) {
|
||||
if ( lua_isnumber( L, -1 ) ) {
|
||||
if ( lua_isnumber( L, -2 ) ) {
|
||||
switch ( i ) {
|
||||
case 0:
|
||||
npatch.source = uluaGetRectangle( L );
|
||||
@@ -1341,10 +1450,31 @@ NPatchInfo uluaGetNPatchInfo( lua_State *L ) {
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if ( lua_isstring( L, -2 ) ) {
|
||||
if ( strcmp( "source", (char*)lua_tostring( L, -2 ) ) == 0 ) {
|
||||
npatch.source = uluaGetRectangle( L );
|
||||
}
|
||||
else if ( strcmp( "left", (char*)lua_tostring( L, -2 ) ) == 0 ) {
|
||||
npatch.left = lua_tointeger( L, -1 );
|
||||
}
|
||||
else if ( strcmp( "top", (char*)lua_tostring( L, -2 ) ) == 0 ) {
|
||||
npatch.top = lua_tointeger( L, -1 );
|
||||
}
|
||||
else if ( strcmp( "right", (char*)lua_tostring( L, -2 ) ) == 0 ) {
|
||||
npatch.right = lua_tointeger( L, -1 );
|
||||
}
|
||||
else if ( strcmp( "bottom", (char*)lua_tostring( L, -2 ) ) == 0 ) {
|
||||
npatch.bottom = lua_tointeger( L, -1 );
|
||||
}
|
||||
else if ( strcmp( "layout", (char*)lua_tostring( L, -2 ) ) == 0 ) {
|
||||
npatch.layout = lua_tointeger( L, -1 );
|
||||
}
|
||||
}
|
||||
i++;
|
||||
lua_pop( L, 1 );
|
||||
}
|
||||
|
||||
}
|
||||
return npatch;
|
||||
}
|
||||
|
||||
|
||||
14
src/main.c
14
src/main.c
@@ -2,13 +2,21 @@
|
||||
#include "state.h"
|
||||
#include "lua_core.h"
|
||||
|
||||
inline static void printVersion() {
|
||||
if ( VERSION_DEV ) {
|
||||
TraceLog( LOG_INFO, "ReiLua %d.%d.%d-Dev", VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH );
|
||||
}
|
||||
else {
|
||||
TraceLog( LOG_INFO, "ReiLua %d.%d.%d", VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH );
|
||||
}
|
||||
}
|
||||
|
||||
int main( int argn, const char **argc ) {
|
||||
char exePath[ STRING_LEN ] = { '\0' };
|
||||
|
||||
if ( 1 < argn ) {
|
||||
if ( strcmp( argc[1], "--version" ) == 0 || strcmp( argc[1], "-v" ) == 0 ) {
|
||||
printf( "ReiLua %d.%d.%d\n", VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH );
|
||||
|
||||
printVersion();
|
||||
return 1;
|
||||
}
|
||||
else{
|
||||
@@ -18,7 +26,7 @@ int main( int argn, const char **argc ) {
|
||||
else {
|
||||
sprintf( exePath, "%s/", GetWorkingDirectory() );
|
||||
}
|
||||
TraceLog( LOG_INFO, "ReiLua %d.%d.%d", VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH );
|
||||
printVersion();
|
||||
stateInit( exePath );
|
||||
|
||||
while ( state->run ) {
|
||||
|
||||
@@ -1202,7 +1202,7 @@ int lmodelsUpdateMesh( lua_State *L ) {
|
||||
i++;
|
||||
lua_pop( L, 1 );
|
||||
}
|
||||
UpdateMeshBuffer( *mesh, 3, (void*)data, len * 4 * sizeof(unsigned char), 0 );
|
||||
UpdateMeshBuffer( *mesh, 3, (void*)data, len * 4 * sizeof( unsigned char ), 0 );
|
||||
}
|
||||
else if ( strcmp( "indices", (char*)lua_tostring( L, -2 ) ) == 0 && lua_istable( L, -1 ) ) {
|
||||
size_t len = uluaGetTableLen( L );
|
||||
@@ -1217,7 +1217,7 @@ int lmodelsUpdateMesh( lua_State *L ) {
|
||||
i++;
|
||||
lua_pop( L, 1 );
|
||||
}
|
||||
UpdateMeshBuffer( *mesh, 6, (void*)data, len * sizeof(unsigned short), 0 );
|
||||
UpdateMeshBuffer( *mesh, 6, (void*)data, len * sizeof( unsigned short ), 0 );
|
||||
}
|
||||
lua_pop( L, 1 );
|
||||
}
|
||||
@@ -2245,7 +2245,7 @@ int lmodelsGetRayCollisionModel( lua_State *L ) {
|
||||
lua_pushnil( L );
|
||||
return 1;
|
||||
}
|
||||
// uluaPushRayCollision( L, GetRayCollisionModel( ray, *state->models[ modelId ] ) );
|
||||
uluaPushRayCollision( L, GetRayCollisionModel( ray, *state->models[ modelId ] ) );
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user