diff options
| author | Gene Pasquet <dev@etenil.net> | 2026-04-05 19:47:05 +0100 |
|---|---|---|
| committer | Gene Pasquet <dev@etenil.net> | 2026-04-05 19:47:05 +0100 |
| commit | 027053b11a3a5d861ed2fa2db245388bd95ac246 (patch) | |
| tree | 84dfd90642bb6d8eb4e0e3fa3a9d651ba29b41e8 /tilemap.scm | |
| parent | 927f37639a3d5a0d881a5c8709f2cf577aadb15e (diff) | |
Progress
Diffstat (limited to 'tilemap.scm')
| -rw-r--r-- | tilemap.scm | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/tilemap.scm b/tilemap.scm index 7e9e11c..8af70b9 100644 --- a/tilemap.scm +++ b/tilemap.scm @@ -74,6 +74,34 @@ (maybe-string->number (cdr pair)))) string-alist)) + (define (alist->tileset attrs) + (make-tileset + tilewidth: (alist-ref 'tilewidth attrs eq?) + tileheight: (alist-ref 'tileheight attrs eq?) + spacing: (alist-ref 'spacing attrs eq? 0) + tilecount: (alist-ref 'tilecount attrs eq?) + columns: (alist-ref 'columns attrs eq?) + image-source: "" + image: #f)) + + (define (alist->layer attrs) + (let ((symbol-attrs (string-alist->alist attrs))) + (make-layer + name: (alist-ref 'name symbol-attrs eq?) + width: (alist-ref 'width symbol-attrs eq?) + height: (alist-ref 'height symbol-attrs eq?) + map: '()))) + + (define (alist->object attrs) + (make-object + name: (alist-ref 'name attrs eq?) + type: (alist-ref 'type attrs eq?) + x: (alist-ref 'x attrs eq?) + y: (alist-ref 'y attrs eq?) + width: (alist-ref 'width attrs eq? 0) + height: (alist-ref 'height attrs eq? 0) + properties: '())) + (define (parse-tileset string-tileset) (let ((parser (expat:make-parser)) (tags '()) @@ -135,7 +163,8 @@ ("property" (object-properties-set! object - (cons (cons (alist-ref 'name symbol-attrs) (alist-ref 'value symbol-attrs)) + (cons (cons (string->symbol (alist-ref "name" attrs string=?)) + (alist-ref "value" attrs string=?)) (or (object-properties object) '())))) (_ #f)) (set! tags (cons tag tags))))) |
