Skip to content

Commit

Permalink
Add player, controller, debug stuff.
Browse files Browse the repository at this point in the history
Squashed commit of the following:

commit 529893cee8d90aa41a497181fd7d70332a1f844f
Author: Karn Kaul <[email protected]>
Date:   Wed Feb 28 20:04:57 2024 +0530

    Cleanup spaced.

commit 5f735b0d98c61b5779d1a7ede9d0821d10aad8be
Author: Karn Kaul <[email protected]>
Date:   Wed Feb 28 20:00:39 2024 +0530

    bave stable 0.4.4.

commit 08488b8a9fe51ce12f851ed17fcb68b178598552
Author: Karn Kaul <[email protected]>
Date:   Wed Feb 28 19:59:25 2024 +0530

    Add CI scripts.

commit b90d5e8b15e7f8c6db423711979d00acfbde8e26
Author: Karn Kaul <[email protected]>
Date:   Wed Feb 28 19:44:14 2024 +0530

    Aggregate pointer and gamepad input.

commit c93a4ea449adbd5c8bbb5a12f05fe2ed4615b598
Author: Karn Kaul <[email protected]>
Date:   Tue Feb 27 18:03:44 2024 +0530

    [android] enable both landscape orientations.

commit 237ab692230a68e6f252935273c3354fb996640b
Author: Karn Kaul <[email protected]>
Date:   Tue Feb 27 17:56:03 2024 +0530

    Add `SpringArm`.

commit 8437a7868f8d25b54703f127c555b018d6928bc9
Author: Karn Kaul <[email protected]>
Date:   Tue Feb 27 13:00:23 2024 +0530

    Add debug stuff.

commit a6eb411ca90730e1baa132e919a9ff5db198aa53
Author: Karn Kaul <[email protected]>
Date:   Tue Feb 27 11:58:10 2024 +0530

    bave update

commit 1f36cb91fa041e053df49c6cbfc2d579d57a7f13
Author: Karn Kaul <[email protected]>
Date:   Tue Feb 27 02:08:25 2024 +0530

    Add `PlayerController`, `GamepadProvider`.

    - bave unstable.

commit c9e51859d2d2c17df3621e8d222cdc3b94defacc
Author: Karn Kaul <[email protected]>
Date:   Mon Feb 26 22:51:06 2024 +0530

    Add `Player`, `Game`; improve `ISceneSwitcher`.
  • Loading branch information
karnkaul committed Feb 28, 2024
1 parent 302f979 commit e5f2ed3
Show file tree
Hide file tree
Showing 55 changed files with 3,372 additions and 153 deletions.
13 changes: 13 additions & 0 deletions .github/format_check_diff.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

[[ ! $(git --version) ]] && exit 1

output=$(git diff)

if [[ "$output" != "" ]]; then
echo "One or more source files are not formatted!"
exit 1
fi

echo "All source files are formatted"
exit
41 changes: 41 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: ci
on: [push]
jobs:
build-linux:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: init
run: sudo apt update -yqq && sudo apt install -yqq ninja-build xorg-dev g++-13 clang-15
- name: configure gcc
run: cmake -S . --preset=default -B build -DBAVE_BUILD_SHADERS=OFF -DBAVE_USE_FREETYPE=OFF -DCAPO_USE_OPENAL=OFF -DCMAKE_CXX_COMPILER=g++-13
- name: configure clang
run: cmake -S . --preset=default -B clang -DBAVE_BUILD_SHADERS=OFF -DBAVE_USE_FREETYPE=OFF -DCAPO_USE_OPENAL=OFF -DCMAKE_CXX_COMPILER=clang++-15
- name: build gcc
run: cmake --build build --config=Release -- -d explain
- name: build clang
run: cmake --build clang --config=Release
- name: test
run: cd build && ctest -C Release
build-windows:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- name: configure
run: cmake -S . --preset=vs22 -B build -DBAVE_BUILD_SHADERS=OFF -DBAVE_USE_FREETYPE=OFF -DCAPO_USE_OPENAL=OFF
- name: build
run: cmake --build build --config=Release
- name: test
run: cd build && ctest -C Release
build-macos:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- name: init
run: brew install ninja
- name: configure
run: cmake -S . --preset=default -B build -DBAVE_BUILD_SHADERS=OFF -DBAVE_USE_FREETYPE=OFF -DCAPO_USE_OPENAL=OFF
- name: build
run: cmake --build build --config=Release -- -d explain
- name: test
run: cd build && ctest -C Release
11 changes: 11 additions & 0 deletions .github/workflows/format_check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: ci
on: [push]
jobs:
format-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: format code
run: tools/format_code.sh
- name: check diff
run: .github/format_check_diff.sh
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ include(FetchContent)
FetchContent_Declare(
bave
GIT_REPOSITORY https://github.com/karnkaul/bave
GIT_TAG 26b2d5ecdc119fda3524e454fa304bcb75e8f595 # v0.4.3
GIT_TAG b8dd8a003276fbe21af477da2d2a58d3251ef473 # v0.4.4
SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ext/bave"
)

