001 (ns cc.journeyman.the-great-game.playroom
002 (:require [jme-clj.core :refer [add add-to-root box defsimpleapp fly-cam geo
003 get* get-state load-texture rotate run set*
004 setc set-state start unshaded-mat]])
005 (:import [com.jme3.math ColorRGBA]))
006
007 ;; At present this file is just somewhere to play around with jme-clj examples
008
009 (declare app)
010
011 (defn init []
012 (let [cube (geo "jMonkey cube" (box 1 1 1))
013 mat (unshaded-mat)]
014 (set* mat :texture "ColorMap" (load-texture "textures/Monkey.jpg"))
015 (set* cube :material mat)
016 (add-to-root cube)
017 {:cube cube}))
018
019 ;; Let's create simple-update fn with no body for now.
020 (defn simple-update [tpf]
021 (let [{:keys [cube]} (get-state)]
022 (rotate cube 0 (* 2 tpf) 0)))
023
024
025 ;; Kills the running app var and closes its window.
026 ;; (unbind-app #'app)
027
028 ;; We define the `app` var.
029 (defsimpleapp app
030 :opts {:show-settings? false
031 :pause-on-lost-focus? false
032 :settings {:title "My JME Game"
033 :load-defaults? true
034 :frame-rate 60
035 :width 800
036 :height 600}}
037 :init init
038 :update simple-update)
039
040 ;; (start app)
041
042 ;; Reinitialises the running app
043 ;;(run app
044 ;; (re-init init))
045
046 ;; By default, there is a Fly Camera attached to the app that you can control with W, A, S and D keys.
047 ;; Let's increase its movement speed. Now, you fly faster :)
048 ;; (run app
049 ;; (set* (fly-cam) :move-speed 15))
050
051
052 ;; Updates the app
053 ;; (run app
054 ;; (let [{:keys [cube]} (get-state)]
055 ;; (set* cube :local-translation (add (get* cube :local-translation) 1 1 1))))
056
057 ;; Updates the app adding a second cube
058 ;; (run app
059 ;; (let [cube (geo "jMonkey cube" (box 1 1 1))
060 ;; mat (unshaded-mat)]
061 ;; (set* mat :texture "ColorMap" (load-texture "textures/Monkey.jpg"))
062 ;; (setc cube
063 ;; :material mat
064 ;; :local-translation [-3 0 0])
065 ;; (add-to-root cube)
066 ;; (set-state :cube2 cube)))
067
068 ;; We added the new cube, but it's not rotating. We need to update the simple-update fn.
069 ;; (defn simple-update [tpf]
070 ;; (let [{:keys [cube cube2]} (get-state)]
071 ;; (rotate cube 0 (* 2 tpf) 0)
072 ;; (rotate cube2 0 (* 2 tpf) 0)))