map.scm 1.52 KB
Newer Older
1 2 3
(define-module (map)
  :export (game-map board-height board-width))

4

5 6 7 8 9 10
(define (parse-map spec)
  (let ((arr (make-array #f (length spec) (string-length (car spec)))))
    (array-index-map! arr
                      (lambda (i j)
                        (case (string-ref (list-ref spec i) j)
                          ((#\space) 'space)
11 12 13
                          ((#\#) 'wall)
                          ((#\:) 'grass)
                          ((#\;) 'teleporter)
Hugo Hörnquist's avatar
Hugo Hörnquist committed
14
                          ((#\*) 'window)
Filip Polbratt's avatar
Filip Polbratt committed
15
                          ((#\%) 'entrance))))
16 17 18 19
    arr))

(define game-map
  (parse-map
20 21
   '(
     "  ######                 "
Filip Polbratt's avatar
Filip Polbratt committed
22
     "  #  % #                 "
23
     "  #  ####################"
Filip Polbratt's avatar
Filip Polbratt committed
24 25
     "  #    %                #"
     "  #    #############%#%##"
26
     "  #    #          #  #  #"
Filip Polbratt's avatar
Filip Polbratt committed
27
     "  #    %          #  #  #"
28
     "  #    #######****#**#**#"
Hugo Hörnquist's avatar
Hugo Hörnquist committed
29 30 31 32 33 34 35 36 37 38 39 40
     "###%####:::::::::::::::::"
     "::*   *::::::::::::::::::"
     "::*   *::::::::::::::::::"
     "::#   #::::::::::::::::::"
     "::*   *::::::::::::::::::"
     "::*   *::::::::::::::::::"
     "::#   #::::::::::::::::::"
     "::*   *::::::::::::::::::"
     "::*   *::::::::::::::::::"
     "::#   #::::::::::::::::::"
     "::*   *::::::::::::::::::"
     "::*   *::::::::::::::::::"
41
     "  #  ###**#*#**#**#**#**#"
Filip Polbratt's avatar
Filip Polbratt committed
42
     "  #  % #  # #  #  #  #  #"
43
     "  #  ###  # #  #  #  #  #"
Filip Polbratt's avatar
Filip Polbratt committed
44 45
     "  #  ####%#%##%##%#%##%##"
     "  #  %                   "
46
     "  ## #####################")))
47 48 49 50 51



(define-values (board-height board-width)
  (apply values (array-dimensions game-map)))