From bcb80ae2db3b9be68ea74b97c4c632b34ea64b5a Mon Sep 17 00:00:00 2001 From: = Date: Mon, 15 Sep 2014 22:01:00 -0700 Subject: [PATCH] fixing jumping. --- desktop/resources/cursor.png | Bin 2111 -> 2192 bytes desktop/src-common/advent/screens/scene.clj | 20 ++++---------------- desktop/src-common/advent/utils.clj | 19 ++++++++++++++++++- 3 files changed, 22 insertions(+), 17 deletions(-) diff --git a/desktop/resources/cursor.png b/desktop/resources/cursor.png index 7624436c08fc910e0bf0052070aaba0be742fc4e..a079a4ae5c763ae55305ca1b876396282443c12a 100644 GIT binary patch delta 1101 zcmV-T1hV_T5RehDQv`nmCrLy>RA>e5S21W5K@|NLEW}1dt6WlCBY`v$AqYWDch!RLCgf!_xK(Gk}#eiUQ#9$GdBLssIkQ8DQ2sSCaOQmQfHfFuI`Zj;(W_EV> zh$NT~%gp@w@6X@={`}h$IhOxA0|ou|#bPmNwOTQq-aqVf#P5HLG0XcMhJ17rLmKP} zGht~!Cgw1#5%<>CmN%5a!NE*Lo+lr`xB|&qfG$5iJz{7y8d9lL65qGSbhNOrAW1J^ z+H)QJd>`<n-pu@S_c>K~EQtzUBH`c$-6uKu~v zUzgYA!`@xlU7L&cd=ry+pS^ECDTzL8+I<&+Y4AR*EB=lG*xcNd;o;%v%(O*dBV6lV zzFLobniGGJkDCwjgEw!baP6uL^}LXCw?}1lsZYw)QJJds$y~iDtyQsh0T!+H%`TvI zNplpvPh9x`0X{7DwViI`BoH=f;(#56KHERrp~}}aV9&EV3V=>I!YPfZvyJ*20L0^A z+sDnnb8D180UdCV-~0FGgM8ln?Tw3V+b>}e4E2A^N_np-&+Xl>!>5aU6pBmIbdANu zMQc8gBP4cwd^~o6^jRPV7tH1ZczkyOpH(zJEC!noZO46Q0U%NMt+9a!Hb)W-J=;BR zKDz-v6wU7dbb#-l+8yA+Na&KcUX~wAfA4u282Kn;)#%o?yq$h0GX~L*hj=? zy7PaCn0oHJ zMqLD$<3a1kKL!3iZ+*p6eCM_{3o<@$|00e5SHDYKK@c7#Y0@OYRGt<#L9huHHWD#EuEKA`eROmb3}s?sBC5z!@&Sx5kk|tB*$K%J!`9Z8RIAm( z^A5U(*4Eaf=m4%he*b*8Yl$yS=EmD-G{pL2K(0RJ){G>^=+g#p?jQHc%s(5$R?FAehhEkN+Iw91NIpG1 zP09yw7-M5&!Zm$`W)eu86`QYOsbV?q`kEBCu?QWST(eS}`pyE}CXsER~AlHw%9N08~$G5r80k4sJf4$$jg! zk2oj-cWZQ7Za06)ohM6-Tju8f+~{wcALQWTg`DlIw)a8{m-vu=Xul|lA#B-wAAx1? zA*?U{t^(NK-b5W-?#>*+R50-;kT4(M^vX7<_6MWL<% zefsVy02<{Cqg1A>-!sS`{(JL5K5zc<-h<55*SrWO2Ule7q9JeW?$;HPk9-u0Z+9=gK9D0Mc41+m;{s`4AO;uAvH?8aUBJf<%@2Qz!Lp(CxbH0hBnsae3q)|gW^{n_ zldJ>WpUzG4*30H=86CbSOkWZBEa=YX>iCG$ddO8qZr%wj zTOk|77Znlwp@518{BY`vGMAkmGhI&Ci&EGi-2-HlVIp-Io6hp?UXrjF}~jA=S(lJ;V8j1_pqf*4Y4r1&R> zG3eQfp`!q_GS@U{fvJO;MWAIUh|473B0dzij@Mn|?7iS&uU8wr;@va3zk>zf0X&g! chan go thread take! alts!!]]) (:import [com.badlogic.gdx.graphics Pixmap Pixmap$Filter Texture Texture$TextureFilter] @@ -15,7 +16,6 @@ (def +screen-width+ 320) (def +screen-height+ 240) -(def +num-cursors+ 4) (defprotocol IMouseIn (mouse-in? [this location])) @@ -34,20 +34,8 @@ (actions/walk-to entities :ego [x y]))))) -(def +all-cursors+ [:main :touch :look :talk :right :down :left :up]) -(defn cursor [filename which] - (let [scale 2 - base-cursor (pixmap filename) - target-width (* 16 scale) - target-height (* 16 scale) - resized (Pixmap. target-width target-height (.getFormat base-cursor)) - index (.indexOf +all-cursors+ which)] - (Pixmap/setFilter Pixmap$Filter/NearestNeighbour) - (pixmap! resized :draw-pixmap base-cursor (* index 16) 0 16 16 - 0 0 target-width target-height) - resized )) (defn left-click [screen entities] (let [{:keys [x y]} (input->screen screen {:x (:input-x screen) :y (:input-y screen)}) @@ -111,7 +99,7 @@ :on-show (fn [screen entities] (update! screen :renderer (stage) :camera (orthographic)) - (let [_ (input! :set-cursor-image (cursor "cursor.png" :main) 0 0) + (let [_ (input! :set-cursor-image (utils/cursor "cursor.png" :main) 0 0) sheep-sheet (texture! (texture "outsidehouse/sheep-anim.png") :split 33 21) sheep (animation 0.15 (for [i (flatten [(repeat 10 0) 1 2 3 4 5 6 7 4 5 6 7 8 9 10 (repeat 25 11) (repeat 15 12)])] (aget sheep-sheet 0 i))) @@ -225,11 +213,11 @@ (let [{:keys [x y]} (input->screen screen {:x (:input-x screen) :y (:input-y screen)})] (if-let [mouse-override (first (filter #(mouse-in? % [x y]) (get-in entities [:background :mouse-overrides])))] (when (not (get-in entities [:cursor :override])) - (do (input! :set-cursor-image (cursor "cursor.png" (cursor-override mouse-override)) 0 0) + (do (input! :set-cursor-image (utils/cursor "cursor.png" (cursor-override mouse-override)) 0 0) (assoc-in entities [:cursor :override] mouse-override))) (when (get-in entities [:cursor :override]) - (do (input! :set-cursor-image (cursor "cursor.png" :main) 0 0) + (do (input! :set-cursor-image (utils/cursor "cursor.png" :main) 0 0) (assoc-in entities [:cursor :override] nil)))))) :on-touch-down (fn [screen [entities]] diff --git a/desktop/src-common/advent/utils.clj b/desktop/src-common/advent/utils.clj index 7419e10e..05baafd0 100644 --- a/desktop/src-common/advent/utils.clj +++ b/desktop/src-common/advent/utils.clj @@ -2,8 +2,25 @@ (:require [play-clj.core :refer :all] [play-clj.ui :refer :all] [play-clj.utils :refer :all] - [play-clj.g2d :refer :all])) + [play-clj.g2d :refer :all]) + (:import [com.badlogic.gdx.graphics Pixmap Pixmap$Filter Texture Texture$TextureFilter] + [com.badlogic.gdx.graphics.g2d TextureRegion] + [java.lang Object])) (defn log-coords [screen entities] (let [{:keys [x y]} (input->screen screen {:x (:input-x screen) :y (:input-y screen)})] (println (:input-x screen) (:input-y screen) "->" x y))) + +(def +all-cursors+ [:main :touch :look :talk :right :down :left :up]) + +(defn cursor [filename which] + (let [scale 2 + base-cursor (pixmap filename) + target-width (* 16 scale) + target-height (* 16 scale) + resized (Pixmap. target-width target-height (.getFormat base-cursor)) + index (.indexOf +all-cursors+ which)] + (Pixmap/setFilter Pixmap$Filter/NearestNeighbour) + (pixmap! resized :draw-pixmap base-cursor (* index 16) 0 16 16 + 0 0 target-width target-height) + resized ))