map.scm 1.78 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)
14 15
                          ((#\*) 'wall  #; 'window
                           )
Filip Polbratt's avatar
Filip Polbratt committed
16
                          ((#\%) 'entrance))))
17 18 19 20
    arr))

(define game-map
  (parse-map
21 22
   '(
     "  ######                 "
Filip Polbratt's avatar
Filip Polbratt committed
23
     "  #  % #                 "
24
     "  #  ####################"
Filip Polbratt's avatar
Filip Polbratt committed
25 26
     "  #    %                #"
     "  #    #############%#%##"
27
     "  #    #          #  #  #"
Filip Polbratt's avatar
Filip Polbratt committed
28
     "  #    %          #  #  #"
29
     "  #    #######****#**#**#"
Filip Polbratt's avatar
Filip Polbratt committed
30
     "###%%###:::::::::::::::::"
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
     "::*    *:::::::::::::::::"
     "::*    *:::::::::::::::::"
     "::*    *:::::::::::::::::"
     "::*    *:::::::::::::::::"
     "::*    *:::::::::::::::::"
     "::*    *:::::::::::::::::"
     "::*    *:::::::::::::::::"
     "::*    *:::::::::::::::::"
     "::*    *:::::::::::::::::"
     "::*    *:::::::::::::::::"
     "::*    *:::::::::::::::::"
     "::*    *:::::::::::::::::"
     "::*    *:::::::::::::::::"
     "::*    *:::::::::::::::::"
     "::*    *:::::::::::::::::"
     "::*    *:::::::::::::::::"
     "::*    *:::::::::::::::::"
     "::*    *:::::::::::::::::"
     "  #  ###**#*#**#**#**#**#"
Filip Polbratt's avatar
Filip Polbratt committed
50
     "  #  % #  # #  #  #  #  #"
51
     "  #  ###  # #  #  #  #  #"
Filip Polbratt's avatar
Filip Polbratt committed
52 53
     "  #  ####%#%##%##%#%##%##"
     "  #  %                   "
54
     "  ########################")))
55 56 57 58 59



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