Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2017
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Erlang 0.61 KB | None | 0 0
  1. draw_world() ->
  2.     Q = qlc:q([X || X <- mnesia:table(world)]),
  3.     F = fun() -> qlc:eval(Q) end,
  4.     {atomic, World} = mnesia:transaction(F),
  5.     {WorldWidth, WorldHeight} = bounding_dimensions(World),
  6.     {DrawX, DrawY} = rogueunlike_util:centering_coords(WorldWidth, WorldHeight),
  7.     DrawF = fun(Spot) ->
  8.         Char = case Spot#world.stuff of
  9.             [walkable] -> ".";
  10.             [wall] -> "#";
  11.             _ -> "\s"
  12.         end,
  13.         {LocX, LocY} = Spot#world.loc,
  14.         cecho:mvaddstr(DrawY+LocY, DrawX+LocX, Char)
  15.     end,
  16.     lists:foreach(DrawF, World),
  17.     cecho:refresh(),
  18.     ok.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement