|
|
@ -5,35 +5,33 @@
|
|
|
|
[topdown2d.sprites :as sprites]))
|
|
|
|
[topdown2d.sprites :as sprites]))
|
|
|
|
|
|
|
|
|
|
|
|
(defn init [gamestate scenestate]
|
|
|
|
(defn init [gamestate scenestate]
|
|
|
|
(assoc
|
|
|
|
(merge
|
|
|
|
scenestate
|
|
|
|
scenestate
|
|
|
|
:player
|
|
|
|
{:player {:x (- (/ (get-in gamestate [:dimensions :w]) 2) 32)
|
|
|
|
{:x (- (/ (get-in gamestate [:dimensions :w]) 2) 32)
|
|
|
|
:y (- (/ (get-in gamestate [:dimensions :h]) 2) 32)
|
|
|
|
:y (- (/ (get-in gamestate [:dimensions :h]) 2) 32)
|
|
|
|
:w 64 :h 64
|
|
|
|
:w 64 :h 64
|
|
|
|
:d :s
|
|
|
|
:d :s
|
|
|
|
:sprite
|
|
|
|
:sprite
|
|
|
|
{:image (.getElementById js/document "demo-player")
|
|
|
|
{:image (.getElementById js/document "demo-player")
|
|
|
|
:size 64
|
|
|
|
:size 64
|
|
|
|
:rows {:w 1 :e 3
|
|
|
|
:rows {:w 1 :e 3
|
|
|
|
:n 0 :s 2
|
|
|
|
:n 0 :s 2
|
|
|
|
:? 2}
|
|
|
|
:? 2}
|
|
|
|
:cycle {:pos 0
|
|
|
|
:cycle {:pos 0
|
|
|
|
:from 1
|
|
|
|
:from 1
|
|
|
|
:count 8
|
|
|
|
:count 8
|
|
|
|
:last-cycle 0
|
|
|
|
:last-cycle 0
|
|
|
|
;; seconds per cycle
|
|
|
|
;; seconds per cycle
|
|
|
|
:spc 0.08}}}
|
|
|
|
:spc 0.08}}}
|
|
|
|
:viewport {:image (.getElementById js/document "demo-background")
|
|
|
|
:viewport
|
|
|
|
:keep-in {:x 0 :y 0
|
|
|
|
{:image (.getElementById js/document "demo-background")
|
|
|
|
:w 2239 :h 2235}
|
|
|
|
:keep-in {:x 0 :y 0
|
|
|
|
:x 1 :y 1
|
|
|
|
:w 2239 :h 2235}
|
|
|
|
:d :?
|
|
|
|
:x 1 :y 1
|
|
|
|
;; pixels per second
|
|
|
|
:d :?
|
|
|
|
:pps 350
|
|
|
|
;; pixels per second
|
|
|
|
:w (get-in gamestate [:dimensions :w])
|
|
|
|
:pps 350
|
|
|
|
:h (get-in gamestate [:dimensions :h])}}))
|
|
|
|
:w (get-in gamestate [:dimensions :w])
|
|
|
|
|
|
|
|
:h (get-in gamestate [:dimensions :h])}))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defn update-player [gamestate player dir]
|
|
|
|
(defn update-player [gamestate player dir]
|
|
|
|
(let [old-dir (:d player)
|
|
|
|
(let [old-dir (:d player)
|
|
|
@ -54,7 +52,7 @@
|
|
|
|
(let [player (:player scenestate)
|
|
|
|
(let [player (:player scenestate)
|
|
|
|
viewport (:viewport scenestate)
|
|
|
|
viewport (:viewport scenestate)
|
|
|
|
dir (get-in gamestate [:input :dir])]
|
|
|
|
dir (get-in gamestate [:input :dir])]
|
|
|
|
(assoc scenedata
|
|
|
|
(assoc scenestate
|
|
|
|
:player (update-player gamestate player dir)
|
|
|
|
:player (update-player gamestate player dir)
|
|
|
|
:viewport (update-viewport gamestate viewport dir))))
|
|
|
|
:viewport (update-viewport gamestate viewport dir))))
|
|
|
|
|
|
|
|
|
|
|
|