diff options
| author | ruki <[email protected]> | 2025-12-16 23:39:52 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2025-12-16 23:39:52 +0800 |
| commit | 3e7d8b94f1a1349ccbae107b5a2aeac9fb77e6e2 (patch) | |
| tree | 11ac0a272ccfc04633a836a8cce4a6d3b9cab46f | |
| parent | 5537af295c452f1bbc1875c27b285a35a167f44e (diff) | |
improve raylib tests
16 files changed, 152 insertions, 8 deletions
diff --git a/tests/projects/android/native_app/android/AndroidManifest.xml b/tests/projects/android/native_app/raylib_basic/android/AndroidManifest.xml index 40cfd7066..2d6b2d67c 100644 --- a/tests/projects/android/native_app/android/AndroidManifest.xml +++ b/tests/projects/android/native_app/raylib_basic/android/AndroidManifest.xml @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" - package="com.raylib.demo" + package="com.raylib.basic" android:versionCode="15" android:versionName="1.5"> @@ -11,12 +11,12 @@ <uses-permission android:name="android.permission.SET_RELEASE_APP"/> <application - android:label="Fighter" android:debuggable="true" android:hasCode="false" + android:label="RaylibBasic" android:debuggable="true" android:hasCode="false" tools:replace="android:icon,android:theme,android:allowBackup,label" android:icon="@mipmap/icon"> <activity android:name="android.app.NativeActivity" - android:label="Fighter" + android:label="RaylibBasic" android:configChanges="orientation|keyboardHidden|screenSize|screenLayout" android:screenOrientation="portrait" android:theme="@android:style/Theme.NoTitleBar.Fullscreen"> diff --git a/tests/projects/android/native_app/android/debug.jks b/tests/projects/android/native_app/raylib_basic/android/debug.jks Binary files differindex 0a18aa012..0a18aa012 100644 --- a/tests/projects/android/native_app/android/debug.jks +++ b/tests/projects/android/native_app/raylib_basic/android/debug.jks diff --git a/tests/projects/android/native_app/android/res/mipmap-mdpi/icon.png b/tests/projects/android/native_app/raylib_basic/android/res/mipmap-mdpi/icon.png Binary files differindex 743413831..743413831 100644 --- a/tests/projects/android/native_app/android/res/mipmap-mdpi/icon.png +++ b/tests/projects/android/native_app/raylib_basic/android/res/mipmap-mdpi/icon.png diff --git a/tests/projects/android/native_app/android/res/mipmap/icon.png b/tests/projects/android/native_app/raylib_basic/android/res/mipmap/icon.png Binary files differindex 743413831..743413831 100644 --- a/tests/projects/android/native_app/android/res/mipmap/icon.png +++ b/tests/projects/android/native_app/raylib_basic/android/res/mipmap/icon.png diff --git a/tests/projects/android/native_app/android/res/values/strings.xml b/tests/projects/android/native_app/raylib_basic/android/res/values/strings.xml index e98a18284..bc0a9bfbf 100644 --- a/tests/projects/android/native_app/android/res/values/strings.xml +++ b/tests/projects/android/native_app/raylib_basic/android/res/values/strings.xml @@ -1,4 +1,4 @@ <?xml version="1.0" encoding="utf-8"?> <resources> - <string name="app_name">Space Defender</string> + <string name="app_name">Raylib Basic</string> </resources>
\ No newline at end of file diff --git a/tests/projects/android/native_app/android/res/values/styles.xml b/tests/projects/android/native_app/raylib_basic/android/res/values/styles.xml index 621547380..621547380 100644 --- a/tests/projects/android/native_app/android/res/values/styles.xml +++ b/tests/projects/android/native_app/raylib_basic/android/res/values/styles.xml diff --git a/tests/projects/android/native_app/src/main.cpp b/tests/projects/android/native_app/raylib_basic/src/main.cpp index e906f490e..b160499b7 100644 --- a/tests/projects/android/native_app/src/main.cpp +++ b/tests/projects/android/native_app/raylib_basic/src/main.cpp @@ -1,7 +1,7 @@ #include <raylib.h> #include <android/log.h> -#define LOG_TAG "raydemo" +#define LOG_TAG "raydemo_basic" #define LOGI(...) __android_log_print(ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__) int main(int argc, char** argv) { diff --git a/tests/projects/android/native_app/xmake.lua b/tests/projects/android/native_app/raylib_basic/xmake.lua index f5fc5f2ed..50886764d 100644 --- a/tests/projects/android/native_app/xmake.lua +++ b/tests/projects/android/native_app/raylib_basic/xmake.lua @@ -2,7 +2,7 @@ add_rules("mode.debug", "mode.release") add_requires("raylib 5.5.0") -target("raydemo") +target("raydemo_basic") set_kind("binary") set_languages("c++17") add_files("src/main.cpp") @@ -14,6 +14,6 @@ target("raydemo") android_res = "android/res", keystore = "android/debug.jks", keystore_pass = "123456", - package_name = "com.raylib.demo", - logcat_filters = {"raydemo_android", "raylib"} + package_name = "com.raylib.basic", + logcat_filters = {"raydemo_basic", "raylib"} }) diff --git a/tests/projects/android/native_app/raylib_particles/android/AndroidManifest.xml b/tests/projects/android/native_app/raylib_particles/android/AndroidManifest.xml new file mode 100644 index 000000000..70dd36933 --- /dev/null +++ b/tests/projects/android/native_app/raylib_particles/android/AndroidManifest.xml @@ -0,0 +1,31 @@ +<?xml version="1.0" encoding="utf-8"?> +<manifest xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:tools="http://schemas.android.com/tools" + package="com.raylib.particles" + + android:versionCode="15" + android:versionName="1.5"> + + <uses-sdk android:minSdkVersion="21" android:targetSdkVersion="30" /> + + <uses-permission android:name="android.permission.SET_RELEASE_APP"/> + + <application + android:label="RaylibParticles" android:debuggable="true" android:hasCode="false" + tools:replace="android:icon,android:theme,android:allowBackup,label" + android:icon="@mipmap/icon"> + + <activity android:name="android.app.NativeActivity" + android:label="RaylibParticles" + android:configChanges="orientation|keyboardHidden|screenSize|screenLayout" + android:screenOrientation="portrait" + android:theme="@android:style/Theme.NoTitleBar.Fullscreen"> + <meta-data android:name="android.app.lib_name" + android:value="main" /> + <intent-filter> + <action android:name="android.intent.action.MAIN" /> + <category android:name="android.intent.category.LAUNCHER" /> + </intent-filter> + </activity> + </application> +</manifest>
\ No newline at end of file diff --git a/tests/projects/android/native_app/raylib_particles/android/debug.jks b/tests/projects/android/native_app/raylib_particles/android/debug.jks Binary files differnew file mode 100644 index 000000000..0a18aa012 --- /dev/null +++ b/tests/projects/android/native_app/raylib_particles/android/debug.jks diff --git a/tests/projects/android/native_app/raylib_particles/android/res/mipmap-mdpi/icon.png b/tests/projects/android/native_app/raylib_particles/android/res/mipmap-mdpi/icon.png Binary files differnew file mode 100644 index 000000000..743413831 --- /dev/null +++ b/tests/projects/android/native_app/raylib_particles/android/res/mipmap-mdpi/icon.png diff --git a/tests/projects/android/native_app/raylib_particles/android/res/mipmap/icon.png b/tests/projects/android/native_app/raylib_particles/android/res/mipmap/icon.png Binary files differnew file mode 100644 index 000000000..743413831 --- /dev/null +++ b/tests/projects/android/native_app/raylib_particles/android/res/mipmap/icon.png diff --git a/tests/projects/android/native_app/raylib_particles/android/res/values/strings.xml b/tests/projects/android/native_app/raylib_particles/android/res/values/strings.xml new file mode 100644 index 000000000..3967cc312 --- /dev/null +++ b/tests/projects/android/native_app/raylib_particles/android/res/values/strings.xml @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> + <string name="app_name">Raylib Particles</string> +</resources>
\ No newline at end of file diff --git a/tests/projects/android/native_app/raylib_particles/android/res/values/styles.xml b/tests/projects/android/native_app/raylib_particles/android/res/values/styles.xml new file mode 100644 index 000000000..621547380 --- /dev/null +++ b/tests/projects/android/native_app/raylib_particles/android/res/values/styles.xml @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> + <style name="AppTheme" parent="android:Theme.NoTitleBar.Fullscreen"> + <item name="android:windowBackground">@android:color/black</item> + <item name="android:colorPrimary">#FF6200EE</item> + <item name="android:colorPrimaryDark">#FF3700B3</item> + <item name="android:colorAccent">#FF03DAC5</item> + </style> +</resources>
\ No newline at end of file diff --git a/tests/projects/android/native_app/raylib_particles/src/main.cpp b/tests/projects/android/native_app/raylib_particles/src/main.cpp new file mode 100644 index 000000000..41dd8bd4a --- /dev/null +++ b/tests/projects/android/native_app/raylib_particles/src/main.cpp @@ -0,0 +1,81 @@ +#include <raylib.h> +#include <android/log.h> +#include <vector> +#include <cmath> + +#define LOG_TAG "raydemo_particles" +#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__) + +struct Particle { + Vector2 position; + Vector2 velocity; + Color color; + float size; + float life; +}; + +int main(int argc, char** argv) { + InitWindow(0, 0, "Raylib Particles"); + SetTargetFPS(60); + LOGD("raylib particles starting!"); + + std::vector<Particle> particles; + + while (!WindowShouldClose()) { + // Update + bool inputActive = IsMouseButtonDown(MOUSE_BUTTON_LEFT) || GetTouchPointCount() > 0; + Vector2 pos; + + if (inputActive) { + pos = GetMousePosition(); + if (GetTouchPointCount() > 0) pos = GetTouchPosition(0); + } else { + // Auto emit when idle + double time = GetTime(); + pos.x = GetScreenWidth() / 2.0f + cos(time * 3.0f) * (GetScreenWidth() / 4.0f); + pos.y = GetScreenHeight() / 2.0f + sin(time * 2.0f) * (GetScreenHeight() / 4.0f); + } + + if (inputActive || GetRandomValue(0, 100) < 50) { + int count = inputActive ? 5 : 2; + for (int i = 0; i < count; i++) { + Particle p; + p.position = pos; + p.velocity = {(float)GetRandomValue(-200, 200) / 100.0f, (float)GetRandomValue(-200, 200) / 100.0f}; + p.color = (Color){(unsigned char)GetRandomValue(0, 255), (unsigned char)GetRandomValue(0, 255), (unsigned char)GetRandomValue(0, 255), 255}; + p.size = (float)GetRandomValue(5, 20); + p.life = 1.0f; + particles.push_back(p); + } + } + + for (auto it = particles.begin(); it != particles.end();) { + it->position.x += it->velocity.x * 5.0f; + it->position.y += it->velocity.y * 5.0f; + it->life -= 0.02f; + it->size *= 0.99f; + + if (it->life <= 0) { + it = particles.erase(it); + } else { + ++it; + } + } + + // Draw + BeginDrawing(); + ClearBackground(BLACK); + + for (const auto& p : particles) { + DrawCircleV(p.position, p.size, Fade(p.color, p.life)); + } + + DrawText("Touch to create particles!", 10, 40, 20, WHITE); + DrawFPS(10, 10); + + EndDrawing(); + } + + CloseWindow(); + return 0; +} diff --git a/tests/projects/android/native_app/raylib_particles/xmake.lua b/tests/projects/android/native_app/raylib_particles/xmake.lua new file mode 100644 index 000000000..c6d9a6217 --- /dev/null +++ b/tests/projects/android/native_app/raylib_particles/xmake.lua @@ -0,0 +1,19 @@ +add_rules("mode.debug", "mode.release") + +add_requires("raylib 5.5.0") + +target("raydemo_particles") + set_kind("binary") + set_languages("c++17") + add_files("src/main.cpp") + add_syslinks("log") + add_packages("raylib") + add_rules("android.native_app", { + android_sdk_version = "35", + android_manifest = "android/AndroidManifest.xml", + android_res = "android/res", + keystore = "android/debug.jks", + keystore_pass = "123456", + package_name = "com.raylib.particles", + logcat_filters = {"raydemo_particles", "raylib"} + }) |
