From 4f5676d3a5038ae2e6c140499db9d9125248c6d6 Mon Sep 17 00:00:00 2001 From: Amy Grinn Date: Wed, 15 Jan 2025 09:16:13 -0500 Subject: [PATCH] Added centering credit --- game.scm | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/game.scm b/game.scm index df2ef91..6e0cc23 100644 --- a/game.scm +++ b/game.scm @@ -462,7 +462,19 @@ (make-credit-text text) (make-credit-text (make-string (string-length text) #\-)))) -(define credits +(define (make-credit-centering total-lines credit) + (make-credit + #:lines total-lines + #:draw + (lambda (y) + (let* ((progress (/ (- credits-start y) (+ game-height + (* (line-height) total-lines)))) + (offset (* total-lines (line-height) + (/ (1+ (- (cos (* progress 3.14)))) 2)))) + ((credit-draw credit) (+ y offset)))) + #:update (lambda () ((credit-update credit))) + #:on-enter (lambda () ((credit-on-enter credit))) + #:on-leave (lambda () ((credit-on-leave credit))))) (define (make-credits) (vector (make-credit-group @@ -495,8 +507,8 @@ (make-credit-group (make-credit-underline "Other") (make-credit-text "monogram font by datagoblin")) - (make-credit #:lines 4) - (make-credit-text "Thank you for playing!"))) + (make-credit-centering + 10 (make-credit-text "Thank you for playing!")))) (define-record-type (make-credits-state credits top first-visible-index next-visible-index)