fixing jumping.
This commit is contained in:
Binary file not shown.
|
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 2.1 KiB |
@@ -7,6 +7,7 @@
|
|||||||
[advent.pathfind]
|
[advent.pathfind]
|
||||||
[advent.actions :as actions]
|
[advent.actions :as actions]
|
||||||
[advent.zone :as zone]
|
[advent.zone :as zone]
|
||||||
|
[advent.utils :as utils]
|
||||||
[advent.screens.dialogue :refer [talking-screen]]
|
[advent.screens.dialogue :refer [talking-screen]]
|
||||||
[clojure.core.async :refer [put! <! <!! >! chan go thread take! alts!!]])
|
[clojure.core.async :refer [put! <! <!! >! chan go thread take! alts!!]])
|
||||||
(:import [com.badlogic.gdx.graphics Pixmap Pixmap$Filter Texture Texture$TextureFilter]
|
(:import [com.badlogic.gdx.graphics Pixmap Pixmap$Filter Texture Texture$TextureFilter]
|
||||||
@@ -15,7 +16,6 @@
|
|||||||
|
|
||||||
(def +screen-width+ 320)
|
(def +screen-width+ 320)
|
||||||
(def +screen-height+ 240)
|
(def +screen-height+ 240)
|
||||||
(def +num-cursors+ 4)
|
|
||||||
|
|
||||||
(defprotocol IMouseIn
|
(defprotocol IMouseIn
|
||||||
(mouse-in? [this location]))
|
(mouse-in? [this location]))
|
||||||
@@ -34,20 +34,8 @@
|
|||||||
(actions/walk-to entities :ego [x y])))))
|
(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]
|
(defn left-click [screen entities]
|
||||||
(let [{:keys [x y]} (input->screen screen {:x (:input-x screen) :y (:input-y screen)})
|
(let [{:keys [x y]} (input->screen screen {:x (:input-x screen) :y (:input-y screen)})
|
||||||
@@ -111,7 +99,7 @@
|
|||||||
:on-show
|
:on-show
|
||||||
(fn [screen entities]
|
(fn [screen entities]
|
||||||
(update! screen :renderer (stage) :camera (orthographic))
|
(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-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)])]
|
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)))
|
(aget sheep-sheet 0 i)))
|
||||||
@@ -225,11 +213,11 @@
|
|||||||
(let [{:keys [x y]} (input->screen screen {:x (:input-x screen) :y (:input-y screen)})]
|
(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])))]
|
(if-let [mouse-override (first (filter #(mouse-in? % [x y]) (get-in entities [:background :mouse-overrides])))]
|
||||||
(when (not (get-in entities [:cursor :override]))
|
(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)))
|
(assoc-in entities [:cursor :override] mouse-override)))
|
||||||
|
|
||||||
(when (get-in entities [:cursor :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))))))
|
(assoc-in entities [:cursor :override] nil))))))
|
||||||
|
|
||||||
:on-touch-down (fn [screen [entities]]
|
:on-touch-down (fn [screen [entities]]
|
||||||
|
|||||||
@@ -2,8 +2,25 @@
|
|||||||
(:require [play-clj.core :refer :all]
|
(:require [play-clj.core :refer :all]
|
||||||
[play-clj.ui :refer :all]
|
[play-clj.ui :refer :all]
|
||||||
[play-clj.utils :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]
|
(defn log-coords [screen entities]
|
||||||
(let [{:keys [x y]} (input->screen screen {:x (:input-x screen) :y (:input-y screen)})]
|
(let [{:keys [x y]} (input->screen screen {:x (:input-x screen) :y (:input-y screen)})]
|
||||||
(println (:input-x screen) (:input-y screen) "->" x y)))
|
(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 ))
|
||||||
|
|||||||
Reference in New Issue
Block a user