Files
gitea-docker/desktop/src-common/advent/utils.clj
2014-09-15 22:01:00 -07:00

27 lines
1.0 KiB
Clojure

(ns advent.utils
(:require [play-clj.core :refer :all]
[play-clj.ui :refer :all]
[play-clj.utils :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 ))