feat: update render lib
This commit is contained in:
parent
6ff7eca031
commit
f26b274138
1 changed files with 39 additions and 21 deletions
60
game.scm
60
game.scm
|
@ -151,20 +151,6 @@
|
||||||
"Add task")))
|
"Add task")))
|
||||||
|
|
||||||
|
|
||||||
;; render ascii art
|
|
||||||
(define (template-ascii-art)
|
|
||||||
(define ink-script '(
|
|
||||||
"(\\ "
|
|
||||||
"\\'\\ "
|
|
||||||
" \\'\\ __________ "
|
|
||||||
" / '| ()_________) "
|
|
||||||
" \\ '/ \\ ~~~~~~~~ \\ "
|
|
||||||
" \\ \\ ~~~~~~ \\ "
|
|
||||||
" ==). \\__________\\ "
|
|
||||||
" (__) ()__________) "
|
|
||||||
))
|
|
||||||
`(pre ,(string-join ink-script "\n")))
|
|
||||||
|
|
||||||
;; Lib
|
;; Lib
|
||||||
(define (sub-string-list string-list start len func)
|
(define (sub-string-list string-list start len func)
|
||||||
(define (sub-string-list-iter string-list start len func part)
|
(define (sub-string-list-iter string-list start len func part)
|
||||||
|
@ -174,19 +160,19 @@
|
||||||
(if (= start 0 )
|
(if (= start 0 )
|
||||||
'()
|
'()
|
||||||
(list (substring (car string-list) 0 start)))
|
(list (substring (car string-list) 0 start)))
|
||||||
(list (func (substring (car string-list) start (+ start len))))
|
(list (func (substring (car string-list) start len)))
|
||||||
(if (= (+ start len) (string-length (car string-list)))
|
(if (= len (string-length (car string-list)))
|
||||||
'()
|
'()
|
||||||
(list (substring (car string-list) (+ start len) (string-length (car string-list)))))
|
(list (substring (car string-list) start (string-length (car string-list)))))
|
||||||
(cdr string-list))
|
(cdr string-list))
|
||||||
(sub-string-list-iter (cdr string-list)
|
(sub-string-list-iter (cdr string-list)
|
||||||
(- start (string-length (car string-list)))
|
(abs (- start (string-length (car string-list))))
|
||||||
len
|
(abs (- len (string-length (car string-list))))
|
||||||
func
|
func
|
||||||
(append part (list (car string-list)))))
|
(append part (list (car string-list)))))
|
||||||
(sub-string-list-iter (cdr string-list)
|
(sub-string-list-iter (cdr string-list)
|
||||||
(- start (string-length (car (last-pair (car string-list)))))
|
(- start (string-length (car (last-pair (car string-list)))))
|
||||||
len
|
(- len (string-length (car (last-pair (car string-list)))))
|
||||||
func
|
func
|
||||||
(append part (list (car string-list))))))
|
(append part (list (car string-list))))))
|
||||||
(sub-string-list-iter string-list start len func '()))
|
(sub-string-list-iter string-list start len func '()))
|
||||||
|
@ -205,7 +191,7 @@
|
||||||
(if (= 0 llen)
|
(if (= 0 llen)
|
||||||
part
|
part
|
||||||
(up-iter string-length
|
(up-iter string-length
|
||||||
x
|
(+ x xlen)
|
||||||
(+ 1 y)
|
(+ 1 y)
|
||||||
xlen
|
xlen
|
||||||
(- llen 1)
|
(- llen 1)
|
||||||
|
@ -216,6 +202,38 @@
|
||||||
))))))
|
))))))
|
||||||
(up-iter (+ 1 string-length) x y xlen ylen '()))
|
(up-iter (+ 1 string-length) x y xlen ylen '()))
|
||||||
|
|
||||||
|
(define (gen-string-list string-list update-list func)
|
||||||
|
(let loop ((string-list string-list)
|
||||||
|
(update-list update-list))
|
||||||
|
(if (equal? update-list '())
|
||||||
|
string-list
|
||||||
|
(loop (sub-string-list string-list
|
||||||
|
(car (car update-list))
|
||||||
|
(cadr (car update-list))
|
||||||
|
func)
|
||||||
|
(cdr update-list)))))
|
||||||
|
|
||||||
|
;; render ascii art
|
||||||
|
(define (template-ascii-art)
|
||||||
|
(define (blod string)
|
||||||
|
`(b ,string))
|
||||||
|
(define ink-script '(
|
||||||
|
"(\\ "
|
||||||
|
"\\'\\ "
|
||||||
|
" \\'\\ __________ "
|
||||||
|
" / '| ()_________) "
|
||||||
|
" \\ '/ \\ ~~~~~~~~ \\ "
|
||||||
|
" \\ \\ ~~~~~~ \\ "
|
||||||
|
" ==). \\__________\\ "
|
||||||
|
" (__) ()__________) "
|
||||||
|
))
|
||||||
|
(string-length (string-join ink-script "\n"))
|
||||||
|
`(pre ,@(gen-string-list (list (string-join ink-script "\n"))
|
||||||
|
(gen-update-list
|
||||||
|
(find-string-list-len (list (string-join ink-script "\n"))) 3 1 1 5)
|
||||||
|
blod)))
|
||||||
|
|
||||||
|
|
||||||
;; Main
|
;; Main
|
||||||
(set! *template* template-task)
|
(set! *template* template-task)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue