summaryrefslogtreecommitdiff
path: root/examples/resources/lib
diff options
context:
space:
mode:
authorjussi2024-11-21 18:02:06 +0200
committerjussi2024-11-21 18:02:06 +0200
commitd96e33bb1772c28f630de32e09201c0cdea6f896 (patch)
tree6f17dcdf04c476b6a152d2b0aa3698c1fe0ab910 /examples/resources/lib
parent3d5eeac3d7e73a71cd476afed556e76fd9b5fe07 (diff)
downloadreilua-enhanced-d96e33bb1772c28f630de32e09201c0cdea6f896.tar.gz
reilua-enhanced-d96e33bb1772c28f630de32e09201c0cdea6f896.tar.bz2
reilua-enhanced-d96e33bb1772c28f630de32e09201c0cdea6f896.zip
Updated examples to ReiLua 0.9.0.
Diffstat (limited to 'examples/resources/lib')
-rw-r--r--examples/resources/lib/camera3d.lua6
-rw-r--r--examples/resources/lib/utillib.lua38
2 files changed, 30 insertions, 14 deletions
diff --git a/examples/resources/lib/camera3d.lua b/examples/resources/lib/camera3d.lua
index 6acb78b..f9a9a50 100644
--- a/examples/resources/lib/camera3d.lua
+++ b/examples/resources/lib/camera3d.lua
@@ -92,8 +92,6 @@ function Camera3D:getUpward()
end
function Camera3D:update( delta )
- delta = 1 / 60 -- Hack for framerate independance.
-
if self.mode == self.MODES.FREE then
if RL.IsMouseButtonDown( RL.MOUSE_BUTTON_MIDDLE ) then
local mouseDelta = Vector2:newT( RL.GetMouseDelta() )
@@ -109,7 +107,7 @@ function Camera3D:update( delta )
mouseDelta = mouseDelta:scale( self.TURN_SPEED * delta )
RL.Camera3DYaw( self.camera, -mouseDelta.x, true )
- RL.Camera3DPitch( self.camera, -mouseDelta.y, false, true, false )
+ RL.Camera3DPitch( self.camera, -mouseDelta.y, true, true, false )
end
end
@@ -124,7 +122,7 @@ function Camera3D:update( delta )
mouseDelta = mouseDelta:scale( self.TURN_SPEED * delta )
RL.Camera3DYaw( self.camera, -mouseDelta.x, false )
- RL.Camera3DPitch( self.camera, -mouseDelta.y, false, false, false )
+ RL.Camera3DPitch( self.camera, -mouseDelta.y, true, false, false )
RL.SetMousePosition( Vector2:newT( RL.GetScreenSize() ):scale( 0.5 ) )
local distance = self.KEYBOARD_MOVE_SPEED * delta
diff --git a/examples/resources/lib/utillib.lua b/examples/resources/lib/utillib.lua
index c66cf26..42a331c 100644
--- a/examples/resources/lib/utillib.lua
+++ b/examples/resources/lib/utillib.lua
@@ -59,7 +59,7 @@ function utillib.utf8Sub( s, i, j )
i = utf8.offset( s, i )
j = utf8.offset( s, j + 1 )
-
+
if i and j then
return s:sub( i, j - 1 )
elseif i then
@@ -147,27 +147,25 @@ function utillib.printt( t )
print( "}" )
end
-function utillib.colorLerp( a, b, f )
- return {
- utillib.round( utillib.lerp( a[1], b[1], f ) ),
- utillib.round( utillib.lerp( a[2], b[2], f ) ),
- utillib.round( utillib.lerp( a[3], b[3], f ) )
- }
-end
-
-- Move secuence of elements inside table.
function utillib.tableMove( t, src, len, dest )
local copy = table.move( t, src, src + len - 1, 1, {} )
if src >= dest then
table.move( t, dest, src - 1, dest + len )
- else
+ else
table.move( t, src + len, dest + len - 1, src )
end
table.move( copy, 1, len, dest, t )
end
+function utillib.reverseTable( t )
+ for i = 1, math.floor( #t / 2 ), 1 do
+ t[i], t[ #t - i + 1 ] = t[ #t - i + 1 ], t[i]
+ end
+end
+
function utillib.randomFloat( min, max )
return min + math.random() * ( max - min );
end
@@ -183,4 +181,24 @@ function utillib.printBin( v )
print()
end
+function utillib.capitalize( str )
+ return string.format( "%s%s", str:sub( 1, 1 ):upper(), str:sub( 2, -1 ) )
+end
+
+function utillib.doString( str )
+ local func, err = load( str )
+
+ if func then
+ local success, result = pcall( func )
+
+ if success then
+ return result
+ else
+ RL.TraceLog( RL.LOG_WARNING, "Execution error: "..result )
+ end
+ else
+ RL.TraceLog( RL.LOG_WARNING, "Compilation error: "..err )
+ end
+end
+
return utillib