trimmed mobile.
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
(ns advent.pathfind
|
||||
(:require [play-clj.core :refer :all])
|
||||
(:require [play-clj.core :refer :all]
|
||||
[play-clj.utils :refer :all]
|
||||
[clojure.tools.logging :as log])
|
||||
(:import (java.lang Math)))
|
||||
|
||||
(def scale 2)
|
||||
@@ -120,18 +122,21 @@
|
||||
(println path)))
|
||||
|
||||
(defn map-from-resource [filename]
|
||||
(log/info "Loading collision from" filename)
|
||||
(let [pm (pixmap filename)
|
||||
black (color 0 0 0 255)
|
||||
painful (color 255 0 0 255)
|
||||
result (transient [])
|
||||
scale (long scale)
|
||||
height (long (pixmap! pm :get-height))]
|
||||
(doseq [^long x (range (/ (pixmap! pm :get-width) scale))
|
||||
^long y (range (/ height scale))
|
||||
:let [
|
||||
current-color (color (pixmap! pm :get-pixel (unchecked-multiply scale x) (unchecked-subtract height (unchecked-multiply scale y))))]]
|
||||
(conj! result (cond
|
||||
(color! current-color :equals black) 0
|
||||
(color! current-color :equals painful) 2
|
||||
:else 1)))
|
||||
(partition (/ (pixmap! pm :get-height) scale) (persistent! result) )))
|
||||
height (long (pixmap! pm :get-height))
|
||||
_ (doseq [^long x (range (/ (pixmap! pm :get-width) scale))
|
||||
^long y (range (/ height scale))
|
||||
:let [current-color (color (pixmap! pm :get-pixel (unchecked-multiply scale x) (unchecked-subtract height (unchecked-multiply scale y))))]]
|
||||
(conj! result (cond
|
||||
(color! current-color :equals black) 0
|
||||
(color! current-color :equals painful) 2
|
||||
:else 1)))
|
||||
result (partition (/ (pixmap! pm :get-height) scale) (persistent! result) )]
|
||||
(.unload *asset-manager* filename)
|
||||
(log/info "Finished loading collision from" filename)
|
||||
result))
|
||||
|
||||
Reference in New Issue
Block a user