Repository navigation
Releases
0.5
Executable require JRE to run (download). Run executable with "java -jar path-to/roguehike.jar" command in console.
Fine-grained control over spawned terminal via second optional argument. Also some refactoring under the hood.
You can find minified version of roguehike 0.5 source code in "minification" branch. It's less than 3 kilobytes without sacrificing any functionality.
In fact, here it is:
(ns r.c(:require[lanterna.screen :as s][roul.random :as r][clojure.math :as m][clojure.edn :as e])(:gen-class))(def a ref-set)(def o str)(def t s/put-string)(def r{:fg :white :bg :black})(def s{:fg :black :bg :white})(def A range)(def J ref)(def K get-in)(def p #{\0\O\W\T\@\=})(def i 150)(def r(vec(for[_(A i)](vec(for[_(A i)](r/rand-nth-weighted[[\space i][\. 20][\, 15][\` 15][\* 40][\" 5][\o 5][\w 5][\t 5][\0 5][\O 5][\W 5][\T 5][\@ 5][\= 1]]))))))(def m(J 75))(def n(J 148))(def k(J@m))(def l(J@n))(def d(J 0))(def e(J 0))(def g(J"You're standing at foot of the mountain."))(def f(J 3))(def j(J 100))(def h(J 0))(def q(J 0))(def b(J nil))(defn B[](dosync(a k@m)(a d 0)(a l@n)(a e 0)))(defn c[C D](dosync(let[[x y](mapv +[@m@n]C)E(K r[(mod x i)(mod y i)])](if(and(p E)(= 0 D))(a g"Can't walk there, only clamber: path is obstructed.")(let[[F G](mapv +[@d@e]C)u(max 0(- 75(max 0(dec(m/round(m/sqrt(+(m/pow(- x 75)2)(m/pow(- y 75)2))))))))v(if(p E)6 1)z(if(= v 6)"clamber""walk")w(if(> u@f)(* v 3)(if(< u@f)(* v 2)v))](if(<@j w)(a g(o"You're too tired to "z". You need a rest."))(do(a m x)(a n y)(a d F)(a e G)(a f u)(a j(-@j w))(if(nil?(K r[x y]))(a g"You are about to leave wilderness. Press q to quit.")(if(<@f 75)(a g(o"You "z"."))(a g(o"You "z" on top of the mountain.")))))))))))(defn H[](dosync(let[z(dec@q)u(quot@h 2)v(quot z 2)x(-@h 2)y(- z 2)](when(>= 0(+ u@d))(a k(-@k x))(a d(+@d x)))(when(<=(dec@h)(+ u@d))(a k(+@k x))(a d(-@d x)))(when(>= 0(+ v@e))(a l(-@l y))(a e(+@e y)))(when(<=(dec z)(+ v@e))(a l(+@l y))(a e(-@e y)))(doseq[x(A@h)y(A z)](t@b x y(o(K r[(mod(+(-@k(quot@h 2))x)i)(mod(+(-@l(quot(dec@q)2))y)i)]))r))(t@b(+ u@d)(+ v@e)"i" r)(s/move-cursor@b(+ u@d)(+ v@e))(t@b 0 z(apply o(repeat@h" "))s)(t@b 0 z(format(o"NRG %3d | ALT %2d/%2d |%s%s%s| %s")@j@f 75(if(=@f 75)"T"(if(>@m 76)"<"" "))(if(=@f 75)"O"(if(<@n 74)"v"(if(>@n 76)"^"" ")))(if(=@f 75)"P"(if(<@m 74)">"" "))@g)s)))(s/redraw@b))(defn -main[& I](dosync(a b(s/get-screen(keyword(or(first I)(if(re-matches #"Windows.*"(System/getProperty"os.name"))"auto""unix")))(e/read-string(or(second I)"{}"))))(s/start@b)(s/add-resize-listener@b(fn[x y](dosync(a h x)(a q y))(B)(s/redraw@b)(H)))(let[[x y](s/get-size@b)](a h x)(a q y)))(loop[](H)(case(s/get-key-blocking@b)\q(do(s/stop@b)(dosync(a b nil)))\c(B)(\r\5)(let[z(if(=@f 75)" on top of the mountain""")](dosync(a j(min 100(+@j 5)))(if(=@j 100)(a g(o"You're fully rested"z"."))(a g(o"You rest for a while"z".")))))(\h\4)(c[-1 0]0)(:left\H)(c[-1 0]1)(\j\2)(c[0 1]0)(:down\J)(c[0 1]1)(\k\8)(c[0 -1]0)(:up\K)(c[0 -1]1)(\l\6)(c[1 0]0)(:right\L)(c[1 0]1)(\y\7)(c[-1 -1]0)(:home\Y)(c[-1 -1]1)(\u\9)(c[1 -1]0)(:page-up\U)(c[1 -1]1)(\b\1)(c[-1 1]0)(:end\B)(c[-1 1]1)(\n\3)(c[1 1]0)(:page-down\N)(c[1 1]1)nil)(if(some?@b)(recur))))