Expand Down
2,019 changes: 2,019 additions & 0 deletions assets/gamecontrollerdb.txt

Large diffs are not rendered by default.

17 changes: 17 additions & 0 deletions src/android/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
*.iml
.gradle
/local.properties
/.idea/caches
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
.DS_Store
/build
/captures
.externalNativeBuild
.cxx
local.properties

/.idea
1 change: 1 addition & 0 deletions src/android/app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
56 changes: 56 additions & 0 deletions src/android/app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
plugins {
alias(libs.plugins.androidApplication)
alias(libs.plugins.jetbrainsKotlinAndroid)
}

android {
namespace = "com.karnage.spaced"
compileSdk = 34

defaultConfig {
applicationId = "com.karnage.spaced"
minSdk = 28
targetSdk = 34
versionCode = 1
versionName = "1.0"

ndk {
abiFilters.add("arm64-v8a")
abiFilters.add("x86_64")
}
}

buildTypes {
release {
isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = "1.8"
}
externalNativeBuild {
cmake {
path = file("src/main/cpp/CMakeLists.txt")
version = "3.22.1"
}
}
ndkVersion = "26.1.10909125"
}

dependencies {

implementation(libs.androidx.core.ktx)
implementation(libs.androidx.appcompat)
implementation(libs.material)
testImplementation(libs.junit)
androidTestImplementation(libs.androidx.junit)
androidTestImplementation(libs.androidx.espresso.core)
}
21 changes: 21 additions & 0 deletions src/android/app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
1 change: 1 addition & 0 deletions src/android/app/src/main/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/assets
30 changes: 30 additions & 0 deletions src/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">

<application
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.Hog"
tools:targetApi="31">

<activity android:name="android.app.NativeActivity"
android:screenOrientation="userLandscape"
android:label="@string/app_name"
android:exported="true">
<meta-data
android:name="android.app.lib_name"
android:value="spaced-android" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

</manifest>
24 changes: 24 additions & 0 deletions src/android/app/src/main/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
cmake_minimum_required(VERSION 3.22)

project(spaced-android)

set(spaced_path ../../../../../../)
file(REAL_PATH ${spaced_path} spaced_path)
add_subdirectory(${spaced_path} "${CMAKE_CURRENT_BINARY_DIR}/spaced")

add_library(${PROJECT_NAME} SHARED)

target_link_libraries(${PROJECT_NAME} PRIVATE
spaced::lib
)

target_sources(${PROJECT_NAME} PRIVATE
main.cpp
)

add_custom_target(copy-assets ALL
${CMAKE_COMMAND} -E remove_directory "${CMAKE_CURRENT_SOURCE_DIR}/../assets"
COMMAND ${CMAKE_COMMAND} -E copy_directory "${spaced_path}/assets" "${CMAKE_CURRENT_SOURCE_DIR}/../assets"
)

add_dependencies(${PROJECT_NAME} copy-assets)
16 changes: 16 additions & 0 deletions src/android/app/src/main/cpp/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include <bave/android_app.hpp>
#include <spaced/spaced.hpp>

extern "C" {
// Android entry point: must have C linkage.
void android_main(android_app* andr_app) {
// we will use bave::AndroidApp.
// create the App instance.
auto app = bave::AndroidApp{*andr_app, vk::SampleCountFlagBits::e4};
// setup the entry point (Flappy).
app.set_bootloader([](bave::App& app) { return std::make_unique<spaced::Spaced>(app); });
// run App and return its exit code.
// after its own setup, App will create Flappy (via the factory passed above) and drive it every frame.
app.run();
}
}
Loading

0 comments on commit e5f2ed3

Please sign in to comment.