map.scm 1.76 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 14 15
                          ((#\#) 'wall)
                          ((#\:) 'grass)
                          ((#\;) 'teleporter)
                          ((#\*) 'window)
                          ((#) 'entrance))))
16 17 18 19
    arr))

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



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