import macros, os, random import ncurses when defined(Linux): proc positional_putch(x, y: int; ch: char) = mvaddch(x.cint, y.cint, ch.chtype) proc updateScreen = refresh() proc nonBlockingGetch(): char = let c = getch() result = if c in 0..255: char(c) else: '\0' proc closeScreen = endwin() else: error "Not implemented" const W = 80 H = 40 Space = 0 Food = 1 Border = 2 Symbol = [' ', '@', '.'] type Dir {.pure.} = enum North, East, South, West Game = object board: array[W * H, int] head: int dir: Dir quit: bool proc age(game: var Game) = ## Reduce a time-to-live, effectively erasing the tail. for i in 0..