Remove platform-specific defgame
This commit is contained in:
@@ -1,6 +1 @@
|
||||
(ns play-clj.native
|
||||
(:require [play-clj.core :refer :all]))
|
||||
|
||||
(defmacro defgame
|
||||
[name & {:keys [] :as options}]
|
||||
`(def ~name (create-game ~options)))
|
||||
(ns play-clj.native)
|
||||
|
||||
@@ -91,7 +91,11 @@
|
||||
[^Game game ^Screen screen]
|
||||
(.setScreen game screen))
|
||||
|
||||
(defn create-game
|
||||
(defn defgame*
|
||||
[{:keys [start-screen]}]
|
||||
(proxy [Game] []
|
||||
(create [] (when start-screen (set-screen! this start-screen)))))
|
||||
|
||||
(defmacro defgame
|
||||
[name & {:keys [] :as options}]
|
||||
`(def ~name (defgame* ~options)))
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
:width `(.getWidth (Gdx/graphics))
|
||||
:height `(.getHeight (Gdx/graphics))
|
||||
:is-fullscreen? `(.isFullscreen (Gdx/graphics))
|
||||
:is-touched? `(.isTouched (Gdx/input))
|
||||
:x `(.getX (Gdx/input))
|
||||
:y `(.getY (Gdx/input))
|
||||
nil))
|
||||
@@ -36,21 +37,6 @@
|
||||
nil)
|
||||
key))
|
||||
|
||||
(defn resolve-touch
|
||||
[key]
|
||||
(case key
|
||||
:down `(> (game :y) (* (game :height) (/ 2 3)))
|
||||
:up `(< (game :y) (/ (game :height) 3))
|
||||
:left `(< (game :x) (/ (game :width) 3))
|
||||
:right `(> (game :x) (* (game :width) (/ 2 3)))
|
||||
false))
|
||||
|
||||
(defmacro is-pressed?
|
||||
[key]
|
||||
`(.isKeyPressed (Gdx/input) ~(resolve-key key)))
|
||||
|
||||
(defmacro is-touched?
|
||||
([]
|
||||
`(.isTouched (Gdx/input)))
|
||||
([key]
|
||||
`(and (is-touched?) ~(resolve-touch key))))
|
||||
|
||||
@@ -1,17 +1 @@
|
||||
(ns play-clj.native
|
||||
(: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)))))
|
||||
(ns play-clj.native)
|
||||
|
||||
@@ -1,6 +1 @@
|
||||
(ns play-clj.native
|
||||
(:require [play-clj.core :refer :all]))
|
||||
|
||||
(defmacro defgame
|
||||
[name & {:keys [] :as options}]
|
||||
`(def ~name (create-game ~options)))
|
||||
(ns play-clj.native)
|
||||
|
||||
Reference in New Issue
Block a user