Compare commits

...

2 Commits

Author SHA1 Message Date
Attila Uygun dd14ed30ea Use gn target name for the native lib 2023-09-27 23:35:00 +02:00
Attila Uygun 35958b13f7 Move assets to assets/demo 2023-09-27 21:33:00 +02:00
48 changed files with 60 additions and 46 deletions

View File

@ -1,4 +1,4 @@
copy("assets") {
copy("demo") {
sources = [
"bead.png",
"boss_explosion.mp3",
@ -40,5 +40,5 @@ copy("assets") {
"woom_logo_start_frames_02-03.png",
]
outputs = ["$root_out_dir/assets/{{source_file_part}}"]
outputs = ["$root_out_dir/assets/demo/{{source_file_part}}"]
}

View File

Before

Width:  |  Height:  |  Size: 106 KiB

After

Width:  |  Height:  |  Size: 106 KiB

View File

Before

Width:  |  Height:  |  Size: 103 KiB

After

Width:  |  Height:  |  Size: 103 KiB

View File

Before

Width:  |  Height:  |  Size: 105 KiB

After

Width:  |  Height:  |  Size: 105 KiB

View File

Before

Width:  |  Height:  |  Size: 507 B

After

Width:  |  Height:  |  Size: 507 B

View File

Before

Width:  |  Height:  |  Size: 332 KiB

After

Width:  |  Height:  |  Size: 332 KiB

View File

Before

Width:  |  Height:  |  Size: 55 KiB

After

Width:  |  Height:  |  Size: 55 KiB

View File

Before

Width:  |  Height:  |  Size: 156 KiB

After

Width:  |  Height:  |  Size: 156 KiB

View File

Before

Width:  |  Height:  |  Size: 219 KiB

After

Width:  |  Height:  |  Size: 219 KiB

View File

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 17 KiB

View File

Before

Width:  |  Height:  |  Size: 32 KiB

After

Width:  |  Height:  |  Size: 32 KiB

View File

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 24 KiB

View File

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 26 KiB

View File

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

View File

Before

Width:  |  Height:  |  Size: 102 KiB

After

Width:  |  Height:  |  Size: 102 KiB

View File

Before

Width:  |  Height:  |  Size: 143 KiB

After

Width:  |  Height:  |  Size: 143 KiB

View File

Before

Width:  |  Height:  |  Size: 255 KiB

After

Width:  |  Height:  |  Size: 255 KiB

View File

@ -47,6 +47,7 @@ android {
applicationId 'com.woom.game'
resValue "string", "app_name", "woom"
resValue "string", "interstitial_ad_unit_id", "ca-app-pub-1321063817979967/8373182022"
resValue "string", "admob_application_id", "ca-app-pub-1321063817979967~1100949243"
manifestPlaceholders = [appIcon: "@mipmap/ic_launcher"]
ext {
gnTarget = "demo"
@ -96,6 +97,16 @@ android {
abiFilters = ["x86_64", "x86"]
}
}
// Native library name is same as GN target name.
android.productFlavors.each { flavor ->
if (flavor.dimension == 'game') {
"${flavor.name}" {
resValue "string", "lib_name", flavor.ext.gnTarget
buildConfigField 'String', 'NATIVE_LIBRARY', "\"${flavor.ext.gnTarget}\""
}
}
}
}
sourceSets {
@ -156,7 +167,7 @@ utils.addGameTask('runNinjaFor') { String taskName, String buildType, String arc
dependsOn "runGnFor${arch}${buildType}"
executable rootProject.ext.ninja
args '-C', "${utils.getOutDir(buildType)}/${arch}", utils.getGnTargetFor(game)
args '-C', "${utils.getOutDir(buildType)}/${arch}", "src/${utils.getGnTargetFor(game)}"
// Always run ninja and let it figure out what needs to be compiled.
outputs.upToDateWhen { false }
@ -175,14 +186,12 @@ utils.addGameTask('copyAssetsFor') { String taskName, String buildType, String a
}
// Copy the native library to a directory denoting its arch code as the Android Gradle plugin expects.
// Also rename it to `libkaliber.so` which is the name expected by the engine.
utils.addGameTask('copyJniLibsFor') { String taskName, String buildType, String arch, String game ->
task(taskName, type: Copy) {
dependsOn "runNinjaFor${game}${arch}${buildType}"
from("${utils.getOutDir(buildType)}/${arch}") {
include "lib${utils.getGnTargetFor(game)}.so"
rename "lib${utils.getGnTargetFor(game)}.so", "libkaliber.so"
}
into "${utils.getJniLibsDir(buildType)}/${utils.getAbiCodeFor(arch)}"
}

View File

@ -27,12 +27,12 @@
</intent-filter>
<meta-data
android:name="android.app.lib_name"
android:value="kaliber" />
android:value="@string/lib_name" />
</activity>
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-1321063817979967~1100949243" />
android:value="@string/admob_application_id" />
<provider
android:name="androidx.core.content.FileProvider"

View File

@ -2,4 +2,5 @@
<resources>
<string name="app_name">Kaliber app</string>
<string name="interstitial_ad_unit_id"></string>
<string name="admob_application_id">ca-app-pub-3940256099942544~3347511713</string>
</resources>

View File

@ -19,7 +19,7 @@ game("demo") {
"sky_quad.h",
]
deps = [
"//assets",
"//assets/demo",
"//src/base",
"//src/engine",
]

View File

@ -45,15 +45,15 @@ Demo::~Demo() {
}
bool Demo::PreInitialize() {
if (!font_.Load("PixelCaps!.ttf"))
if (!font_.Load("demo/PixelCaps!.ttf"))
return false;
Engine::Get().SetShaderSource("sky_without_nebula",
"sky_without_nebula.glsl");
Engine::Get().SetShaderSource("sky", "sky.glsl");
"demo/sky_without_nebula.glsl");
Engine::Get().SetShaderSource("sky", "demo/sky.glsl");
Engine::Get().AsyncLoadSound("music", "Game_2_Main.mp3", true);
Engine::Get().AsyncLoadSound("boss_music", "Game_2_Boss.mp3", true);
Engine::Get().AsyncLoadSound("music", "demo/Game_2_Main.mp3", true);
Engine::Get().AsyncLoadSound("boss_music", "demo/Game_2_Boss.mp3", true);
if (!enemy_.PreInitialize()) {
LOG(0) << "Failed to create the enemy.";

View File

@ -78,17 +78,20 @@ Enemy::Enemy() = default;
Enemy::~Enemy() = default;
bool Enemy::PreInitialize() {
Engine::Get().SetImageSource("skull_tex", "enemy_anims_01_frames_ok.png",
Engine::Get().SetImageSource("skull_tex", "demo/enemy_anims_01_frames_ok.png",
true);
Engine::Get().SetImageSource("bug_tex", "enemy_anims_02_frames_ok.png", true);
Engine::Get().SetImageSource("boss_tex1", "Boss_ok.png", true);
Engine::Get().SetImageSource("boss_tex2", "Boss_ok_lvl2.png", true);
Engine::Get().SetImageSource("boss_tex3", "Boss_ok_lvl3.png", true);
Engine::Get().SetImageSource("target_tex", "enemy_target_single_ok.png",
Engine::Get().SetImageSource("bug_tex", "demo/enemy_anims_02_frames_ok.png",
true);
Engine::Get().SetImageSource("blast_tex", "enemy_anims_blast_ok.png", true);
Engine::Get().SetImageSource("shield_tex", "woom_enemy_shield.png", true);
Engine::Get().SetImageSource("crate_tex", "nuke_pack_OK.png", true);
Engine::Get().SetImageSource("boss_tex1", "demo/Boss_ok.png", true);
Engine::Get().SetImageSource("boss_tex2", "demo/Boss_ok_lvl2.png", true);
Engine::Get().SetImageSource("boss_tex3", "demo/Boss_ok_lvl3.png", true);
Engine::Get().SetImageSource("target_tex", "demo/enemy_target_single_ok.png",
true);
Engine::Get().SetImageSource("blast_tex", "demo/enemy_anims_blast_ok.png",
true);
Engine::Get().SetImageSource("shield_tex", "demo/woom_enemy_shield.png",
true);
Engine::Get().SetImageSource("crate_tex", "demo/nuke_pack_OK.png", true);
for (int i = 0; i < kEnemyType_Max; ++i) {
if (i == kEnemyType_PowerUp)
@ -99,16 +102,16 @@ bool Enemy::PreInitialize() {
}
Engine::Get().SetShaderSource("chromatic_aberration",
"chromatic_aberration.glsl");
"demo/chromatic_aberration.glsl");
Engine::Get().AsyncLoadSound("boss_intro", "boss_intro.mp3");
Engine::Get().AsyncLoadSound("boss_explosion", "boss_explosion.mp3");
Engine::Get().AsyncLoadSound("explosion", "explosion.mp3");
Engine::Get().AsyncLoadSound("stealth", "stealth.mp3");
Engine::Get().AsyncLoadSound("shield", "shield.mp3");
Engine::Get().AsyncLoadSound("hit", "hit.mp3");
Engine::Get().AsyncLoadSound("powerup-spawn", "powerup-spawn.mp3");
Engine::Get().AsyncLoadSound("powerup-pick", "powerup-pick.mp3");
Engine::Get().AsyncLoadSound("boss_intro", "demo/boss_intro.mp3");
Engine::Get().AsyncLoadSound("boss_explosion", "demo/boss_explosion.mp3");
Engine::Get().AsyncLoadSound("explosion", "demo/explosion.mp3");
Engine::Get().AsyncLoadSound("stealth", "demo/stealth.mp3");
Engine::Get().AsyncLoadSound("shield", "demo/shield.mp3");
Engine::Get().AsyncLoadSound("hit", "demo/hit.mp3");
Engine::Get().AsyncLoadSound("powerup-spawn", "demo/powerup-spawn.mp3");
Engine::Get().AsyncLoadSound("powerup-pick", "demo/powerup-pick.mp3");
return true;
}

View File

@ -55,7 +55,7 @@ Menu::~Menu() = default;
bool Menu::PreInitialize() {
click_sound_ = std::make_shared<Sound>();
if (!click_sound_->Load("menu_click.mp3", false))
if (!click_sound_->Load("demo/menu_click.mp3", false))
return false;
Demo* game = static_cast<Demo*>(Engine::Get().GetGame());
@ -72,12 +72,12 @@ bool Menu::PreInitialize() {
Engine::Get().SetImageSource("menu_tex",
std::bind(&Menu::CreateMenuImage, this), true);
Engine::Get().SetImageSource("logo_tex0", "woom_logo_start_frames_01.png",
true);
Engine::Get().SetImageSource("logo_tex1", "woom_logo_start_frames_02-03.png",
true);
Engine::Get().SetImageSource("buttons_tex", "menu_icons.png", true);
Engine::Get().SetImageSource("renderer_logo", "renderer_logo.png", true);
Engine::Get().SetImageSource("logo_tex0",
"demo/woom_logo_start_frames_01.png", true);
Engine::Get().SetImageSource("logo_tex1",
"demo/woom_logo_start_frames_02-03.png", true);
Engine::Get().SetImageSource("buttons_tex", "demo/menu_icons.png", true);
Engine::Get().SetImageSource("renderer_logo", "demo/renderer_logo.png", true);
Engine::Get().SetImageSource(
"version_tex",

View File

@ -30,14 +30,15 @@ Player::Player() = default;
Player::~Player() = default;
bool Player::PreInitialize() {
Engine::Get().SetImageSource("weapon_tex", "enemy_anims_flare_ok.png", true);
Engine::Get().SetImageSource("beam_tex", "enemy_ray_ok.png", true);
Engine::Get().SetImageSource("nuke_symbol_tex", "nuke_frames.png", true);
Engine::Get().SetImageSource("health_bead", "bead.png", true);
Engine::Get().SetImageSource("weapon_tex", "demo/enemy_anims_flare_ok.png",
true);
Engine::Get().SetImageSource("beam_tex", "demo/enemy_ray_ok.png", true);
Engine::Get().SetImageSource("nuke_symbol_tex", "demo/nuke_frames.png", true);
Engine::Get().SetImageSource("health_bead", "demo/bead.png", true);
Engine::Get().AsyncLoadSound("laser", "laser.mp3");
Engine::Get().AsyncLoadSound("nuke", "nuke.mp3");
Engine::Get().AsyncLoadSound("no_nuke", "no_nuke.mp3");
Engine::Get().AsyncLoadSound("laser", "demo/laser.mp3");
Engine::Get().AsyncLoadSound("nuke", "demo/nuke.mp3");
Engine::Get().AsyncLoadSound("no_nuke", "demo/no_nuke.mp3");
return true;
}

View File

@ -32,7 +32,7 @@ public class KaliberActivity extends NativeActivity {
static {
// Get the native Java methods bound to exported functions.
System.loadLibrary("kaliber");
System.loadLibrary(BuildConfig.NATIVE_LIBRARY);
}
private InterstitialAd mInterstitialAd;