summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjussi2022-11-11 19:23:35 +0200
committerjussi2022-11-11 19:23:35 +0200
commit921ed3b07f4e8c643161a08744b75562055077ff (patch)
treeee10fca564fd0c9417aa6c40561e994446748549
parent1094b1f833553c26125affddf991f8c7f72da225 (diff)
downloadreilua-enhanced-921ed3b07f4e8c643161a08744b75562055077ff.tar.gz
reilua-enhanced-921ed3b07f4e8c643161a08744b75562055077ff.tar.bz2
reilua-enhanced-921ed3b07f4e8c643161a08744b75562055077ff.zip
Lua interpreter mode and easings module.
-rw-r--r--API.md261
-rw-r--r--CMakeLists.txt1
-rw-r--r--README.md9
-rw-r--r--changelog12
-rw-r--r--doc_parser.lua1
-rw-r--r--examples/platformer/main.lua6
-rw-r--r--examples/resources/lib/utillib.lua16
-rw-r--r--examples/resources/lib/vector2.lua1
-rw-r--r--examples/resources/lib/vector3.lua1
-rw-r--r--include/easings.h263
-rw-r--r--include/main.h4
-rw-r--r--include/reasings.h44
-rw-r--r--include/state.h1
-rw-r--r--src/easings.c516
-rw-r--r--src/lua_core.c50
-rw-r--r--src/main.c44
-rw-r--r--src/state.c9
17 files changed, 1212 insertions, 27 deletions
diff --git a/API.md b/API.md
index 40e005f..c30e84a 100644
--- a/API.md
+++ b/API.md
@@ -6207,3 +6207,264 @@ Get the line drawing width
- Success return float
---
+
+## Easings - Linear Easing functions
+
+---
+
+> value = RL_EaseLinear( float t, float b, float c, float d )
+
+Ease linear
+
+- Failure return false
+- Success return float
+
+---
+
+## Easings - Sine Easing functions
+
+---
+
+> value = RL_EaseSineIn( float t, float b, float c, float d )
+
+Ease sine in
+
+- Failure return false
+- Success return float
+
+---
+
+> value = RL_EaseSineOut( float t, float b, float c, float d )
+
+Ease sine out
+
+- Failure return false
+- Success return float
+
+---
+
+> value = RL_EaseSineInOut( float t, float b, float c, float d )
+
+Ease sine in out
+
+- Failure return false
+- Success return float
+
+---
+
+## Easings - Circular Easing functions
+
+---
+
+> value = RL_EaseCircIn( float t, float b, float c, float d )
+
+Ease circle in
+
+- Failure return false
+- Success return float
+
+---
+
+> value = RL_EaseCircOut( float t, float b, float c, float d )
+
+Ease circle out
+
+- Failure return false
+- Success return float
+
+---
+
+> value = RL_EaseCircInOut( float t, float b, float c, float d )
+
+Ease circle in out
+
+- Failure return false
+- Success return float
+
+---
+
+## Easings - Cubic Easing functions
+
+---
+
+> value = RL_EaseCubicIn( float t, float b, float c, float d )
+
+Ease cubic in
+
+- Failure return false
+- Success return float
+
+---
+
+> value = RL_EaseCubicOut( float t, float b, float c, float d )
+
+Ease cubic out
+
+- Failure return false
+- Success return float
+
+---
+
+> value = RL_EaseCubicInOut( float t, float b, float c, float d )
+
+Ease cubic in out
+
+- Failure return false
+- Success return float
+
+---
+
+## Easings - Quadratic Easing functions
+
+---
+
+> value = RL_EaseQuadIn( float t, float b, float c, float d )
+
+Ease quadratic in
+
+- Failure return false
+- Success return float
+
+---
+
+> value = RL_EaseQuadOut( float t, float b, float c, float d )
+
+Ease quadratic out
+
+- Failure return false
+- Success return float
+
+---
+
+> value = RL_EaseQuadInOut( float t, float b, float c, float d )
+
+Ease quadratic in out
+
+- Failure return false
+- Success return float
+
+---
+
+## Easings - Exponential Easing functions
+
+---
+
+> value = RL_EaseExpoIn( float t, float b, float c, float d )
+
+Ease exponential in
+
+- Failure return false
+- Success return float
+
+---
+
+> value = RL_EaseExpoOut( float t, float b, float c, float d )
+
+Ease exponential out
+
+- Failure return false
+- Success return float
+
+---
+
+> value = RL_EaseExpoInOut( float t, float b, float c, float d )
+
+Ease exponential in out
+
+- Failure return false
+- Success return float
+
+---
+
+## Easings - Back Easing functions
+
+---
+
+> value = RL_EaseBackIn( float t, float b, float c, float d )
+
+Ease back in
+
+- Failure return false
+- Success return float
+
+---
+
+> value = RL_EaseBackOut( float t, float b, float c, float d )
+
+Ease back out
+
+- Failure return false
+- Success return float
+
+---
+
+> value = RL_EaseBackInOut( float t, float b, float c, float d )
+
+Ease back in out
+
+- Failure return false
+- Success return float
+
+---
+
+## Easings - Bounce Easing functions
+
+---
+
+> value = RL_EaseBounceIn( float t, float b, float c, float d )
+
+Ease bounce in
+
+- Failure return false
+- Success return float
+
+---
+
+> value = RL_EaseBounceOut( float t, float b, float c, float d )
+
+Ease bounce out
+
+- Failure return false
+- Success return float
+
+---
+
+> value = RL_EaseBounceInOut( float t, float b, float c, float d )
+
+Ease bounce in out
+
+- Failure return false
+- Success return float
+
+---
+
+## Easings - Elastic Easing functions
+
+---
+
+> value = RL_EaseElasticIn( float t, float b, float c, float d )
+
+Ease elastic in
+
+- Failure return false
+- Success return float
+
+---
+
+> value = RL_EaseElasticOut( float t, float b, float c, float d )
+
+Ease elastic out
+
+- Failure return false
+- Success return float
+
+---
+
+> value = RL_EaseElasticInOut( float t, float b, float c, float d )
+
+Ease elastic in out
+
+- Failure return false
+- Success return float
+
+---
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c1cc5ae..fe2f089 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -55,6 +55,7 @@ else() # Desktop
target_link_libraries( ${PROJECT_NAME} "-framework Cocoa" )
target_link_libraries( ${PROJECT_NAME} "-framework OpenGL" )
elseif( WIN32 )
+ # Remove this to get console.
set( CMAKE_C_FLAGS ${CMAKE_C_FLAGS} "-mwindows" )
target_link_libraries( ${PROJECT_NAME} mingw32 opengl32 gdi32 winmm )
endif()
diff --git a/README.md b/README.md
index 4382138..eccdc98 100644
--- a/README.md
+++ b/README.md
@@ -16,6 +16,7 @@ Included submodules.
* Raygui
* Raymath
+* Easings
List of some MISSING features that are planned to be included. For specific function, check API.
@@ -73,6 +74,14 @@ GameFolder
Application should now start successfully from executable. All functionality can be found in "API".
+## Interpreter Mode
+
+ReiLua can also be used to run single lua file using interpreter mode with arguments -i or --interpret. Given file will be called with dofile. Usage example:
+
+```
+./Reilua -i hello.lua
+```
+
## Building
I think the simplest way would be to statically link Raylib and Lua to the same executable. Specially on Linux this would simplify distribution of games since different distros tend to use different versions of librarys. Of course if you plan to only experiment with it, this isn't so important. Current Raylib version 4.2.0.
diff --git a/changelog b/changelog
new file mode 100644
index 0000000..abaf44b
--- /dev/null
+++ b/changelog
@@ -0,0 +1,12 @@
+------------------------------------------------------------------------
+Release: ReiLua version 0.4.0 Using Raylib 4.2
+------------------------------------------------------------------------
+KEY CHANGES:
+ - ADDED: This changelog.
+ - ADDED: Lua interpreter mode.
+ - ADDED: Easings extra module.
+
+Detailed changes:
+ADDED: Help argument.
+CHANGED: Changed fuction name RL_rlSetLineWidth to RL_rlglSetLineWidth.
+CHANGED: Changed fuction name RL_rlGetLineWidth to RL_rlglGetLineWidth.
diff --git a/doc_parser.lua b/doc_parser.lua
index 5a58cee..09227cf 100644
--- a/doc_parser.lua
+++ b/doc_parser.lua
@@ -155,6 +155,7 @@ local sourceFiles = {
"src/rgui.c",
"src/lights.c",
"src/rlgl.c",
+ "src/easings.c",
}
for _, src in ipairs( sourceFiles ) do
diff --git a/examples/platformer/main.lua b/examples/platformer/main.lua
index d68b3b8..e325fbd 100644
--- a/examples/platformer/main.lua
+++ b/examples/platformer/main.lua
@@ -80,12 +80,6 @@ local function createMap()
tilemap.tiles[1][8] = 6
end
-function log( logLevel, message )
- if logLevel == LOG_WARNING then
- error( "Terminated because of warning" )
- end
-end
-
function init()
local monitorPos = Vec2:new( RL_GetMonitorPosition( monitor ) )
local monitorSize = Vec2:new( RL_GetMonitorSize( monitor ) )
diff --git a/examples/resources/lib/utillib.lua b/examples/resources/lib/utillib.lua
index 8d3ce9e..b2b93e0 100644
--- a/examples/resources/lib/utillib.lua
+++ b/examples/resources/lib/utillib.lua
@@ -1,4 +1,4 @@
--- Define useful global stuff.
+-- Define useful global functions.
local utillib = {}
@@ -41,7 +41,7 @@ function utillib.clamp( val, min, max )
return math.max( min, math.min( val, max ) )
end
--- Returns changed value ( value to be changed, index, bit )
+-- Returns changed value ( value to be changed, index, state( bool ) )
function utillib.setBit( v, i, b )
if b then
return v | 1 << i
@@ -93,6 +93,7 @@ function utillib.round( v )
return math.tointeger( v + 0.5 - ( v + 0.5 ) % 1 )
end
+-- Use with dictionary style tables.
function utillib.tableLen( t )
local count = 0
@@ -151,4 +152,15 @@ function utillib.toBoolean( v )
return false
end
+-- Print table content.
+function utillib.printt( t )
+ print( tostring(t).." = {" )
+
+ for i, item in pairs( t ) do
+ print( "\t"..tostring(i).." = "..tostring( item ) )
+ end
+
+ print( "}" )
+end
+
return utillib
diff --git a/examples/resources/lib/vector2.lua b/examples/resources/lib/vector2.lua
index 7e3b7fb..0446473 100644
--- a/examples/resources/lib/vector2.lua
+++ b/examples/resources/lib/vector2.lua
@@ -38,7 +38,6 @@ Vector2.meta = {
return len
end,
__eq = function( v1, v2 )
- -- return v1.x == v2.x and v1.y == v2.y
return RL_Vector2Equals( v1, v2 ) == 1
end,
}
diff --git a/examples/resources/lib/vector3.lua b/examples/resources/lib/vector3.lua
index 0f4d990..0eb9d77 100644
--- a/examples/resources/lib/vector3.lua
+++ b/examples/resources/lib/vector3.lua
@@ -38,7 +38,6 @@ Vector3.meta = {
return len
end,
__eq = function( v1, v2 )
- -- return v1.x == v2.x and v1.y == v2.y and v1.z == v2.z
return RL_Vector3Equals( v1, v2 ) == 1
end,
}
diff --git a/include/easings.h b/include/easings.h
new file mode 100644
index 0000000..3441305
--- /dev/null
+++ b/include/easings.h
@@ -0,0 +1,263 @@
+/*******************************************************************************************
+*
+* raylib easings (header only file)
+*
+* Useful easing functions for values animation
+*
+* This header uses:
+* #define EASINGS_STATIC_INLINE // Inlines all functions code, so it runs faster.
+* // This requires lots of memory on system.
+* How to use:
+* The four inputs t,b,c,d are defined as follows:
+* t = current time (in any unit measure, but same unit as duration)
+* b = starting value to interpolate
+* c = the total change in value of b that needs to occur
+* d = total time it should take to complete (duration)
+*
+* Example:
+*
+* int currentTime = 0;
+* int duration = 100;
+* float startPositionX = 0.0f;
+* float finalPositionX = 30.0f;
+* float currentPositionX = startPositionX;
+*
+* while (currentPositionX < finalPositionX)
+* {
+* currentPositionX = EaseSineIn(currentTime, startPositionX, finalPositionX - startPositionX, duration);
+* currentTime++;
+* }
+*
+* A port of Robert Penner's easing equations to C (http://robertpenner.com/easing/)
+*
+* Robert Penner License
+* ---------------------------------------------------------------------------------
+* Open source under the BSD License.
+*
+* Copyright (c) 2001 Robert Penner. All rights reserved.
+*
+* Redistribution and use in source and binary forms, with or without modification,
+* are permitted provided that the following conditions are met:
+*
+* - Redistributions of source code must retain the above copyright notice,
+* this list of conditions and the following disclaimer.
+* - Redistributions in binary form must reproduce the above copyright notice,
+* this list of conditions and the following disclaimer in the documentation
+* and/or other materials provided with the distribution.
+* - Neither the name of the author nor the names of contributors may be used
+* to endorse or promote products derived from this software without specific
+* prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+* IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+* OF THE POSSIBILITY OF SUCH DAMAGE.
+* ---------------------------------------------------------------------------------
+*
+* Copyright (c) 2015 Ramon Santamaria
+*
+* This software is provided "as-is", without any express or implied warranty. In no event
+* will the authors be held liable for any damages arising from the use of this software.
+*
+* Permission is granted to anyone to use this software for any purpose, including commercial
+* applications, and to alter it and redistribute it freely, subject to the following restrictions:
+*
+* 1. The origin of this software must not be misrepresented; you must not claim that you
+* wrote the original software. If you use this software in a product, an acknowledgment
+* in the product documentation would be appreciated but is not required.
+*
+* 2. Altered source versions must be plainly marked as such, and must not be misrepresented
+* as being the original software.
+*
+* 3. This notice may not be removed or altered from any source distribution.
+*
+**********************************************************************************************/
+
+#ifndef EASINGS_H
+#define EASINGS_H
+
+#define EASINGS_STATIC_INLINE // NOTE: By default, compile functions as static inline
+
+#if defined(EASINGS_STATIC_INLINE)
+ #define EASEDEF static inline
+#else
+ #define EASEDEF extern
+#endif
+
+#include <math.h> // Required for: sinf(), cosf(), sqrtf(), powf()
+
+#ifndef PI
+ #define PI 3.14159265358979323846f //Required as PI is not always defined in math.h
+#endif
+
+#ifdef __cplusplus
+extern "C" { // Prevents name mangling of functions
+#endif
+
+// Linear Easing functions
+EASEDEF float EaseLinearNone(float t, float b, float c, float d) { return (c*t/d + b); }
+EASEDEF float EaseLinearIn(float t, float b, float c, float d) { return (c*t/d + b); }
+EASEDEF float EaseLinearOut(float t, float b, float c, float d) { return (c*t/d + b); }
+EASEDEF float EaseLinearInOut(float t,float b, float c, float d) { return (c*t/d + b); }
+
+// Sine Easing functions
+EASEDEF float EaseSineIn(float t, float b, float c, float d) { return (-c*cosf(t/d*(PI/2.0f)) + c + b); }
+EASEDEF float EaseSineOut(float t, float b, float c, float d) { return (c*sinf(t/d*(PI/2.0f)) + b); }
+EASEDEF float EaseSineInOut(float t, float b, float c, float d) { return (-c/2.0f*(cosf(PI*t/d) - 1.0f) + b); }
+
+// Circular Easing functions
+EASEDEF float EaseCircIn(float t, float b, float c, float d) { t /= d; return (-c*(sqrtf(1.0f - t*t) - 1.0f) + b); }
+EASEDEF float EaseCircOut(float t, float b, float c, float d) { t = t/d - 1.0f; return (c*sqrtf(1.0f - t*t) + b); }
+EASEDEF float EaseCircInOut(float t, float b, float c, float d)
+{
+ if ((t/=d/2.0f) < 1.0f) return (-c/2.0f*(sqrtf(1.0f - t*t) - 1.0f) + b);
+ t -= 2.0f; return (c/2.0f*(sqrtf(1.0f - t*t) + 1.0f) + b);
+}
+
+// Cubic Easing functions
+EASEDEF float EaseCubicIn(float t, float b, float c, float d) { t /= d; return (c*t*t*t + b); }
+EASEDEF float EaseCubicOut(float t, float b, float c, float d) { t = t/d - 1.0f; return (c*(t*t*t + 1.0f) + b); }
+EASEDEF float EaseCubicInOut(float t, float b, float c, float d)
+{
+ if ((t/=d/2.0f) < 1.0f) return (c/2.0f*t*t*t + b);
+ t -= 2.0f; return (c/2.0f*(t*t*t + 2.0f) + b);
+}
+
+// Quadratic Easing functions
+EASEDEF float EaseQuadIn(float t, float b, float c, float d) { t /= d; return (c*t*t + b); }
+EASEDEF float EaseQuadOut(float t, float b, float c, float d) { t /= d; return (-c*t*(t - 2.0f) + b); }
+EASEDEF float EaseQuadInOut(float t, float b, float c, float d)
+{
+ if ((t/=d/2) < 1) return (((c/2)*(t*t)) + b);
+ return (-c/2.0f*(((t - 1.0f)*(t - 3.0f)) - 1.0f) + b);
+}
+
+// Exponential Easing functions
+EASEDEF float EaseExpoIn(float t, float b, float c, float d) { return (t == 0.0f) ? b : (c*powf(2.0f, 10.0f*(t/d - 1.0f)) + b); }
+EASEDEF float EaseExpoOut(float t, float b, float c, float d) { return (t == d) ? (b + c) : (c*(-powf(2.0f, -10.0f*t/d) + 1.0f) + b); }
+EASEDEF float EaseExpoInOut(float t, float b, float c, float d)
+{
+ if (t == 0.0f) return b;
+ if (t == d) return (b + c);
+ if ((t/=d/2.0f) < 1.0f) return (c/2.0f*powf(2.0f, 10.0f*(t - 1.0f)) + b);
+
+ return (c/2.0f*(-powf(2.0f, -10.0f*(t - 1.0f)) + 2.0f) + b);
+}
+
+// Back Easing functions
+EASEDEF float EaseBackIn(float t, float b, float c, float d)
+{
+ float s = 1.70158f;
+ float postFix = t/=d;
+ return (c*(postFix)*t*((s + 1.0f)*t - s) + b);
+}
+
+EASEDEF float EaseBackOut(float t, float b, float c, float d)
+{
+ float s = 1.70158f;
+ t = t/d - 1.0f;
+ return (c*(t*t*((s + 1.0f)*t + s) + 1.0f) + b);
+}
+
+EASEDEF float EaseBackInOut(float t, float b, float c, float d)
+{
+ float s = 1.70158f;
+ if ((t/=d/2.0f) < 1.0f)
+ {
+ s *= 1.525f;
+ return (c/2.0f*(t*t*((s + 1.0f)*t - s)) + b);
+ }
+
+ float postFix = t-=2.0f;
+ s *= 1.525f;
+ return (c/2.0f*((postFix)*t*((s + 1.0f)*t + s) + 2.0f) + b);
+}
+
+// Bounce Easing functions
+EASEDEF float EaseBounceOut(float t, float b, float c, float d)
+{
+ if ((t/=d) < (1.0f/2.75f))
+ {
+ return (c*(7.5625f*t*t) + b);
+ }
+ else if (t < (2.0f/2.75f))
+ {
+ float postFix = t-=(1.5f/2.75f);
+ return (c*(7.5625f*(postFix)*t + 0.75f) + b);
+ }
+ else if (t < (2.5/2.75))
+ {
+ float postFix = t-=(2.25f/2.75f);
+ return (c*(7.5625f*(postFix)*t + 0.9375f) + b);
+ }
+ else
+ {
+ float postFix = t-=(2.625f/2.75f);
+ return (c*(7.5625f*(postFix)*t + 0.984375f) + b);
+ }
+}
+
+EASEDEF float EaseBounceIn(float t, float b, float c, float d) { return (c - EaseBounceOut(d - t, 0.0f, c, d) + b); }
+EASEDEF float EaseBounceInOut(float t, float b, float c, float d)
+{
+ if (t < d/2.0f) return (EaseBounceIn(t*2.0f, 0.0f, c, d)*0.5f + b);
+ else return (EaseBounceOut(t*2.0f - d, 0.0f, c, d)*0.5f + c*0.5f + b);
+}
+
+// Elastic Easing functions
+EASEDEF float EaseElasticIn(float t, float b, float c, float d)
+{
+ if (t == 0.0f) return b;
+ if ((t/=d) == 1.0f) return (b + c);
+
+ float p = d*0.3f;
+ float a = c;
+ float s = p/4.0f;
+ float postFix = a*powf(2.0f, 10.0f*(t-=1.0f));
+
+ return (-(postFix*sinf((t*d-s)*(2.0f*PI)/p )) + b);
+}
+
+EASEDEF float EaseElasticOut(float t, float b, float c, float d)
+{
+ if (t == 0.0f) return b;
+ if ((t/=d) == 1.0f) return (b + c);
+
+ float p = d*0.3f;
+ float a = c;
+ float s = p/4.0f;
+
+ return (a*powf(2.0f,-10.0f*t)*sinf((t*d-s)*(2.0f*PI)/p) + c + b);
+}
+
+EASEDEF float EaseElasticInOut(float t, float b, float c, float d)
+{
+ if (t == 0.0f) return b;
+ if ((t/=d/2.0f) == 2.0f) return (b + c);
+
+ float p = d*(0.3f*1.5f);
+ float a = c;
+ float s = p/4.0f;
+
+ if (t < 1.0f)
+ {
+ float postFix = a*powf(2.0f, 10.0f*(t-=1.0f));
+ return -0.5f*(postFix*sinf((t*d-s)*(2.0f*PI)/p)) + b;
+ }
+
+ float postFix = a*powf(2.0f, -10.0f*(t-=1.0f));
+
+ return (postFix*sinf((t*d-s)*(2.0f*PI)/p)*0.5f + c + b);
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // EASINGS_H
diff --git a/include/main.h b/include/main.h
index ff160a2..c04f3e5 100644
--- a/include/main.h
+++ b/include/main.h
@@ -3,9 +3,9 @@
#define STRING_LEN 1024
#define VERSION_MAJOR 0
-#define VERSION_MINOR 3
+#define VERSION_MINOR 4
#define VERSION_PATCH 0
-#define VERSION_DEV 0
+#define VERSION_DEV 1
#include <stdio.h>
#include <stdlib.h>
diff --git a/include/reasings.h b/include/reasings.h
new file mode 100644
index 0000000..e8c9a65
--- /dev/null
+++ b/include/reasings.h
@@ -0,0 +1,44 @@
+#pragma once
+
+/* Linear Easing functions. */
+int leasingsEaseLinear( lua_State *L );
+
+/* Sine Easing functions. */
+int leasingsEaseSineIn( lua_State *L );
+int leasingsEaseSineOut( lua_State *L );
+int leasingsEaseSineInOut( lua_State *L );
+
+/* Circular Easing functions. */
+int leasingsEaseCircIn( lua_State *L );
+int leasingsEaseCircOut( lua_State *L );
+int leasingsEaseCircInOut( lua_State *L );
+
+/* Cubic Easing functions. */
+int leasingsEaseCubicIn( lua_State *L );
+int leasingsEaseCubicOut( lua_State *L );
+int leasingsEaseCubicInOut( lua_State *L );
+
+/* Quadratic Easing functions. */
+int leasingsEaseQuadIn( lua_State *L );
+int leasingsEaseQuadOut( lua_State *L );
+int leasingsEaseQuadInOut( lua_State *L );
+
+/* Exponential Easing functions. */
+int leasingsEaseExpoIn( lua_State *L );
+int leasingsEaseExpoOut( lua_State *L );
+int leasingsEaseExpoInOut( lua_State *L );
+
+/* Back Easing functions. */
+int leasingsEaseBackIn( lua_State *L );
+int leasingsEaseBackOut( lua_State *L );
+int leasingsEaseBackInOut( lua_State *L );
+
+/* Bounce Easing functions. */
+int leasingsEaseBounceIn( lua_State *L );
+int leasingsEaseBounceOut( lua_State *L );
+int leasingsEaseBounceInOut( lua_State *L );
+
+/* Elastic Easing functions. */
+int leasingsEaseElasticIn( lua_State *L );
+int leasingsEaseElasticOut( lua_State *L );
+int leasingsEaseElasticInOut( lua_State *L );
diff --git a/include/state.h b/include/state.h
index fc3c957..b82cfd9 100644
--- a/include/state.h
+++ b/include/state.h
@@ -78,4 +78,5 @@ typedef struct {
extern State *state;
bool stateInit( const char *exePath );
+bool stateInitInterpret();
void stateFree();
diff --git a/src/easings.c b/src/easings.c
new file mode 100644
index 0000000..b864cdb
--- /dev/null
+++ b/src/easings.c
@@ -0,0 +1,516 @@
+#include "main.h"
+#include "state.h"
+#include "lua_core.h"
+#include "easings.h"
+#include "reasings.h"
+
+/*
+## Easings - Linear Easing functions
+*/
+
+/*
+> value = RL_EaseLinear( float t, float b, float c, float d )
+
+Ease linear
+
+- Failure return false
+- Success return float
+*/
+int leasingsEaseLinear( lua_State *L ) {
+ if ( !lua_isnumber( L, -4 ) || !lua_isnumber( L, -3 ) || !lua_isnumber( L, -2 ) || !lua_isnumber( L, -1 ) ) {
+ TraceLog( LOG_WARNING, "%s", "Bad call of function. RL_EaseLinear( float t, float b, float c, float d )" );
+ lua_pushboolean( L, false );
+ return 1;
+ }
+ lua_pushnumber( L, EaseLinearNone( lua_tonumber( L, -4 ), lua_tonumber( L, -3 ), lua_tonumber( L, -2 ), lua_tonumber( L, -1 ) ) );
+
+ return 1;
+}
+
+/*
+## Easings - Sine Easing functions
+*/
+
+/*
+> value = RL_EaseSineIn( float t, float b, float c, float d )
+
+Ease sine in
+
+- Failure return false
+- Success return float
+*/
+int leasingsEaseSineIn( lua_State *L ) {
+ if ( !lua_isnumber( L, -4 ) || !lua_isnumber( L, -3 ) || !lua_isnumber( L, -2 ) || !lua_isnumber( L, -1 ) ) {
+ TraceLog( LOG_WARNING, "%s", "Bad call of function. RL_EaseSineIn( float t, float b, float c, float d )" );
+ lua_pushboolean( L, false );
+ return 1;
+ }
+ lua_pushnumber( L, EaseSineIn( lua_tonumber( L, -4 ), lua_tonumber( L, -3 ), lua_tonumber( L, -2 ), lua_tonumber( L, -1 ) ) );
+
+ return 1;
+}
+
+/*
+> value = RL_EaseSineOut( float t, float b, float c, float d )
+
+Ease sine out
+
+- Failure return false
+- Success return float
+*/
+int leasingsEaseSineOut( lua_State *L ) {
+ if ( !lua_isnumber( L, -4 ) || !lua_isnumber( L, -3 ) || !lua_isnumber( L, -2 ) || !lua_isnumber( L, -1 ) ) {
+ TraceLog( LOG_WARNING, "%s", "Bad call of function. RL_EaseSineOut( float t, float b, float c, float d )" );
+ lua_pushboolean( L, false );
+ return 1;
+ }
+ lua_pushnumber( L, EaseSineOut( lua_tonumber( L, -4 ), lua_tonumber( L, -3 ), lua_tonumber( L, -2 ), lua_tonumber( L, -1 ) ) );
+
+ return 1;
+}
+
+/*
+> value = RL_EaseSineInOut( float t, float b, float c, float d )
+
+Ease sine in out
+
+- Failure return false
+- Success return float
+*/
+int leasingsEaseSineInOut( lua_State *L ) {
+ if ( !lua_isnumber( L, -4 ) || !lua_isnumber( L, -3 ) || !lua_isnumber( L, -2 ) || !lua_isnumber( L, -1 ) ) {
+ TraceLog( LOG_WARNING, "%s", "Bad call of function. RL_EaseSineInOut( float t, float b, float c, float d )" );
+ lua_pushboolean( L, false );
+ return 1;
+ }
+ lua_pushnumber( L, EaseSineInOut( lua_tonumber( L, -4 ), lua_tonumber( L, -3 ), lua_tonumber( L, -2 ), lua_tonumber( L, -1 ) ) );
+
+ return 1;
+}
+
+/*
+## Easings - Circular Easing functions
+*/
+
+/*
+> value = RL_EaseCircIn( float t, float b, float c, float d )
+
+Ease circle in
+
+- Failure return false
+- Success return float
+*/
+int leasingsEaseCircIn( lua_State *L ) {
+ if ( !lua_isnumber( L, -4 ) || !lua_isnumber( L, -3 ) || !lua_isnumber( L, -2 ) || !lua_isnumber( L, -1 ) ) {
+ TraceLog( LOG_WARNING, "%s", "Bad call of function. RL_EaseCircIn( float t, float b, float c, float d )" );
+ lua_pushboolean( L, false );
+ return 1;
+ }
+ lua_pushnumber( L, EaseCircIn( lua_tonumber( L, -4 ), lua_tonumber( L, -3 ), lua_tonumber( L, -2 ), lua_tonumber( L, -1 ) ) );
+
+ return 1;
+}
+
+/*
+> value = RL_EaseCircOut( float t, float b, float c, float d )
+
+Ease circle out
+
+- Failure return false
+- Success return float
+*/
+int leasingsEaseCircOut( lua_State *L ) {
+ if ( !lua_isnumber( L, -4 ) || !lua_isnumber( L, -3 ) || !lua_isnumber( L, -2 ) || !lua_isnumber( L, -1 ) ) {
+ TraceLog( LOG_WARNING, "%s", "Bad call of function. RL_EaseCircOut( float t, float b, float c, float d )" );
+ lua_pushboolean( L, false );
+ return 1;
+ }
+ lua_pushnumber( L, EaseCircOut( lua_tonumber( L, -4 ), lua_tonumber( L, -3 ), lua_tonumber( L, -2 ), lua_tonumber( L, -1 ) ) );
+
+ return 1;
+}
+
+/*
+> value = RL_EaseCircInOut( float t, float b, float c, float d )
+
+Ease circle in out
+
+- Failure return false
+- Success return float
+*/
+int leasingsEaseCircInOut( lua_State *L ) {
+ if ( !lua_isnumber( L, -4 ) || !lua_isnumber( L, -3 ) || !lua_isnumber( L, -2 ) || !lua_isnumber( L, -1 ) ) {
+ TraceLog( LOG_WARNING, "%s", "Bad call of function. RL_EaseCircInOut( float t, float b, float c, float d )" );
+ lua_pushboolean( L, false );
+ return 1;
+ }
+ lua_pushnumber( L, EaseCircInOut( lua_tonumber( L, -4 ), lua_tonumber( L, -3 ), lua_tonumber( L, -2 ), lua_tonumber( L, -1 ) ) );
+
+ return 1;
+}
+
+/*
+## Easings - Cubic Easing functions
+*/
+
+/*
+> value = RL_EaseCubicIn( float t, float b, float c, float d )
+
+Ease cubic in
+
+- Failure return false
+- Success return float
+*/
+int leasingsEaseCubicIn( lua_State *L ) {
+ if ( !lua_isnumber( L, -4 ) || !lua_isnumber( L, -3 ) || !lua_isnumber( L, -2 ) || !lua_isnumber( L, -1 ) ) {
+ TraceLog( LOG_WARNING, "%s", "Bad call of function. RL_EaseCubicIn( float t, float b, float c, float d )" );
+ lua_pushboolean( L, false );
+ return 1;
+ }
+ lua_pushnumber( L, EaseCubicIn( lua_tonumber( L, -4 ), lua_tonumber( L, -3 ), lua_tonumber( L, -2 ), lua_tonumber( L, -1 ) ) );
+
+ return 1;
+}
+
+/*
+> value = RL_EaseCubicOut( float t, float b, float c, float d )
+
+Ease cubic out
+
+- Failure return false
+- Success return float
+*/
+int leasingsEaseCubicOut( lua_State *L ) {
+ if ( !lua_isnumber( L, -4 ) || !lua_isnumber( L, -3 ) || !lua_isnumber( L, -2 ) || !lua_isnumber( L, -1 ) ) {
+ TraceLog( LOG_WARNING, "%s", "Bad call of function. RL_EaseCubicOut( float t, float b, float c, float d )" );
+ lua_pushboolean( L, false );
+ return 1;
+ }
+ lua_pushnumber( L, EaseCubicOut( lua_tonumber( L, -4 ), lua_tonumber( L, -3 ), lua_tonumber( L, -2 ), lua_tonumber( L, -1 ) ) );
+
+ return 1;
+}
+
+/*
+> value = RL_EaseCubicInOut( float t, float b, float c, float d )
+
+Ease cubic in out
+
+- Failure return false
+- Success return float
+*/
+int leasingsEaseCubicInOut( lua_State *L ) {
+ if ( !lua_isnumber( L, -4 ) || !lua_isnumber( L, -3 ) || !lua_isnumber( L, -2 ) || !lua_isnumber( L, -1 ) ) {
+ TraceLog( LOG_WARNING, "%s", "Bad call of function. RL_EaseCubicInOut( float t, float b, float c, float d )" );
+ lua_pushboolean( L, false );
+ return 1;
+ }
+ lua_pushnumber( L, EaseCubicInOut( lua_tonumber( L, -4 ), lua_tonumber( L, -3 ), lua_tonumber( L, -2 ), lua_tonumber( L, -1 ) ) );
+
+ return 1;
+}
+
+/*
+## Easings - Quadratic Easing functions
+*/
+
+/*
+> value = RL_EaseQuadIn( float t, float b, float c, float d )
+
+Ease quadratic in
+
+- Failure return false
+- Success return float
+*/
+int leasingsEaseQuadIn( lua_State *L ) {
+ if ( !lua_isnumber( L, -4 ) || !lua_isnumber( L, -3 ) || !lua_isnumber( L, -2 ) || !lua_isnumber( L, -1 ) ) {
+ TraceLog( LOG_WARNING, "%s", "Bad call of function. RL_EaseQuadIn( float t, float b, float c, float d )" );
+ lua_pushboolean( L, false );
+ return 1;
+ }
+ lua_pushnumber( L, EaseQuadIn( lua_tonumber( L, -4 ), lua_tonumber( L, -3 ), lua_tonumber( L, -2 ), lua_tonumber( L, -1 ) ) );
+
+ return 1;
+}
+
+/*
+> value = RL_EaseQuadOut( float t, float b, float c, float d )
+
+Ease quadratic out
+
+- Failure return false
+- Success return float
+*/
+int leasingsEaseQuadOut( lua_State *L ) {
+ if ( !lua_isnumber( L, -4 ) || !lua_isnumber( L, -3 ) || !lua_isnumber( L, -2 ) || !lua_isnumber( L, -1 ) ) {
+ TraceLog( LOG_WARNING, "%s", "Bad call of function. RL_EaseQuadOut( float t, float b, float c, float d )" );
+ lua_pushboolean( L, false );
+ return 1;
+ }
+ lua_pushnumber( L, EaseQuadOut( lua_tonumber( L, -4 ), lua_tonumber( L, -3 ), lua_tonumber( L, -2 ), lua_tonumber( L, -1 ) ) );
+
+ return 1;
+}
+
+/*
+> value = RL_EaseQuadInOut( float t, float b, float c, float d )
+
+Ease quadratic in out
+
+- Failure return false
+- Success return float
+*/
+int leasingsEaseQuadInOut( lua_State *L ) {
+ if ( !lua_isnumber( L, -4 ) || !lua_isnumber( L, -3 ) || !lua_isnumber( L, -2 ) || !lua_isnumber( L, -1 ) ) {
+ TraceLog( LOG_WARNING, "%s", "Bad call of function. RL_EaseQuadInOut( float t, float b, float c, float d )" );
+ lua_pushboolean( L, false );
+ return 1;
+ }
+ lua_pushnumber( L, EaseQuadInOut( lua_tonumber( L, -4 ), lua_tonumber( L, -3 ), lua_tonumber( L, -2 ), lua_tonumber( L, -1 ) ) );
+
+ return 1;
+}
+
+/*
+## Easings - Exponential Easing functions
+*/
+
+/*
+> value = RL_EaseExpoIn( float t, float b, float c, float d )
+
+Ease exponential in
+
+- Failure return false
+- Success return float
+*/
+int leasingsEaseExpoIn( lua_State *L ) {
+ if ( !lua_isnumber( L, -4 ) || !lua_isnumber( L, -3 ) || !lua_isnumber( L, -2 ) || !lua_isnumber( L, -1 ) ) {
+ TraceLog( LOG_WARNING, "%s", "Bad call of function. RL_EaseExpoIn( float t, float b, float c, float d )" );
+ lua_pushboolean( L, false );
+ return 1;
+ }
+ lua_pushnumber( L, EaseExpoIn( lua_tonumber( L, -4 ), lua_tonumber( L, -3 ), lua_tonumber( L, -2 ), lua_tonumber( L, -1 ) ) );
+
+ return 1;
+}
+
+/*
+> value = RL_EaseExpoOut( float t, float b, float c, float d )
+
+Ease exponential out
+
+- Failure return false
+- Success return float
+*/
+int leasingsEaseExpoOut( lua_State *L ) {
+ if ( !lua_isnumber( L, -4 ) || !lua_isnumber( L, -3 ) || !lua_isnumber( L, -2 ) || !lua_isnumber( L, -1 ) ) {
+ TraceLog( LOG_WARNING, "%s", "Bad call of function. RL_EaseExpoOut( float t, float b, float c, float d )" );
+ lua_pushboolean( L, false );
+ return 1;
+ }
+ lua_pushnumber( L, EaseExpoOut( lua_tonumber( L, -4 ), lua_tonumber( L, -3 ), lua_tonumber( L, -2 ), lua_tonumber( L, -1 ) ) );
+
+ return 1;
+}
+
+/*
+> value = RL_EaseExpoInOut( float t, float b, float c, float d )
+
+Ease exponential in out
+
+- Failure return false
+- Success return float
+*/
+int leasingsEaseExpoInOut( lua_State *L ) {
+ if ( !lua_isnumber( L, -4 ) || !lua_isnumber( L, -3 ) || !lua_isnumber( L, -2 ) || !lua_isnumber( L, -1 ) ) {
+ TraceLog( LOG_WARNING, "%s", "Bad call of function. RL_EaseExpoInOut( float t, float b, float c, float d )" );
+ lua_pushboolean( L, false );
+ return 1;
+ }
+ lua_pushnumber( L, EaseExpoInOut( lua_tonumber( L, -4 ), lua_tonumber( L, -3 ), lua_tonumber( L, -2 ), lua_tonumber( L, -1 ) ) );
+
+ return 1;
+}
+
+/*
+## Easings - Back Easing functions
+*/
+
+/*
+> value = RL_EaseBackIn( float t, float b, float c, float d )
+
+Ease back in
+
+- Failure return false
+- Success return float
+*/
+int leasingsEaseBackIn( lua_State *L ) {
+ if ( !lua_isnumber( L, -4 ) || !lua_isnumber( L, -3 ) || !lua_isnumber( L, -2 ) || !lua_isnumber( L, -1 ) ) {
+ TraceLog( LOG_WARNING, "%s", "Bad call of function. RL_EaseBackIn( float t, float b, float c, float d )" );
+ lua_pushboolean( L, false );
+ return 1;
+ }
+ lua_pushnumber( L, EaseBackIn( lua_tonumber( L, -4 ), lua_tonumber( L, -3 ), lua_tonumber( L, -2 ), lua_tonumber( L, -1 ) ) );
+
+ return 1;
+}
+
+/*
+> value = RL_EaseBackOut( float t, float b, float c, float d )
+
+Ease back out
+
+- Failure return false
+- Success return float
+*/
+int leasingsEaseBackOut( lua_State *L ) {
+ if ( !lua_isnumber( L, -4 ) || !lua_isnumber( L, -3 ) || !lua_isnumber( L, -2 ) || !lua_isnumber( L, -1 ) ) {
+ TraceLog( LOG_WARNING, "%s", "Bad call of function. RL_EaseBackOut( float t, float b, float c, float d )" );
+ lua_pushboolean( L, false );
+ return 1;
+ }
+ lua_pushnumber( L, EaseBackOut( lua_tonumber( L, -4 ), lua_tonumber( L, -3 ), lua_tonumber( L, -2 ), lua_tonumber( L, -1 ) ) );
+
+ return 1;
+}
+
+/*
+> value = RL_EaseBackInOut( float t, float b, float c, float d )
+
+Ease back in out
+
+- Failure return false
+- Success return float
+*/
+int leasingsEaseBackInOut( lua_State *L ) {
+ if ( !lua_isnumber( L, -4 ) || !lua_isnumber( L, -3 ) || !lua_isnumber( L, -2 ) || !lua_isnumber( L, -1 ) ) {
+ TraceLog( LOG_WARNING, "%s", "Bad call of function. RL_EaseBackInOut( float t, float b, float c, float d )" );
+ lua_pushboolean( L, false );
+ return 1;
+ }
+ lua_pushnumber( L, EaseBackInOut( lua_tonumber( L, -4 ), lua_tonumber( L, -3 ), lua_tonumber( L, -2 ), lua_tonumber( L, -1 ) ) );
+
+ return 1;
+}
+
+/*
+## Easings - Bounce Easing functions
+*/
+
+/*
+> value = RL_EaseBounceIn( float t, float b, float c, float d )
+
+Ease bounce in
+
+- Failure return false
+- Success return float
+*/
+int leasingsEaseBounceIn( lua_State *L ) {
+ if ( !lua_isnumber( L, -4 ) || !lua_isnumber( L, -3 ) || !lua_isnumber( L, -2 ) || !lua_isnumber( L, -1 ) ) {
+ TraceLog( LOG_WARNING, "%s", "Bad call of function. RL_EaseBounceIn( float t, float b, float c, float d )" );
+ lua_pushboolean( L, false );
+ return 1;
+ }
+ lua_pushnumber( L, EaseBounceIn( lua_tonumber( L, -4 ), lua_tonumber( L, -3 ), lua_tonumber( L, -2 ), lua_tonumber( L, -1 ) ) );
+
+ return 1;
+}
+
+/*
+> value = RL_EaseBounceOut( float t, float b, float c, float d )
+
+Ease bounce out
+
+- Failure return false
+- Success return float
+*/
+int leasingsEaseBounceOut( lua_State *L ) {
+ if ( !lua_isnumber( L, -4 ) || !lua_isnumber( L, -3 ) || !lua_isnumber( L, -2 ) || !lua_isnumber( L, -1 ) ) {
+ TraceLog( LOG_WARNING, "%s", "Bad call of function. RL_EaseBounceOut( float t, float b, float c, float d )" );
+ lua_pushboolean( L, false );
+ return 1;
+ }
+ lua_pushnumber( L, EaseBounceOut( lua_tonumber( L, -4 ), lua_tonumber( L, -3 ), lua_tonumber( L, -2 ), lua_tonumber( L, -1 ) ) );
+
+ return 1;
+}
+
+/*
+> value = RL_EaseBounceInOut( float t, float b, float c, float d )
+
+Ease bounce in out
+
+- Failure return false
+- Success return float
+*/
+int leasingsEaseBounceInOut( lua_State *L ) {
+ if ( !lua_isnumber( L, -4 ) || !lua_isnumber( L, -3 ) || !lua_isnumber( L, -2 ) || !lua_isnumber( L, -1 ) ) {
+ TraceLog( LOG_WARNING, "%s", "Bad call of function. RL_EaseBounceInOut( float t, float b, float c, float d )" );
+ lua_pushboolean( L, false );
+ return 1;
+ }
+ lua_pushnumber( L, EaseBounceInOut( lua_tonumber( L, -4 ), lua_tonumber( L, -3 ), lua_tonumber( L, -2 ), lua_tonumber( L, -1 ) ) );
+
+ return 1;
+}
+
+/*
+## Easings - Elastic Easing functions
+*/
+
+/*
+> value = RL_EaseElasticIn( float t, float b, float c, float d )
+
+Ease elastic in
+
+- Failure return false
+- Success return float
+*/
+int leasingsEaseElasticIn( lua_State *L ) {
+ if ( !lua_isnumber( L, -4 ) || !lua_isnumber( L, -3 ) || !lua_isnumber( L, -2 ) || !lua_isnumber( L, -1 ) ) {
+ TraceLog( LOG_WARNING, "%s", "Bad call of function. RL_EaseElasticIn( float t, float b, float c, float d )" );
+ lua_pushboolean( L, false );
+ return 1;
+ }
+ lua_pushnumber( L, EaseElasticIn( lua_tonumber( L, -4 ), lua_tonumber( L, -3 ), lua_tonumber( L, -2 ), lua_tonumber( L, -1 ) ) );
+
+ return 1;
+}
+
+/*
+> value = RL_EaseElasticOut( float t, float b, float c, float d )
+
+Ease elastic out
+
+- Failure return false
+- Success return float
+*/
+int leasingsEaseElasticOut( lua_State *L ) {
+ if ( !lua_isnumber( L, -4 ) || !lua_isnumber( L, -3 ) || !lua_isnumber( L, -2 ) || !lua_isnumber( L, -1 ) ) {
+ TraceLog( LOG_WARNING, "%s", "Bad call of function. RL_EaseElasticOut( float t, float b, float c, float d )" );
+ lua_pushboolean( L, false );
+ return 1;
+ }
+ lua_pushnumber( L, EaseElasticOut( lua_tonumber( L, -4 ), lua_tonumber( L, -3 ), lua_tonumber( L, -2 ), lua_tonumber( L, -1 ) ) );
+
+ return 1;
+}
+
+/*
+> value = RL_EaseElasticInOut( float t, float b, float c, float d )
+
+Ease elastic in out
+
+- Failure return false
+- Success return float
+*/
+int leasingsEaseElasticInOut( lua_State *L ) {
+ if ( !lua_isnumber( L, -4 ) || !lua_isnumber( L, -3 ) || !lua_isnumber( L, -2 ) || !lua_isnumber( L, -1 ) ) {
+ TraceLog( LOG_WARNING, "%s", "Bad call of function. RL_EaseElasticInOut( float t, float b, float c, float d )" );
+ lua_pushboolean( L, false );
+ return 1;
+ }
+ lua_pushnumber( L, EaseElasticInOut( lua_tonumber( L, -4 ), lua_tonumber( L, -3 ), lua_tonumber( L, -2 ), lua_tonumber( L, -1 ) ) );
+
+ return 1;
+}
diff --git a/src/lua_core.c b/src/lua_core.c
index 1d3f1c8..5e20cd3 100644
--- a/src/lua_core.c
+++ b/src/lua_core.c
@@ -11,6 +11,7 @@
#include "rgui.h"
#include "lights.h"
#include "lrlgl.h"
+#include "reasings.h"
static void assignGlobalInt( int value, const char *name ) {
lua_State *L = state->luaState;
@@ -526,10 +527,10 @@ bool luaInit() {
return false;
}
- luaRegister();
+ // luaRegister();
defineGlobals();
- return luaCallMain();
+ return true;
}
int luaTraceback( lua_State *L ) {
@@ -592,8 +593,9 @@ bool luaCallMain() {
return false;
}
}
+ //TODO Should this be removed?
else {
- TraceLog( LOG_ERROR, "%s", "No Lua main found!" );
+ TraceLog( LOG_ERROR, "%s", "No Lua init found!" );
return false;
}
/* Apply custom callback here. */
@@ -1265,14 +1267,52 @@ void luaRegister() {
lua_register( L, "RL_GuiSetIconPixel", lguiGuiSetIconPixel );
lua_register( L, "RL_GuiClearIconPixel", lguiGuiClearIconPixel );
lua_register( L, "RL_GuiCheckIconPixel", lguiGuiCheckIconPixel );
+
/* Lights */
/* Basics. */
lua_register( L, "RL_CreateLight", llightsCreateLight );
lua_register( L, "RL_UpdateLightValues", llightsUpdateLightValues );
+
/* RLGL */
/* General render state. */
- lua_register( L, "RL_rlSetLineWidth", lrlglSetLineWidth );
- lua_register( L, "RL_rlGetLineWidth", lrlglGetLineWidth );
+ lua_register( L, "RL_rlglSetLineWidth", lrlglSetLineWidth );
+ lua_register( L, "RL_rlglGetLineWidth", lrlglGetLineWidth );
+
+ /* Easings */
+ /* Linear Easing functions. */
+ lua_register( L, "RL_EaseLinear", leasingsEaseLinear );
+ /* Sine Easing functions. */
+ lua_register( L, "RL_EaseSineIn", leasingsEaseSineIn );
+ lua_register( L, "RL_EaseSineOut", leasingsEaseSineOut );
+ lua_register( L, "RL_EaseSineInOut", leasingsEaseSineInOut );
+ /* Circular Easing functions. */
+ lua_register( L, "RL_EaseCircIn", leasingsEaseCircIn );
+ lua_register( L, "RL_EaseCircOut", leasingsEaseCircOut );
+ lua_register( L, "RL_EaseCircInOut", leasingsEaseCircInOut );
+ /* Cubic Easing functions. */
+ lua_register( L, "RL_EaseCubicIn", leasingsEaseCubicIn );
+ lua_register( L, "RL_EaseCubicOut", leasingsEaseCubicOut );
+ lua_register( L, "RL_EaseCubicInOut", leasingsEaseCubicInOut );
+ /* Quadratic Easing functions. */
+ lua_register( L, "RL_EaseQuadIn", leasingsEaseQuadIn );
+ lua_register( L, "RL_EaseQuadOut", leasingsEaseQuadOut );
+ lua_register( L, "RL_EaseQuadInOut", leasingsEaseQuadInOut );
+ /* Exponential Easing functions. */
+ lua_register( L, "RL_EaseExpoIn", leasingsEaseExpoIn );
+ lua_register( L, "RL_EaseExpoOut", leasingsEaseExpoOut );
+ lua_register( L, "RL_EaseExpoInOut", leasingsEaseExpoInOut );
+ /* Back Easing functions. */
+ lua_register( L, "RL_EaseBackIn", leasingsEaseBackIn );
+ lua_register( L, "RL_EaseBackOut", leasingsEaseBackOut );
+ lua_register( L, "RL_EaseBackInOut", leasingsEaseBackInOut );
+ /* Bounce Easing functions. */
+ lua_register( L, "RL_EaseBounceIn", leasingsEaseBounceIn );
+ lua_register( L, "RL_EaseBounceOut", leasingsEaseBounceOut );
+ lua_register( L, "RL_EaseBounceInOut", leasingsEaseBounceInOut );
+ /* Elastic Easing functions. */
+ lua_register( L, "RL_EaseElasticIn", leasingsEaseElasticIn );
+ lua_register( L, "RL_EaseElasticOut", leasingsEaseElasticOut );
+ lua_register( L, "RL_EaseElasticInOut", leasingsEaseElasticInOut );
}
/* Lua util functions. */
diff --git a/src/main.c b/src/main.c
index 9155cd7..2e07e37 100644
--- a/src/main.c
+++ b/src/main.c
@@ -13,12 +13,26 @@ inline static void printVersion() {
int main( int argn, const char **argc ) {
char exePath[ STRING_LEN ] = { '\0' };
+ bool interpret_mode = false;
if ( 1 < argn ) {
if ( strcmp( argc[1], "--version" ) == 0 || strcmp( argc[1], "-v" ) == 0 ) {
printVersion();
return 1;
}
+ else if ( strcmp( argc[1], "--help" ) == 0 || strcmp( argc[1], "-h" ) == 0 ) {
+ printf(
+"Usage: ReiLua [Options] [Directory to main.lua or main]\nOptions:\n-h --help\tThis help\n-v --version\tShow ReiLua version\n-i --interpret\tInterpret mode [File name]\n" );
+
+ return 1;
+ }
+ else if ( strcmp( argc[1], "--interpret" ) == 0 || strcmp( argc[1], "-i" ) == 0 ) {
+ interpret_mode = true;
+
+ if ( 2 < argn ) {
+ sprintf( exePath, "%s/%s", GetWorkingDirectory(), argc[2] );
+ }
+ }
else{
sprintf( exePath, "%s/%s", GetWorkingDirectory(), argc[1] );
}
@@ -26,19 +40,29 @@ int main( int argn, const char **argc ) {
else {
sprintf( exePath, "%s/", GetWorkingDirectory() );
}
- printVersion();
- stateInit( exePath );
- while ( state->run ) {
- if ( WindowShouldClose() ) {
- state->run = false;
- }
- if ( IsAudioDeviceReady() ) {
- UpdateMusicStream( state->music );
+ if ( interpret_mode ) {
+ stateInitInterpret();
+ luaL_dofile( state->luaState, exePath );
+ }
+ else {
+ printVersion();
+ stateInit( exePath );
+ luaRegister();
+ state->run = luaCallMain();
+
+ while ( state->run ) {
+ if ( WindowShouldClose() ) {
+ state->run = false;
+ }
+ if ( IsAudioDeviceReady() ) {
+ UpdateMusicStream( state->music );
+ }
+ luaCallProcess();
+ luaCallDraw();
}
- luaCallProcess();
- luaCallDraw();
}
+
stateFree();
return 1;
diff --git a/src/state.c b/src/state.c
index 8cecdcd..4f7e302 100644
--- a/src/state.c
+++ b/src/state.c
@@ -108,11 +108,20 @@ bool stateInit( const char *exePath ) {
if ( state->run ) {
InitAudioDevice();
state->run = luaInit();
+ // luaRegister();
+ // defineGlobals();
+
+ state->run = luaInit();
}
return state->run;
}
+bool stateInitInterpret() {
+ state = malloc( sizeof( State ) );
+ luaInit();
+}
+
void stateFree() {
for ( int i = 0; i < state->imageCount; ++i ) {
if ( state->images[i] != NULL ) {