Move step! to the physics namespace where it belonds
This commit is contained in:
@@ -1,7 +1,5 @@
|
|||||||
(ns play-clj.core
|
(ns play-clj.core
|
||||||
(:require [clojure.set :as set]
|
(:require [play-clj.utils :as u])
|
||||||
[play-clj.g2d-physics :as g2dp]
|
|
||||||
[play-clj.utils :as u])
|
|
||||||
(:import [com.badlogic.gdx Application Audio Files Game Gdx Graphics Input
|
(:import [com.badlogic.gdx Application Audio Files Game Gdx Graphics Input
|
||||||
InputMultiplexer InputProcessor Net Screen]
|
InputMultiplexer InputProcessor Net Screen]
|
||||||
[com.badlogic.gdx.graphics Camera Color GL20 OrthographicCamera
|
[com.badlogic.gdx.graphics Camera Color GL20 OrthographicCamera
|
||||||
|
|||||||
@@ -234,25 +234,6 @@
|
|||||||
(render! screen)
|
(render! screen)
|
||||||
(draw! screen entities)))
|
(draw! screen entities)))
|
||||||
|
|
||||||
; physics
|
|
||||||
|
|
||||||
(defn step!
|
|
||||||
([{:keys [world time-step velocity-iterations position-iterations]
|
|
||||||
:or {time-step (/ 1 60) velocity-iterations 10 position-iterations 10}}]
|
|
||||||
(assert world)
|
|
||||||
(cond
|
|
||||||
(isa? (type world) World)
|
|
||||||
(.step ^World world time-step velocity-iterations position-iterations)))
|
|
||||||
([screen entities]
|
|
||||||
(step! screen)
|
|
||||||
(map (fn [entity]
|
|
||||||
(if-let [body (:body entity)]
|
|
||||||
(assoc entity
|
|
||||||
:x (g2dp/body-x body)
|
|
||||||
:y (g2dp/body-y body))
|
|
||||||
entity))
|
|
||||||
entities)))
|
|
||||||
|
|
||||||
; cameras
|
; cameras
|
||||||
|
|
||||||
(defn orthographic*
|
(defn orthographic*
|
||||||
|
|||||||
@@ -164,7 +164,7 @@
|
|||||||
[object k & options]
|
[object k & options]
|
||||||
`(u/call! ^PolygonShape ~object ~k ~@options))
|
`(u/call! ^PolygonShape ~object ~k ~@options))
|
||||||
|
|
||||||
; misc functions
|
; misc
|
||||||
|
|
||||||
(defmacro contact!
|
(defmacro contact!
|
||||||
[object k & options]
|
[object k & options]
|
||||||
@@ -193,3 +193,20 @@
|
|||||||
(-> contact .getFixtureB .getBody)))
|
(-> contact .getFixtureB .getBody)))
|
||||||
([screen entities]
|
([screen entities]
|
||||||
(find-body (second-contact screen) entities)))
|
(find-body (second-contact screen) entities)))
|
||||||
|
|
||||||
|
(defn step!
|
||||||
|
([{:keys [world time-step velocity-iterations position-iterations]
|
||||||
|
:or {time-step (/ 1 60) velocity-iterations 10 position-iterations 10}}]
|
||||||
|
(assert world)
|
||||||
|
(cond
|
||||||
|
(isa? (type world) World)
|
||||||
|
(.step ^World world time-step velocity-iterations position-iterations)))
|
||||||
|
([screen entities]
|
||||||
|
(step! screen)
|
||||||
|
(map (fn [entity]
|
||||||
|
(if-let [body (:body entity)]
|
||||||
|
(assoc entity
|
||||||
|
:x (body-x body)
|
||||||
|
:y (body-y body))
|
||||||
|
entity))
|
||||||
|
entities)))
|
||||||
|
|||||||
Reference in New Issue
Block a user