LuaJIT compatibility.
This commit is contained in:
@@ -126,7 +126,7 @@ function RL.draw()
|
||||
RL.DrawCircle( ball.pos, ball.radius, RL.WHITE )
|
||||
|
||||
-- Draw score.
|
||||
RL.DrawText( 0, playerLeft.score, { 50, 10 }, 40, 2, RL.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, RL.WHITE )
|
||||
RL.DrawText( 0, tostring( playerLeft.score ), { 50, 10 }, 40, 2, RL.WHITE )
|
||||
local rightTextSize = Vec2:new( RL.MeasureText( 0, tostring( playerRight.score ), 40, 2 ) )
|
||||
RL.DrawText( 0, tostring( playerRight.score ), { winSize.x - 50 - rightTextSize.x, 10 }, 40, 2, RL.WHITE )
|
||||
end
|
||||
|
||||
23
examples/resources/lib/bitlib.lua
Normal file
23
examples/resources/lib/bitlib.lua
Normal file
@@ -0,0 +1,23 @@
|
||||
local bitlib = {}
|
||||
|
||||
function bitlib.setBit( v, i, b )
|
||||
if b then
|
||||
return v | 1 << i
|
||||
else
|
||||
return v & ~( 1 << i )
|
||||
end
|
||||
end
|
||||
|
||||
function bitlib.toggleBit( v, i )
|
||||
return v ~ ( 1 << i )
|
||||
end
|
||||
|
||||
function bitlib.getBit( v, i )
|
||||
if v == nil then
|
||||
return false
|
||||
end
|
||||
|
||||
return v & ( 1 << i ) > 0
|
||||
end
|
||||
|
||||
return bitlib
|
||||
@@ -41,27 +41,6 @@ function utillib.clamp( val, min, max )
|
||||
return math.max( min, math.min( val, max ) )
|
||||
end
|
||||
|
||||
-- Returns changed value ( value to be changed, index, state( bool ) )
|
||||
function utillib.setBit( v, i, b )
|
||||
if b then
|
||||
return v | 1 << i
|
||||
else
|
||||
return v & ~( 1 << i )
|
||||
end
|
||||
end
|
||||
|
||||
function utillib.toggleBit( v, i )
|
||||
return v ~ ( 1 << i )
|
||||
end
|
||||
|
||||
function utillib.getBit( v, i )
|
||||
if v == nil then
|
||||
return false
|
||||
end
|
||||
|
||||
return v & ( 1 << i ) > 0
|
||||
end
|
||||
|
||||
function utillib.utf8Sub( s, i, j )
|
||||
i = i or 1
|
||||
j = j or -1
|
||||
@@ -114,9 +93,6 @@ function utillib.split( str, sep )
|
||||
for str in string.gmatch( str, "([^"..sep.."]+)" ) do
|
||||
table.insert( t, str )
|
||||
end
|
||||
-- for s in string.gmatch( str, "([^"..sep.."]+)" ) do
|
||||
-- table.insert( t, s )
|
||||
-- end
|
||||
|
||||
return t
|
||||
end
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
-- For luaJit compatibility.
|
||||
if table.unpack == nil then
|
||||
table.unpack = unpack
|
||||
end
|
||||
|
||||
Vector2 = {}
|
||||
Vector2.meta = {
|
||||
__index = Vector2,
|
||||
@@ -25,9 +30,6 @@ Vector2.meta = {
|
||||
__unm = function( v )
|
||||
return Vector2:new( -v.x, -v.y )
|
||||
end,
|
||||
__idiv = function( v, value )
|
||||
return Vector2:new( v.x // value, v.y // value )
|
||||
end,
|
||||
__len = function( v )
|
||||
local len = 0
|
||||
|
||||
@@ -90,6 +92,14 @@ function Vector2:max( v2 )
|
||||
return Vector2:new( math.max( self.x, v2.x ), math.max( self.y, v2.y ) )
|
||||
end
|
||||
|
||||
function Vector2:floor()
|
||||
return Vector2:new( math.floor( self.x ), math.floor( self.y ) )
|
||||
end
|
||||
|
||||
function Vector2:ceil()
|
||||
return Vector2:new( math.ceil( self.x ), math.ceil( self.y ) )
|
||||
end
|
||||
|
||||
function Vector2:addValue( value )
|
||||
return Vector2:new( RL.Vector2AddValue( self, value ) )
|
||||
end
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
-- For luaJit compatibility.
|
||||
if table.unpack == nil then
|
||||
table.unpack = unpack
|
||||
end
|
||||
|
||||
Vector3 = {}
|
||||
Vector3.meta = {
|
||||
__index = Vector3,
|
||||
@@ -25,9 +30,6 @@ Vector3.meta = {
|
||||
__unm = function( v )
|
||||
return Vector3:new( -v.x, -v.y, -v.z )
|
||||
end,
|
||||
__idiv = function( v, value )
|
||||
return Vector3:new( v.x // value, v.y // value, v.z // value )
|
||||
end,
|
||||
__len = function( v )
|
||||
local len = 0
|
||||
|
||||
@@ -94,6 +96,14 @@ function Vector3:max( v2 )
|
||||
return Vector3:new( RL.Vector3Max( self, v2 ) )
|
||||
end
|
||||
|
||||
function Vector3:floor()
|
||||
return Vector3:new( math.floor( self.x ), math.floor( self.y ), math.floor( self.z ) )
|
||||
end
|
||||
|
||||
function Vector3:ceil()
|
||||
return Vector3:new( math.ceil( self.x ), math.ceil( self.y ), math.ceil( self.z ) )
|
||||
end
|
||||
|
||||
function Vector3:addValue( value )
|
||||
return Vector3:new( RL.Vector3AddValue( self, value ) )
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user