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