Created
September 26, 2018 10:17
-
-
Save astynax/ff31fe1aee4787fd7456ffeb2816567f to your computer and use it in GitHub Desktop.
Small world that I made using Racket, 2htdp/planetcute (that uses "Planet Cute" tiles).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang racket | |
(require 2htdp/image) | |
(require 2htdp/planetcute) | |
(define world | |
'((" k" | |
"T r ," | |
",,, t,." | |
"... ,,.." | |
"... ...." | |
"...~....") | |
(" " | |
" T" | |
", g ," | |
" ,,w,,,." | |
"|..`...." | |
"...~....") | |
(" " | |
" " | |
" " | |
" t ,," | |
"!,, .." | |
",..~~~..") | |
(" " | |
" " | |
" * " | |
" , " | |
" ,. ," | |
",..~~~~.") | |
)) | |
(define empty-block | |
(rectangle 101 171 0 'white)) | |
(define shadow-block | |
(overlay/align | |
'left | |
'bottom | |
(rectangle 101 120 70 'black) | |
empty-block)) | |
(define (->tile c) | |
(case c | |
[(#\.) dirt-block] | |
[(#\,) grass-block] | |
[(#\~) water-block] | |
[(#\`) shadow-block] | |
[(#\w) wood-block] | |
[(#\t) tree-short] | |
[(#\T) tree-tall] | |
[(#\r) rock] | |
[(#\k) key] | |
[(#\*) yellow-star] | |
[(#\!) selector] | |
[(#\|) door-tall-closed] | |
[(#\g) character-cat-girl] | |
[else empty-block])) | |
(define (draw-row row) | |
(apply beside (map ->tile (string->list row)))) | |
(define (draw-layer rows) | |
(foldl (λ (r p) | |
(underlay/align/offset | |
'left 'bottom | |
(draw-row r) | |
0 -40 | |
p)) | |
(draw-row (first rows)) | |
(rest rows))) | |
(define (draw-world layers) | |
(foldl (λ (r p) | |
(overlay/align/offset | |
'left 'bottom | |
(draw-layer r) | |
0 -80 | |
p)) | |
(draw-layer (first layers)) | |
(rest layers))) | |
(draw-world world) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment