repl jack-in.
This commit is contained in:
@@ -45,7 +45,7 @@
|
|||||||
|
|
||||||
(defn from-path [screen entities target-id [x y]]
|
(defn from-path [screen entities target-id [x y]]
|
||||||
(let [entity (target-id entities)
|
(let [entity (target-id entities)
|
||||||
path (vec (take-nth 4 (advent.pathfind/visit-all
|
path (vec (take-nth 5 (advent.pathfind/visit-all
|
||||||
(:collision (:background entities))
|
(:collision (:background entities))
|
||||||
[(int (:x entity)) (int (:y entity))]
|
[(int (:x entity)) (int (:y entity))]
|
||||||
[(int x) (int y)])))
|
[(int x) (int y)])))
|
||||||
|
|||||||
@@ -31,16 +31,16 @@
|
|||||||
|
|
||||||
|
|
||||||
(defn resolve-path [came-from play-loc target-loc]
|
(defn resolve-path [came-from play-loc target-loc]
|
||||||
(doto (if (nil? (came-from target-loc))
|
(if (nil? (came-from target-loc))
|
||||||
nil
|
nil
|
||||||
(loop [path []
|
(loop [path []
|
||||||
current-node target-loc]
|
current-node target-loc]
|
||||||
(if (or (= current-node play-loc)
|
(if (or (= current-node play-loc)
|
||||||
(nil? current-node))
|
(nil? current-node))
|
||||||
(reverse (map (fn [[x y]] [x y]) (conj path current-node)))
|
(reverse (map (fn [[x y]] [x y]) (conj path current-node)))
|
||||||
(recur
|
(recur
|
||||||
(conj path current-node)
|
(conj path current-node)
|
||||||
(came-from current-node))))) println))
|
(came-from current-node))))))
|
||||||
|
|
||||||
(defn heuristic [[goal-x goal-y] [current-x current-y]]
|
(defn heuristic [[goal-x goal-y] [current-x current-y]]
|
||||||
(let [dist-x (Math/abs (- goal-x current-x ))
|
(let [dist-x (Math/abs (- goal-x current-x ))
|
||||||
|
|||||||
@@ -1,10 +1,22 @@
|
|||||||
(ns advent.core.desktop-launcher
|
(ns advent.core.desktop-launcher
|
||||||
(:require [advent.core :refer :all])
|
(:require [advent.core :refer :all]
|
||||||
|
[clojure.tools.nrepl.server])
|
||||||
(:import [com.badlogic.gdx.backends.lwjgl LwjglApplication]
|
(:import [com.badlogic.gdx.backends.lwjgl LwjglApplication]
|
||||||
[org.lwjgl.input Keyboard])
|
[org.lwjgl.input Keyboard])
|
||||||
(:gen-class))
|
(:gen-class))
|
||||||
|
|
||||||
|
(defmacro start-nrepl-expr [port]
|
||||||
|
`(let [{port# :port} (clojure.tools.nrepl.server/start-server :port ~port)]
|
||||||
|
(doseq [port-file# ["target/repl-port" ".nrepl-port"]]
|
||||||
|
(-> port-file#
|
||||||
|
java.io.File.
|
||||||
|
(doto .deleteOnExit)
|
||||||
|
(spit port#)))
|
||||||
|
(println "Started nREPL server on port" port#)))
|
||||||
|
|
||||||
(defn -main
|
(defn -main
|
||||||
[]
|
[& [port]]
|
||||||
|
(when port (start-nrepl-expr (Integer/parseInt port)))
|
||||||
(LwjglApplication. advent "advent" 1280 960)
|
(LwjglApplication. advent "advent" 1280 960)
|
||||||
|
|
||||||
(Keyboard/enableRepeatEvents true))
|
(Keyboard/enableRepeatEvents true))
|
||||||
|
|||||||
Reference in New Issue
Block a user