(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))