diff --git a/.gitignore b/.gitignore index 40fbb28..cc2ff39 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,12 @@ +/target +/lib +/classes +/checkouts pom.xml -*jar -/lib/ -/classes/ -/targets/ +pom.xml.asc +*.jar +*.class .lein-deps-sum +.lein-failures +.lein-plugins +.lein-repl-history diff --git a/android/project.clj b/android/project.clj new file mode 100644 index 0000000..3295004 --- /dev/null +++ b/android/project.clj @@ -0,0 +1,6 @@ +(defproject play-clj-android "0.1.0-SNAPSHOT" + :description "Library for making Android games" + :license {:name "Public Domain" + :url "http://unlicense.org/UNLICENSE"} + :dependencies [[com.badlogicgames.gdx/gdx-backend-android "0.9.9"] + [play-clj "0.1.0-SNAPSHOT"]]) diff --git a/android/src/play_clj/android.clj b/android/src/play_clj/android.clj new file mode 100644 index 0000000..d29c76a --- /dev/null +++ b/android/src/play_clj/android.clj @@ -0,0 +1 @@ +(ns play-clj.android) diff --git a/common/project.clj b/common/project.clj new file mode 100644 index 0000000..7a8f44f --- /dev/null +++ b/common/project.clj @@ -0,0 +1,6 @@ +(defproject play-clj "0.1.0-SNAPSHOT" + :description "Library for making cross-platform games" + :license {:name "Public Domain" + :url "http://unlicense.org/UNLICENSE"} + :dependencies [[com.badlogicgames.gdx/gdx "0.9.9" :use-resources true] + [org.clojure/clojure "1.5.1"]]) diff --git a/common/src/play_clj/core.clj b/common/src/play_clj/core.clj new file mode 100644 index 0000000..1c23bdd --- /dev/null +++ b/common/src/play_clj/core.clj @@ -0,0 +1,36 @@ +(ns play-clj.core + (:import [com.badlogic.gdx Game Screen])) + +(defn set-screen! + [^Game game ^Screen screen] + (.setScreen game screen)) + +(defn defscreen* + [{:keys [on-show on-render on-dispose on-hide on-pause on-resize on-resume]}] + (let [total-time (atom 0) + on-show (or on-show (fn [])) + on-render (or on-render (fn [d t])) + on-dispose (or on-dispose (fn [])) + on-hide (or on-hide (fn [])) + on-pause (or on-pause (fn [])) + on-resize (or on-resize (fn [w h])) + on-resume (or on-resume (fn []))] + (proxy [Screen] [] + (show [] (on-show)) + (render [delta-time] + (swap! total-time + delta-time) + (on-render delta-time @total-time)) + (dispose [] (on-dispose)) + (hide [] (on-hide)) + (pause [] (on-pause)) + (resize [w h] (on-resize w h)) + (resume [] (on-resume))))) + +(defmacro defscreen + [name & {:keys [] :as options}] + `(def ~name (defscreen* ~options))) + +(defn create-game + [{:keys [start-screen]}] + (proxy [Game] [] + (create [] (when start-screen (set-screen! this start-screen))))) diff --git a/desktop/project.clj b/desktop/project.clj new file mode 100644 index 0000000..3c2bf3f --- /dev/null +++ b/desktop/project.clj @@ -0,0 +1,8 @@ +(defproject play-clj-desktop "0.1.0-SNAPSHOT" + :description "Library for making desktop games" + :license {:name "Public Domain" + :url "http://unlicense.org/UNLICENSE"} + :dependencies [[com.badlogicgames.gdx/gdx-backend-lwjgl "0.9.9"] + [com.badlogicgames.gdx/gdx-platform "0.9.9" + :classifier "natives-desktop"] + [play-clj "0.1.0-SNAPSHOT"]]) diff --git a/desktop/src/play_clj/desktop.clj b/desktop/src/play_clj/desktop.clj new file mode 100644 index 0000000..69aaa37 --- /dev/null +++ b/desktop/src/play_clj/desktop.clj @@ -0,0 +1,17 @@ +(ns play-clj.desktop + (:require [play-clj.core :refer :all]) + (:import [com.badlogic.gdx.backends.lwjgl LwjglApplication] + [org.lwjgl.input Keyboard])) + +(defmacro defgame + [name & {:keys [title width height] + :as options}] + (let [title (or title "") + width (or width 800) + height (or height 600)] + `(do + (def ~name (create-game ~options)) + (defn ~'-main + [] + (LwjglApplication. ~name ~title ~width ~height true) + (Keyboard/enableRepeatEvents true))))) diff --git a/ios/project.clj b/ios/project.clj new file mode 100644 index 0000000..cb00934 --- /dev/null +++ b/ios/project.clj @@ -0,0 +1,6 @@ +(defproject play-clj-ios "0.1.0-SNAPSHOT" + :description "Library for making iOS games" + :license {:name "Public Domain" + :url "http://unlicense.org/UNLICENSE"} + :dependencies [[com.badlogicgames.gdx/gdx-backend-robovm "0.9.9"] + [play-clj "0.1.0-SNAPSHOT"]]) diff --git a/ios/src/play_clj/ios.clj b/ios/src/play_clj/ios.clj new file mode 100644 index 0000000..74bac84 --- /dev/null +++ b/ios/src/play_clj/ios.clj @@ -0,0 +1 @@ +(ns play-clj.ios)