Skip to content

Commit f4b3c73

Browse files
committed
Initial raylib/raymob project using lua bindings
0 parents  commit f4b3c73

18 files changed

Lines changed: 600 additions & 0 deletions

.gitignore

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Gradle files
2+
.gradle/
3+
build/
4+
5+
# Local configuration file (sdk path, etc)
6+
local.properties
7+
8+
# Log/OS Files
9+
*.log
10+
11+
# Android Studio generated files and folders
12+
captures/
13+
.externalNativeBuild/
14+
.cxx/
15+
*.apk
16+
output.json
17+
18+
# IntelliJ
19+
*.iml
20+
.idea/
21+
!.idea/compiler.xml
22+
!.idea/gradle.xml
23+
!.idea/misc.xml
24+
!.idea/vcs.xml
25+
26+
# Keystore files
27+
*.jks
28+
*.keystore
29+
30+
# Google Services (e.g. APIs or Firebase)
31+
google-services.json
32+
33+
# Android Profiling
34+
*.hprof

.gitmodules

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[submodule "libs/raylib-lua"]
2+
path = libs/raylib-lua
3+
url = https://github.com/TSnake41/raylib-lua.git
4+
[submodule "libs/raygui"]
5+
path = libs/raygui
6+
url = https://github.com/raysan5/raygui.git
7+
[submodule "libs/raymob"]
8+
path = libs/raymob
9+
url = https://github.com/Bigfoot71/raymob.git

LICENSE

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
raymob License (MIT)
2+
3+
Copyright (c) 2023-2024 Le Juez Victor
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
22+
23+
-------------------------------------------------------------------------------
24+
25+
raylib License (zlib)
26+
27+
Copyright (c) 2013-2024 Ramon Santamaria (@raysan5)
28+
29+
This software is provided "as-is", without any express or implied warranty. In no event
30+
will the authors be held liable for any damages arising from the use of this software.
31+
32+
Permission is granted to anyone to use this software for any purpose, including commercial
33+
applications, and to alter it and redistribute it freely, subject to the following restrictions:
34+
35+
1. The origin of this software must not be misrepresented; you must not claim that you
36+
wrote the original software. If you use this software in a product, an acknowledgment
37+
in the product documentation would be appreciated but is not required.
38+
39+
2. Altered source versions must be plainly marked as such, and must not be misrepresented
40+
as being the original software.
41+
42+
3. This notice may not be removed or altered from any source distribution.
43+
44+
-------------------------------------------------------------------------------
45+
46+
"raylib" refers to the raylib library, which is separately licensed under the zlib license.
47+
All code related to raylib is subject to the zlib license, not the MIT license.

app/build.gradle

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
plugins {
2+
id 'com.android.application'
3+
}
4+
5+
android {
6+
namespace 'com.raylib.testgame'
7+
compileSdk 34
8+
ndkVersion "27.1.12297006"
9+
10+
defaultConfig {
11+
applicationId "com.raylib.testgame"
12+
minSdk 29
13+
targetSdk 34
14+
versionCode 1
15+
versionName "1.0"
16+
17+
externalNativeBuild {
18+
cmake {
19+
cppFlags "-std=c++17 -fexceptions -frtti"
20+
abiFilters 'arm64-v8a' // Only ARM64
21+
}
22+
}
23+
24+
ndk {
25+
abiFilters "arm64-v8a"
26+
}
27+
}
28+
29+
buildTypes {
30+
release {
31+
minifyEnabled false
32+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
33+
}
34+
}
35+
36+
externalNativeBuild {
37+
cmake {
38+
path "src/main/cpp/CMakeLists.txt"
39+
version "3.22.1" // Use CMake version compatible with NDK 27b
40+
}
41+
}
42+
43+
sourceSets {
44+
main {
45+
assets.srcDirs = ['src/main/assets']
46+
}
47+
}
48+
}
49+
50+
dependencies {
51+
// No extra Java dependencies yet
52+
}

app/src/main/AndroidManifest.xml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
2+
3+
<application
4+
android:label="TestGame"
5+
android:theme="@android:style/Theme.DeviceDefault.NoActionBar.Fullscreen"
6+
android:hasCode="false">
7+
8+
<activity android:name="android.app.NativeActivity"
9+
android:label="TestGame"
10+
android:configChanges="orientation|keyboardHidden|screenSize"
11+
android:exported="true">
12+
<meta-data android:name="android.app.lib_name"
13+
android:value="testgame" />
14+
<intent-filter>
15+
<action android:name="android.intent.action.MAIN" />
16+
<category android:name="android.intent.category.LAUNCHER" />
17+
</intent-filter>
18+
</activity>
19+
20+
</application>
21+
22+
</manifest>

app/src/main/assets/main.lua

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
2+
local rl = require("raylib")
3+
4+
rl.InitWindow(1280, 720, "Hello Raylib-Lua!")
5+
rl.SetTargetFPS(60)
6+
7+
while not rl.WindowShouldClose() do
8+
rl.BeginDrawing()
9+
rl.ClearBackground(rl.RAYWHITE)
10+
rl.DrawText("Hello from Lua on Android!", 10, 10, 30, rl.BLACK)
11+
rl.EndDrawing()
12+
end
13+
14+
rl.CloseWindow()

app/src/main/cpp/CMakeLists.txt

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
cmake_minimum_required(VERSION 3.10)
2+
3+
project("yourgame")
4+
5+
set(CMAKE_CXX_STANDARD 17)
6+
7+
# Path to libraries
8+
set(RAYLIB_LUA_DIR ${CMAKE_SOURCE_DIR}/../../../../libs/raylib-lua)
9+
set(RAYGUI_DIR ${CMAKE_SOURCE_DIR}/../../../../libs/raygui)
10+
set(RAYMOB_DIR ${CMAKE_SOURCE_DIR}/../../../../libs/raymob)
11+
12+
# Add raylib sources (edit depending if raylib is prebuilt or source)
13+
add_subdirectory(${RAYLIB_LUA_DIR}/raylib raylib-build)
14+
15+
# Add executable
16+
add_library(yourgame SHARED
17+
dummy_main.c
18+
)
19+
20+
# Link with raylib
21+
target_link_libraries(yourgame
22+
raylib
23+
android
24+
log
25+
EGL
26+
GLESv2
27+
OpenSLES
28+
m
29+
z
30+
)

app/src/main/cpp/dummy_main.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#include "raylib.h"
2+
#include "lua.h"
3+
#include "lauxlib.h"
4+
#include "lualib.h"
5+
6+
int main() {
7+
lua_State *L = luaL_newstate();
8+
luaL_openlibs(L);
9+
10+
if (luaL_dofile(L, "main.lua") != LUA_OK) {
11+
TraceLog(LOG_ERROR, "Lua Error: %s", lua_tostring(L, -1));
12+
}
13+
14+
lua_close(L);
15+
return 0;
16+
}

build.gradle

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
buildscript {
2+
repositories {
3+
google()
4+
mavenCentral()
5+
}
6+
dependencies {
7+
classpath 'com.android.tools.build:gradle:8.2.2' // Latest stable
8+
}
9+
}
10+
11+
allprojects {
12+
repositories {
13+
google()
14+
mavenCentral()
15+
}
16+
}

gradle.properties

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
org.gradle.jvmargs=-Xmx2048m
2+
android.useAndroidX=true
3+
android.enableJetifier=true

0 commit comments

Comments
 (0)