map.scm 2.04 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
    arr))

18
#;
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
(define game-map
  (parse-map
   '(
     "  #    #######****#**#**#"
     "###%####:::::::::::::::::"
     "::*   *::::::::::::::::::"
     "::*   *::::::::::::::::::"
     "::#   #::::::::::::::::::"
     "::*   *::::::::::::::::::"
     "::*   *::::::::::::::::::"
     "::#   #::::::::::::::::::"
     "::*   *::::::::::::::::::"
     "::*   *::::::::::::::::::"
     "::#   #::::::::::::::::::"
     "::*   *::::::::::::::::::"
     "::*   *::::::::::::::::::"
     "  #  ###**#*#**#**#**#**#"
     "  ## #####################")))
37 38


39 40
(define game-map
  (parse-map
41 42
   '(
     "  ######                 "
Filip Polbratt's avatar
Filip Polbratt committed
43
     "  #  % #                 "
44
     "  #  ####################"
Filip Polbratt's avatar
Filip Polbratt committed
45 46
     "  #    %                #"
     "  #    #############%#%##"
47
     "  #    #          #  #  #"
Filip Polbratt's avatar
Filip Polbratt committed
48
     "  #    %          #  #  #"
49
     "  #    #######****#**#**#"
Hugo Hörnquist's avatar
Hugo Hörnquist committed
50 51 52 53 54 55 56 57 58 59 60 61
     "###%####:::::::::::::::::"
     "::*   *::::::::::::::::::"
     "::*   *::::::::::::::::::"
     "::#   #::::::::::::::::::"
     "::*   *::::::::::::::::::"
     "::*   *::::::::::::::::::"
     "::#   #::::::::::::::::::"
     "::*   *::::::::::::::::::"
     "::*   *::::::::::::::::::"
     "::#   #::::::::::::::::::"
     "::*   *::::::::::::::::::"
     "::*   *::::::::::::::::::"
62
     "  #  ###**#*#**#**#**#**#"
Filip Polbratt's avatar
Filip Polbratt committed
63
     "  #  % #  # #  #  #  #  #"
64
     "  #  ###  # #  #  #  #  #"
Filip Polbratt's avatar
Filip Polbratt committed
65 66
     "  #  ####%#%##%##%#%##%##"
     "  #  %                   "
67
     "  ## #####################")))
68 69 70 71 72



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