initial commit

This commit is contained in:
niten 2023-12-28 09:34:03 -08:00
commit b82539e481
5 changed files with 100 additions and 0 deletions

3
.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
.cpcache/
target/
.nrepl-port

36
build.clj Normal file
View File

@ -0,0 +1,36 @@
(ns build
(:require [clojure.tools.build.api :as b]))
(def lib 'org.fudo/ois)
(def version (format "0.1.%s" (b/git-count-revs nil)))
(def class-dir "target/classes")
(def basis (b/create-basis {:project "deps.edn"}))
(def jar-file (format "target/%s-%s.jar" (name lib) version))
(def uber-file (format "target/%s-%s-uber.jar" (name lib) version))
(defn clean [_]
(b/delete {:path "target"}))
(defn jar [_]
(b/write-pom {:class-dir class-dir
:lib lib
:version version
:basis basis
:src-dirs ["src"]})
(b/copy-dir {:src-dirs ["src" "resources"]
:target-dir class-dir})
(b/jar {:class-dir class-dir
:jar-file jar-file
:main 'ois.launcher}))
(defn uber [_]
(clean nil)
(b/copy-dir {:src-dirs ["src" "resources"]
:target-dir class-dir})
(b/compile-clj {:basis basis
:ns-compile '[ois.core]
:class-dir class-dir})
(b/uber {:class-dir class-dir
:uber-file uber-file
:basis basis
:main 'ois.launcher}))

19
deps.edn Normal file
View File

@ -0,0 +1,19 @@
{
:paths ["src"]
:deps {
com.badlogicgames.gdx/gdx { :mvn/version "1.11.0" }
com.badlogicgames.gdx/gdx-backend-lwjgl { :mvn/version "1.11.0" }
com.badlogicgames.gdx/gdx-box2d { :mvn/version "1.11.0" }
com.badlogicgames.gdx/gdx-box2d-platform$natives-desktop { :mvn/version "1.11.0" }
com.badlogicgames.gdx/gdx-bullet { :mvn/version "1.11.0" }
com.badlogicgames.gdx/gdx-bullet-platform$natives-desktop { :mvn/version "1.11.0" }
com.badlogicgames.gdx/gdx-platform$natives-desktop { :mvn/version "1.11.0" }
org.clojure/clojure { :mvn/version "1.7.0" }
}
:aliases {
:build {
:deps {io.github.clojure/tools.build { :mvn/version "0.9.6" }}
:ns-default build
}
}
}

33
src/ois/core.clj Normal file
View File

@ -0,0 +1,33 @@
(ns ois.core
(:import [com.badlogic.gdx Game Gdx Graphics Screen]
[com.badlogic.gdx.graphics Color GL20]
[com.badlogic.gdx.graphics.g2d BitmapFont]
[com.badlogic.gdx.scenes.scene2d Stage]
[com.badlogic.gdx.scenes.scene2d.ui Label Label$LabelStyle]))
(gen-class
:name demo.core.Game
:extends com.badlogic.gdx.Game)
(def main-screen
(let [stage (atom nil)]
(proxy [Screen] []
(show []
(reset! stage (Stage.))
(let [style (Label$LabelStyle. (BitmapFont.) (Color. 1 1 1 1))
label (Label. "Hello world!" style)]
(.addActor @stage label)))
(render [delta]
(.glClearColor (Gdx/gl) 0 0 0 0)
(.glClear (Gdx/gl) GL20/GL_COLOR_BUFFER_BIT)
(doto @stage
(.act delta)
(.draw)))
(dispose[])
(hide [])
(pause [])
(resize [w h])
(resume []))))
(defn -create [^Game this]
(.setScreen this main-screen))

9
src/ois/launcher.clj Normal file
View File

@ -0,0 +1,9 @@
(ns ois.launcher
(:require [demo.core :refer :all])
(:import [com.badlogic.gdx.backends.lwjgl LwjglApplication]
[org.lwjgl.input Keyboard])
(:gen-class))
(defn -main []
(LwjglApplication. (demo.core.Game.) "demo" 800 600)
(Keyboard/enableRepeatEvents true))