whee
This commit is contained in:
commit
0ee33720b7
6 changed files with 144 additions and 0 deletions
2
bin/rpg-main.clj
Normal file
2
bin/rpg-main.clj
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
(ns helloworld)
|
||||||
|
(defn hello [x] (str "Hello, " x "!"))
|
70
bin/rpg-slick.clj
Normal file
70
bin/rpg-slick.clj
Normal file
|
@ -0,0 +1,70 @@
|
||||||
|
(ns engine.core
|
||||||
|
(:use [utils.core :only (defnks)])
|
||||||
|
(:import
|
||||||
|
(org.newdawn.slick AppGameContainer BasicGame Sound Font Graphics GameContainer)))
|
||||||
|
|
||||||
|
;;
|
||||||
|
|
||||||
|
(def fns (atom nil)) ; public becuz used in macro -> wie handlen?
|
||||||
|
; swap! engine.core/fns und private? funzt net ... allgemeines makro problem ebenso bei defnks @ compile-time...
|
||||||
|
|
||||||
|
(defmacro initialize [& exprs]
|
||||||
|
`(swap! fns conj (fn [] ~@exprs)))
|
||||||
|
|
||||||
|
(defn init-all [] (doseq [f @fns] (f)))
|
||||||
|
|
||||||
|
;;
|
||||||
|
|
||||||
|
(defnks create-and-start-app-game-container
|
||||||
|
[:game :width :height :opt :show-fps :lock-framerate :full-screen]
|
||||||
|
(defn get-screen-width [] width)
|
||||||
|
(defn get-screen-height [] height)
|
||||||
|
(let [container (AppGameContainer. game width height (boolean full-screen))]
|
||||||
|
(.setShowFPS container (boolean show-fps))
|
||||||
|
(when lock-framerate
|
||||||
|
(doto container
|
||||||
|
(.setTargetFrameRate 60)
|
||||||
|
(.setVSync true)))
|
||||||
|
(def app-game-container container)
|
||||||
|
(.start (Thread.
|
||||||
|
#(.start container)))))
|
||||||
|
|
||||||
|
(defnks start-slick-basicgame
|
||||||
|
[:opt :full-screen
|
||||||
|
:opt-def :title "test" :width 800 :height 600 :init (fn [container]) :update (fn [container delta]) :render (fn [container g])]
|
||||||
|
(create-and-start-app-game-container
|
||||||
|
:game (proxy [BasicGame] [title]
|
||||||
|
(init [container]
|
||||||
|
(init-all) ; becuz of input needs to be initialized! useful for tests.
|
||||||
|
(init container))
|
||||||
|
(update [container delta]
|
||||||
|
(update container delta))
|
||||||
|
(render [container g]
|
||||||
|
(render container g)))
|
||||||
|
:width width
|
||||||
|
:height height
|
||||||
|
:full-screen full-screen))
|
||||||
|
|
||||||
|
;;
|
||||||
|
|
||||||
|
(defn resrc [path] (str "data/" path))
|
||||||
|
|
||||||
|
(defn create-sound [spath]
|
||||||
|
(Sound. (resrc (str "sounds/" spath))))
|
||||||
|
|
||||||
|
|
||||||
|
;;
|
||||||
|
|
||||||
|
(defn get-font []
|
||||||
|
(.getFont ^Graphics (.getGraphics ^GameContainer app-game-container)))
|
||||||
|
|
||||||
|
(defn get-text-width [text] (.getWidth ^Font (get-font) text))
|
||||||
|
|
||||||
|
(defn get-text-height [text] (.getHeight ^Font (get-font) text))
|
||||||
|
|
||||||
|
(defn get-line-height [] (.getLineHeight ^Font (get-font)))
|
||||||
|
|
||||||
|
;;
|
||||||
|
|
||||||
|
(defn set-mouse-cursor [data hotspotx hotspoty]
|
||||||
|
(.setMouseCursor app-game-container data hotspotx hotspoty))
|
BIN
clojure-src.jar
Normal file
BIN
clojure-src.jar
Normal file
Binary file not shown.
BIN
clojure.jar
Normal file
BIN
clojure.jar
Normal file
Binary file not shown.
2
src/rpg-main.clj
Normal file
2
src/rpg-main.clj
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
(ns helloworld)
|
||||||
|
(defn hello [x] (str "Hello, " x "!"))
|
70
src/rpg-slick.clj
Normal file
70
src/rpg-slick.clj
Normal file
|
@ -0,0 +1,70 @@
|
||||||
|
(ns engine.core
|
||||||
|
(:use [utils.core :only (defnks)])
|
||||||
|
(:import
|
||||||
|
(org.newdawn.slick AppGameContainer BasicGame Sound Font Graphics GameContainer)))
|
||||||
|
|
||||||
|
;;
|
||||||
|
|
||||||
|
(def fns (atom nil)) ; public becuz used in macro -> wie handlen?
|
||||||
|
; swap! engine.core/fns und private? funzt net ... allgemeines makro problem ebenso bei defnks @ compile-time...
|
||||||
|
|
||||||
|
(defmacro initialize [& exprs]
|
||||||
|
`(swap! fns conj (fn [] ~@exprs)))
|
||||||
|
|
||||||
|
(defn init-all [] (doseq [f @fns] (f)))
|
||||||
|
|
||||||
|
;;
|
||||||
|
|
||||||
|
(defnks create-and-start-app-game-container
|
||||||
|
[:game :width :height :opt :show-fps :lock-framerate :full-screen]
|
||||||
|
(defn get-screen-width [] width)
|
||||||
|
(defn get-screen-height [] height)
|
||||||
|
(let [container (AppGameContainer. game width height (boolean full-screen))]
|
||||||
|
(.setShowFPS container (boolean show-fps))
|
||||||
|
(when lock-framerate
|
||||||
|
(doto container
|
||||||
|
(.setTargetFrameRate 60)
|
||||||
|
(.setVSync true)))
|
||||||
|
(def app-game-container container)
|
||||||
|
(.start (Thread.
|
||||||
|
#(.start container)))))
|
||||||
|
|
||||||
|
(defnks start-slick-basicgame
|
||||||
|
[:opt :full-screen
|
||||||
|
:opt-def :title "test" :width 800 :height 600 :init (fn [container]) :update (fn [container delta]) :render (fn [container g])]
|
||||||
|
(create-and-start-app-game-container
|
||||||
|
:game (proxy [BasicGame] [title]
|
||||||
|
(init [container]
|
||||||
|
(init-all) ; becuz of input needs to be initialized! useful for tests.
|
||||||
|
(init container))
|
||||||
|
(update [container delta]
|
||||||
|
(update container delta))
|
||||||
|
(render [container g]
|
||||||
|
(render container g)))
|
||||||
|
:width width
|
||||||
|
:height height
|
||||||
|
:full-screen full-screen))
|
||||||
|
|
||||||
|
;;
|
||||||
|
|
||||||
|
(defn resrc [path] (str "data/" path))
|
||||||
|
|
||||||
|
(defn create-sound [spath]
|
||||||
|
(Sound. (resrc (str "sounds/" spath))))
|
||||||
|
|
||||||
|
|
||||||
|
;;
|
||||||
|
|
||||||
|
(defn get-font []
|
||||||
|
(.getFont ^Graphics (.getGraphics ^GameContainer app-game-container)))
|
||||||
|
|
||||||
|
(defn get-text-width [text] (.getWidth ^Font (get-font) text))
|
||||||
|
|
||||||
|
(defn get-text-height [text] (.getHeight ^Font (get-font) text))
|
||||||
|
|
||||||
|
(defn get-line-height [] (.getLineHeight ^Font (get-font)))
|
||||||
|
|
||||||
|
;;
|
||||||
|
|
||||||
|
(defn set-mouse-cursor [data hotspotx hotspoty]
|
||||||
|
(.setMouseCursor app-game-container data hotspotx hotspoty))
|
Loading…
Add table
Reference in a new issue