项目作者: rootVIII

项目描述 :
💀 💀 💀 s k u l l s 💀 💀 💀
高级语言: Go
项目地址: git://github.com/rootVIII/skulls.git
创建时间: 2021-03-07T05:36:40Z
项目社区:https://github.com/rootVIII/skulls

开源协议:GNU General Public License v2.0

下载


Skulls! A simple Columns-like strategy game developed in Golang with the Ebiten library (for Android)


Google Play Store



ex1



ex2




  • The game was developed as a POC to experience creating a simple game with Go/deploying it to Android


  • The Ebiten library for Golang was used to create the game


  • go-inovation was used as a guide for the ebitenmobile .aar binding


  • All development/debugging was done with the gomobile tool and adb


  • Android Studio should be downloaded/installed; the AVD emulators are free and convenient


  • I use the AVD emulators that are installable with Android Studio and stored in
    $ANDROID_HOME/emulator/emulator


  • It may be helpful to store an alias in your profile to open an emulator via a simple command:
    alias pixel4=’$ANDROID_HOME/emulator/emulator -avd “Pixel_4_API_30”‘


  • Font used for text: RADIOLAND.TTF


  • All assets/ (images, audio, and font) were converted to []byte using file2byteslice


  • The project is intended to be built with gomobile for development and testing, or with ebitenmobile for production releases using Android Studio

Build .apk for development and testing using gomobile:
  1. // 1. Navigate to skulls/ and generate a .apk with gomobile:
  2. gomobile build -target=android github.com/rootVIII/skulls/skullsgomobile
  3. // 2. Install the newly created .apk into an already running Android Emulator:
  4. adb -s install skullsgomobile.apk
  5. // Note: to list available emulators (including phone connected for debugging):
  6. adb devices -l
  7. // 3. View debug/logging output from the game:
  8. adb logcat

###### Build .aar for Android Studio binding and production release using ebitenmobile:
  1. // 1. Navigate to skulls/ and generate the .aar binding:
  2. ebitenmobile bind -target android -javapkg com..skulls -o skulls.aar github.com/rootVIII/skulls/skullsebitenbind
  3. // 2. Create a new Android Studio project (choose Empty Activity) and name it SkullsMobile
  4. // 3. Import the new .aar as a module:
  5. // Select File, New, New Module, Import .jar/.aar Package, select the previously built .aar named skulls.aar
  6. // In app/build.gradle, add this line to the dependencies: compile project(':skulls')
  7. // Example:
  8. dependencies {
  9. implementation 'androidx.appcompat:appcompat:1.3.0'
  10. implementation 'com.google.android.material:material:1.3.0'
  11. implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
  12. testImplementation 'junit:junit:4.+'
  13. androidTestImplementation 'androidx.test.ext:junit:1.1.2'
  14. androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
  15. compile project(':skulls')
  16. }
  17. // Then follow screen prompts to sync the build.gradle change to the project
  18. // 4. Place the following in app/src/main/java/com..skullsmobile/MainActivity.java:
  19. package com..skullsmobile;
  20. import androidx.appcompat.app.AppCompatActivity;
  21. import android.os.Bundle;
  22. import go.Seq;
  23. import com..skulls.skullsebitenbind.EbitenView;
  24. public class MainActivity extends AppCompatActivity {
  25. @Override
  26. protected void onCreate(Bundle savedInstanceState) {
  27. super.onCreate(savedInstanceState);
  28. setContentView(R.layout.activity_main);
  29. Seq.setContext(getApplicationContext());
  30. }
  31. private EbitenView getEbitenView() {
  32. return (EbitenView)this.findViewById(R.id.ebitenview);
  33. }
  34. @Override
  35. protected void onPause() {
  36. super.onPause();
  37. this.getEbitenView().suspendGame();
  38. }
  39. @Override
  40. protected void onResume() {
  41. super.onResume();
  42. this.getEbitenView().resumeGame();
  43. }
  44. }
  45. // 5. Add a separate error handling class in app/src/main/java/com.skullsmobile/EbitenViewWithErrorHandling.java
  46. package com.solsticenet.skullsmobile;
  47. import android.content.Context;
  48. import android.util.AttributeSet;
  49. import com..skulls.skullsebitenbind.EbitenView;
  50. class EbitenViewWithErrorHandling extends EbitenView {
  51. public EbitenViewWithErrorHandling(Context context) {
  52. super(context);
  53. }
  54. public EbitenViewWithErrorHandling(Context context, AttributeSet attributeSet) {
  55. super(context, attributeSet);
  56. }
  57. @Override
  58. protected void onErrorOnGameUpdate(Exception e) {
  59. // You can define your own error handling e.g., using Crashlytics.
  60. // e.g., Crashlytics.logException(e);
  61. super.onErrorOnGameUpdate(e);
  62. }
  63. }
  64. // 6. Add the below into app/src/main/res/AndroidManifest.xml:
  65. .skullsmobile.EbitenViewWithErrorHandling
  66. android:id="@+id/ebitenview"
  67. android:layout_width="match_parent"
  68. android:layout_height="match_parent"
  69. android:focusable="true" />
  70. // 7. The game should now be usable in Android Studio (sign the project with developer keys, UI adjustments in AndroidManifest.xml etc.)


This was developed on macOS Big Sur.



Author: rootVIII 2021