Reorganised resources, to differentiate between original and third party
This commit is contained in:
parent
cb28151712
commit
daa8e571f3
64 changed files with 119 additions and 70 deletions
|
|
@ -1,40 +0,0 @@
|
|||
OK, the basic idea is this
|
||||
|
||||
Everything (every game object, including the world) is a map.
|
||||
|
||||
Every object as an :id property; every :id property is distinct.
|
||||
|
||||
There is a master map - the `oblist` which contains every object, keyed by its :id.
|
||||
|
||||
Every object has a :run function, which returns either a new copy of itself or nil, and does not have side effects.
|
||||
|
||||
Every object has a :location function, which takes one argument, the object, and returns its location as a coordinate pair (or coordinate triple, probably) (this may involve fetching the location from the container in which it is contained, which implies that a contained object must hold a handle to its container).
|
||||
|
||||
Every collection of things in the world is represented as a list of :id values, by which the actual objects can be fetched from the `oblist`.
|
||||
|
||||
## Circles
|
||||
|
||||
Among those collections are the circles. The circles include, at minimum
|
||||
|
||||
1. Those objects in audible/visual range of the player; these have their run method invoked avery game loop. Weather, is always in this circle. The sun and moon are in this circle from shortly becore they rise to shortly after they set.
|
||||
2. Those objects which might come into audible/visual range within a short period; these have their run method invoked every N game loops, where N is probably variable depending on overall system load
|
||||
3. Those objects (actors) which are necessary to maintain the gossip system, etc. These should each have their run method invoked once per game day, but that is done by invoking the run method of a share of them each game loop.
|
||||
|
||||
So `run` takes three arguments - the object, the world and the circle; and returns nil if it makes no change, or a new copy of itself; and probably each of the main functions that run calls have the same behaviour. So, for example, a hierarchy of needs can be represented by
|
||||
|
||||
|
||||
(defn run [character world circle]
|
||||
(first
|
||||
(handle-immediate-threat character world circle) ;; if being attacked, deal with it
|
||||
(complete-current-action character world circle) ;; otherwise, continue the current
|
||||
;; short-term unless completed
|
||||
(handle-thirst character world circle) ;; perhaps adjust tactical plan to find water
|
||||
(handle-hunger character world circle) ;; perhaps adjust tactical plan to find food
|
||||
(handle-fatigue character world circle) ;; perhaps rest if safe to do so
|
||||
(advance-current-plan character world circle) ;; select next step of current strategic plan
|
||||
(select-next-plan character world circle) ;; plan new strategic objective
|
||||
(return-home character world circle))) ;; if no other strategic objective, return
|
||||
;; to home location
|
||||
|
||||
|
||||
Atoms? Background threads?
|
||||
|
|
@ -5,7 +5,7 @@
|
|||
defsimpleapp fly-cam get-height-map image
|
||||
image-based-height-map load-height-map
|
||||
load-texture material set* start
|
||||
terrain-lod-control terrain-quad]])
|
||||
terrain-lod-control terrain-quad]])
|
||||
(:import (com.jme3.texture Texture$WrapMode))
|
||||
(:gen-class))
|
||||
|
||||
|
|
@ -34,32 +34,36 @@
|
|||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(def cli-options
|
||||
;; An option with a required argument
|
||||
[["-p" "--port PORT" "Port number"
|
||||
:default 80
|
||||
:parse-fn #(Integer/parseInt %)
|
||||
:validate [#(< 0 % 0x10000) "Must be a number between 0 and 65536"]]
|
||||
;; A non-idempotent option (:default is applied first)
|
||||
["-v" nil "Verbosity level"
|
||||
"I haven't yet thought out what command line arguments (if any) I need.
|
||||
This is a placeholder."
|
||||
[["-v" nil "Verbosity level"
|
||||
:id :verbosity
|
||||
:default 0
|
||||
:update-fn inc] ; Prior to 0.4.1, you would have to use:
|
||||
;; :assoc-fn (fn [m k _] (update-in m [k] inc))
|
||||
;; A boolean option defaulting to nil
|
||||
:update-fn inc]
|
||||
["-h" "--help"]])
|
||||
|
||||
(defn init []
|
||||
(defn init
|
||||
"Again, placeholder. This initialises a bit of standard jMonkeyEngine
|
||||
terrain, just to check I have things wired up correctly."
|
||||
[]
|
||||
(set* (fly-cam) :move-speed 50)
|
||||
(let [grass (set* (load-texture "textures/terrain/splat/grass.jpg") :wrap Texture$WrapMode/Repeat)
|
||||
dirt (set* (load-texture "textures/terrain/splat/dirt.jpg") :wrap Texture$WrapMode/Repeat)
|
||||
rock (set* (load-texture "textures/terrain/splat/road.jpg") :wrap Texture$WrapMode/Repeat)
|
||||
mat (material "Common/MatDefs/Terrain/Terrain.j3md")
|
||||
height-map-tex (load-texture "textures/terrain/splat/mountains512.png")
|
||||
height-map (->> height-map-tex image image-based-height-map load-height-map)
|
||||
patch-size 65
|
||||
terrain (terrain-quad "my terrain" patch-size 513 (get-height-map height-map))]
|
||||
(let [grass (set* (load-texture "jme3/textures/terrain/splat/grass.jpg")
|
||||
:wrap Texture$WrapMode/Repeat)
|
||||
dirt (set* (load-texture "jme3/textures/terrain/splat/dirt.jpg")
|
||||
:wrap Texture$WrapMode/Repeat)
|
||||
rock (set* (load-texture "jme3/textures/terrain/splat/road.jpg")
|
||||
:wrap Texture$WrapMode/Repeat)
|
||||
mat (material "Common/MatDefs/Terrain/Terrain.j3md")
|
||||
height-map-tex (load-texture
|
||||
"jme3/textures/terrain/splat/mountains512.png")
|
||||
height-map (->> height-map-tex image image-based-height-map
|
||||
load-height-map)
|
||||
patch-size 65
|
||||
terrain (terrain-quad "my terrain" patch-size 513
|
||||
(get-height-map height-map))]
|
||||
(-> mat
|
||||
(set* :texture "Alpha" (load-texture "textures/terrain/splat/alphamap.png"))
|
||||
(set* :texture "Alpha"
|
||||
(load-texture "jme3/textures/terrain/splat/alphamap.png"))
|
||||
(set* :texture "Tex1" grass)
|
||||
(set* :float "Tex1Scale" (float 64))
|
||||
(set* :texture "Tex2" dirt)
|
||||
|
|
@ -73,15 +77,17 @@
|
|||
(add-to-root)
|
||||
(add-control (terrain-lod-control terrain (cam))))))
|
||||
|
||||
(defsimpleapp app :init init)
|
||||
(defsimpleapp game :init init)
|
||||
|
||||
(defn -main
|
||||
(defn -main
|
||||
"Launch the game."
|
||||
[& args]
|
||||
(parse-opts args cli-options)
|
||||
|
||||
;; this isn't working, not sure why not.
|
||||
;; (.setSettings app (app-settings false :dialog-image "images/splash.png"))
|
||||
(.setSettings game
|
||||
(app-settings false
|
||||
:dialog-image "original/images/splash.png"))
|
||||
|
||||
(start app))
|
||||
(start game))
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue