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