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