This commit is contained in:
2014-08-26 19:26:58 -07:00
commit 2c38a57e48
59 changed files with 516 additions and 0 deletions

15
README.md Normal file
View File

@@ -0,0 +1,15 @@
## Introduction
A play-clj game in which ... well, that part is up to you.
## Contents
* `android/src` Android-specific code
* `desktop/resources` Images, audio, and other files
* `desktop/src` Desktop-specific code
* `desktop/src-common` Cross-platform game code
* `ios/src` iOS-specific code
## Building
All projects can be built using [Nightcode](https://nightcode.info/), or on the command line using [Leiningen](https://github.com/technomancy/leiningen) with the [lein-droid](https://github.com/clojure-android/lein-droid) and [lein-fruit](https://github.com/oakes/lein-fruit) plugins.

View File

@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="advent.core"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="15" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name">
<activity android:name=".SplashActivity"
android:theme="@android:style/Theme.Translucent.NoTitleBar">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity android:name=".AndroidLauncher">
<intent-filter>
<action android:name='advent.core.MAIN'/>
<category android:name='android.intent.category.DEFAULT'/>
</intent-filter>
</activity>
</application>
</manifest>

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
android/libs/x86/libgdx.so Normal file

Binary file not shown.

37
android/project.clj Normal file
View File

@@ -0,0 +1,37 @@
(defproject advent "0.0.1-SNAPSHOT"
:description "FIXME: write description"
:dependencies [[com.badlogicgames.gdx/gdx "1.3.0" :use-resources true]
[com.badlogicgames.gdx/gdx-backend-android "1.3.0"]
[com.badlogicgames.gdx/gdx-box2d "1.3.0"]
[com.badlogicgames.gdx/gdx-bullet "1.3.0"]
[neko/neko "3.0.2"]
[org.clojure-android/clojure "1.6.0-RC1" :use-resources true]
[play-clj "0.3.9"]]
:profiles {:dev {:dependencies [[android/tools.nrepl "0.2.0-bigstack"]
[compliment "0.1.3"]]
:android {:aot :all-with-unused}}
:release {:android
{;; Specify the path to your private
;; keystore and the the alias of the
;; key you want to sign APKs with.
;; :keystore-path "/home/user/.android/private.keystore"
;; :key-alias "mykeyalias"
:aot :all}}}
:android {;; Specify the path to the Android SDK directory either
;; here or in your ~/.lein/profiles.clj file.
;; :sdk-path "/home/user/path/to/android-sdk/"
;; Uncomment this if dexer fails with OutOfMemoryException
;; :force-dex-optimize true
:assets-path "../desktop/resources"
:native-libraries-paths ["libs"]
:target-version "15"
:aot-exclude-ns ["clojure.parallel" "clojure.core.reducers"]
:dex-opts ["-JXmx2048M"]}
:source-paths ["src/clojure" "../desktop/src-common"]
:java-source-paths ["src/java" "gen"]
:javac-options ["-target" "1.6" "-source" "1.6" "-Xlint:-options"])

View File

@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/linear_interpolator">
<rotate
android:duration="2000"
android:fromDegrees="0"
android:pivotX="49.566%"
android:pivotY="66.65%"
android:repeatCount="infinite"
android:toDegrees="360"/>
</set>

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<corners android:radius="20dp"/>
<padding android:left="10dp" android:right="10dp" android:top="10dp" android:bottom="10dp"/>
<solid android:color="@android:color/black"/>
</shape>

View File

@@ -0,0 +1,59 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:orientation="vertical"
android:layout_margin="10dp"
android:background="@drawable/splash_background" >
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center" >
<ImageView
android:id="@+id/splash_droid"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/splash_droid" >
</ImageView>
<ImageView
android:id="@+id/splash_circles"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/splash_circle" >
</ImageView>
<ImageView
android:id="@+id/splash_droid_hands"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/splash_hands" >
</ImageView>
</RelativeLayout>
<TextView
android:id="@+id/splash_app_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="18dp"
android:text="Application name"
android:textSize="30sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="18dp"
android:text="Please wait for the application to load..." />
</LinearLayout>
</RelativeLayout>

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">advent</string>
</resources>

View File

@@ -0,0 +1,20 @@
package advent.core;
import clojure.lang.RT;
import clojure.lang.Symbol;
import com.badlogic.gdx.backends.android.AndroidApplication;
import com.badlogic.gdx.Game;
public class AndroidLauncher extends AndroidApplication {
public void onCreate (android.os.Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
RT.var("clojure.core", "require").invoke(Symbol.intern("advent.core"));
try {
Game game = (Game) RT.var("advent.core", "advent").deref();
initialize(game);
} catch (Exception e) {
e.printStackTrace();
}
}
}

View File

@@ -0,0 +1,74 @@
package advent.core;
import android.app.Activity;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;
import android.widget.TextView;
import android.util.Log;
import clojure.lang.Symbol;
import clojure.lang.Var;
import clojure.lang.RT;
import advent.core.R;
public class SplashActivity extends Activity {
private static boolean firstLaunch = true;
private static String TAG = "Splash";
@Override
public void onCreate(Bundle bundle) {
super.onCreate(bundle);
if (firstLaunch) {
firstLaunch = false;
setupSplash();
loadClojure();
} else {
proceed();
}
}
public void setupSplash() {
setContentView(R.layout.splashscreen);
TextView appNameView = (TextView)findViewById(R.id.splash_app_name);
appNameView.setText(R.string.app_name);
Animation rotation = AnimationUtils.loadAnimation(this, R.anim.splash_rotation);
ImageView circleView = (ImageView)findViewById(R.id.splash_circles);
circleView.startAnimation(rotation);
}
public void proceed() {
startActivity(new Intent("advent.core.MAIN"));
finish();
}
public void loadClojure() {
new Thread(new Runnable(){
@Override
public void run() {
Symbol CLOJURE_MAIN = Symbol.intern("neko.init");
Var REQUIRE = RT.var("clojure.core", "require");
REQUIRE.invoke(CLOJURE_MAIN);
Var INIT = RT.var("neko.init", "init");
INIT.invoke(SplashActivity.this.getApplication());
try {
Class.forName("advent.core.AndroidLauncher");
} catch (ClassNotFoundException e) {
Log.e(TAG, "Failed loading AndroidLauncher", e);
}
proceed();
}
}).start();
}
}

20
desktop/project.clj Normal file
View File

@@ -0,0 +1,20 @@
(defproject advent "0.0.1-SNAPSHOT"
:description "FIXME: write description"
:dependencies [[com.badlogicgames.gdx/gdx "1.3.0"]
[com.badlogicgames.gdx/gdx-backend-lwjgl "1.3.0"]
[com.badlogicgames.gdx/gdx-box2d "1.3.0"]
[com.badlogicgames.gdx/gdx-box2d-platform "1.3.0"
:classifier "natives-desktop"]
[com.badlogicgames.gdx/gdx-bullet "1.3.0"]
[com.badlogicgames.gdx/gdx-bullet-platform "1.3.0"
:classifier "natives-desktop"]
[com.badlogicgames.gdx/gdx-platform "1.3.0"
:classifier "natives-desktop"]
[org.clojure/clojure "1.6.0"]
[play-clj "0.3.9"]]
:source-paths ["src" "src-common"]
:javac-options ["-target" "1.6" "-source" "1.6" "-Xlint:-options"]
:aot [advent.core.desktop-launcher]
:main advent.core.desktop-launcher)

BIN
desktop/resources/bg.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.8 KiB

BIN
desktop/resources/bg2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.4 KiB

BIN
desktop/resources/bg2.pxi Normal file

Binary file not shown.

BIN
desktop/resources/bg3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

BIN
desktop/resources/bg3.pxi Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
<dict>
<key>duration</key>
<real>0.10000000149011612</real>
</dict>
<dict>
<key>duration</key>
<real>0.10000000149011612</real>
</dict>
<dict>
<key>duration</key>
<real>0.10000000149011612</real>
</dict>
<dict>
<key>duration</key>
<real>0.10000000149011612</real>
</dict>
<dict>
<key>duration</key>
<real>0.10000000149011612</real>
</dict>
<dict>
<key>duration</key>
<real>0.10000000149011612</real>
</dict>
<dict>
<key>duration</key>
<real>0.10000000149011612</real>
</dict>
<dict>
<key>duration</key>
<real>0.10000000149011612</real>
</dict>
</array>
</plist>

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
<dict>
<key>duration</key>
<real>0.10000000149011612</real>
</dict>
<dict>
<key>duration</key>
<real>0.10000000149011612</real>
</dict>
<dict>
<key>duration</key>
<real>0.10000000149011612</real>
</dict>
<dict>
<key>duration</key>
<real>0.10000000149011612</real>
</dict>
<dict>
<key>duration</key>
<real>0.10000000149011612</real>
</dict>
<dict>
<key>duration</key>
<real>0.10000000149011612</real>
</dict>
<dict>
<key>duration</key>
<real>0.10000000149011612</real>
</dict>
<dict>
<key>duration</key>
<real>0.10000000149011612</real>
</dict>
</array>
</plist>

View File

@@ -0,0 +1,47 @@
(ns advent.core
(:require [play-clj.core :refer :all]
[play-clj.ui :refer :all]
[play-clj.g2d :refer :all]))
(defscreen main-screen
:on-show
(fn [screen entities]
(update! screen :renderer (stage) :camera (orthographic))
(let [player-sheet (texture! (texture "player.png") :split 18 36)
background (texture "bg3.png")]
[(assoc background :scale-y 1.0 :scale-x 1.0 :origin-y 0 :origin-x 0 :ego? false :x -60 :y -34)
{:right (animation 0.1 (for [i (range 8)]
(texture (aget player-sheet 0 i))))
:left (animation 0.1 (for [i (range 8)]
(texture (aget player-sheet 1 i))))
:anim (animation 0.1 (for [i (range 8)]
(texture (aget player-sheet 0 i))))
:x 0 :y 25 :origin-x 0 :origin-y 0 :x-velocity 1
:ego? true}]))
:on-render
(fn [screen entities]
(clear!)
(render! screen (for [entity entities]
(if (:ego? entity)
(merge (animation->texture screen (:anim entity))
{:ego? (:ego? entity) :x (+ (:x entity) (:x-velocity entity)) :y 0 :origin-x 0 :origin-y 0 :anim (:anim entity) :x-velocity (:x-velocity entity) :left (:left entity) :right (:right entity)}
(when (> (:x entity) (width screen))
{:x-velocity -1 :anim (:left entity)})
(when (< (:x entity) 0)
{:x-velocity 1 :anim (:right entity)}))
entity))))
:on-resize
(fn [screen entities]
(height! screen 135))
:on-scrolled
(fn [screen entities]
(set! (. (:camera screen) zoom) (min 1.5 (max (+ (.zoom (:camera screen)) (* 0.01 (:amount screen))) 1)))
nil))
(defgame advent
:on-create
(fn [this]
(set-screen! this main-screen)))

View File

@@ -0,0 +1,10 @@
(ns advent.core.desktop-launcher
(:require [advent.core :refer :all])
(:import [com.badlogic.gdx.backends.lwjgl LwjglApplication]
[org.lwjgl.input Keyboard])
(:gen-class))
(defn -main
[]
(LwjglApplication. advent "advent" 1920 1080)
(Keyboard/enableRepeatEvents true))

61
ios/Info.plist.xml Normal file
View File

@@ -0,0 +1,61 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleDisplayName</key>
<string>advent</string>
<key>CFBundleExecutable</key>
<string>advent</string>
<key>CFBundleIdentifier</key>
<string>advent.core</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>advent</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>${app.version}</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UIDeviceFamily</key>
<array>
<integer>1</integer>
<integer>2</integer>
</array>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>CFBundleIcons</key>
<dict>
<key>CFBundlePrimaryIcon</key>
<dict>
<key>CFBundleIconFiles</key>
<array>
<string>Icon</string>
<string>Icon-72</string>
</array>
</dict>
</dict>
</dict>
</plist>

BIN
ios/libs/libObjectAL.a Normal file

Binary file not shown.

BIN
ios/libs/libgdx-box2d.a Normal file

Binary file not shown.

BIN
ios/libs/libgdx-bullet.a Normal file

Binary file not shown.

BIN
ios/libs/libgdx.a Normal file

Binary file not shown.

17
ios/project.clj Normal file
View File

@@ -0,0 +1,17 @@
(defproject advent "0.0.1-SNAPSHOT"
:description "FIXME: write description"
:dependencies [[com.badlogicgames.gdx/gdx "1.3.0"]
[com.badlogicgames.gdx/gdx-backend-robovm "1.3.0"]
[com.badlogicgames.gdx/gdx-box2d "1.3.0"]
[com.badlogicgames.gdx/gdx-bullet "1.3.0"]
[org.clojure/clojure "1.6.0"]
[play-clj "0.3.9"]]
:source-paths ["src/clojure" "../desktop/src-common"]
:java-source-paths ["src/java"]
:javac-options ["-target" "1.7" "-source" "1.7" "-Xlint:-options"]
:ios {:robovm-opts ["-forcelinkclasses" "advent.**:clojure.**:com.badlogic.**:play_clj.**"
"-libs" "libs/libObjectAL.a:libs/libgdx.a:libs/libgdx-box2d.a:libs/libgdx-bullet.a"
"-frameworks" "UIKit:OpenGLES:QuartzCore:CoreGraphics:OpenAL:AudioToolbox:AVFoundation"
"-resources" "../desktop/resources/**"]}
:aot :all
:main advent.core.IOSLauncher)

View File

@@ -0,0 +1,30 @@
package advent.core;
import clojure.lang.RT;
import clojure.lang.Symbol;
import com.badlogic.gdx.*;
import com.badlogic.gdx.backends.iosrobovm.*;
import org.robovm.apple.foundation.*;
import org.robovm.apple.uikit.*;
public class IOSLauncher extends IOSApplication.Delegate {
protected IOSApplication createApplication() {
IOSApplicationConfiguration config = new IOSApplicationConfiguration();
RT.var("clojure.core", "require").invoke(Symbol.intern("advent.core"));
try {
Game game = (Game) RT.var("advent.core", "advent").deref();
return new IOSApplication(game, config);
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
public static void main(String[] argv) {
NSAutoreleasePool pool = new NSAutoreleasePool();
UIApplication.main(argv, null, IOSLauncher.class);
pool.close();
}
}