From 027053b11a3a5d861ed2fa2db245388bd95ac246 Mon Sep 17 00:00:00 2001 From: Gene Pasquet Date: Sun, 5 Apr 2026 19:47:05 +0100 Subject: Progress --- tilemap.scm | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) (limited to 'tilemap.scm') 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))))) -- cgit v1.2.3