summaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/main.c b/src/main.c
new file mode 100644
index 0000000..e9d5db2
--- /dev/null
+++ b/src/main.c
@@ -0,0 +1,37 @@
+#include "main.h"
+#include "state.h"
+#include "lua_core.h"
+
+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\n", VERSION_MAJOR, VERSION_MINOR );
+
+ return 1;
+ }
+ else{
+ sprintf( exePath, "%s/%s", GetWorkingDirectory(), argc[1] );
+ }
+ }
+ else {
+ sprintf( exePath, "%s/", GetWorkingDirectory() );
+ }
+
+ stateInit( exePath );
+
+ while ( state->run ) {
+ if ( WindowShouldClose() ) {
+ state->run = false;
+ }
+ if ( IsAudioDeviceReady() ) {
+ UpdateMusicStream( state->music );
+ }
+ luaCallProcess();
+ luaCallDraw();
+ }
+ stateFree();
+
+ return 1;
+}