diff --git a/animation/0.png b/animation/0.png new file mode 100644 index 0000000..e67abc5 Binary files /dev/null and b/animation/0.png differ diff --git a/animation/1.png b/animation/1.png new file mode 100644 index 0000000..f069f76 Binary files /dev/null and b/animation/1.png differ diff --git a/animation/2.png b/animation/2.png new file mode 100644 index 0000000..72f5002 Binary files /dev/null and b/animation/2.png differ diff --git a/animation/3.png b/animation/3.png new file mode 100644 index 0000000..e5f602e Binary files /dev/null and b/animation/3.png differ diff --git a/animation/4.png b/animation/4.png new file mode 100644 index 0000000..b0c7ab4 Binary files /dev/null and b/animation/4.png differ diff --git a/animation/5.png b/animation/5.png new file mode 100644 index 0000000..c8ba429 Binary files /dev/null and b/animation/5.png differ diff --git a/animation/6.png b/animation/6.png new file mode 100644 index 0000000..dde6e1b Binary files /dev/null and b/animation/6.png differ diff --git a/animation/7.png b/animation/7.png new file mode 100644 index 0000000..19f6ed3 Binary files /dev/null and b/animation/7.png differ diff --git a/run.scm b/run.scm index e5d1604..3efcb9f 100644 --- a/run.scm +++ b/run.scm @@ -3,133 +3,35 @@ (sdl2 ttf) (ice-9 match) (srfi srfi-26) - (tsukundere menu button) - (tsukundere menu)) ; make-menu run-menu + (tsukundere animation)) (define (load) (let* ((scene - (make-scene '(background - text - menu))) + (make-scene '(background loaders))) (paper (load-image "paper.png")) - (texture (load-image "unchecked_box.png")) - (selected (load-image "checked_box.png")) - (radio (load-image "unselected_radio_button.png")) - (radio-selected (load-image "selected_radio_button.png")) - (simple (load-image "round_button_normal.png")) - (simple-hover (load-image "round_button_hover.png")) - (simple-pressed (load-image "round_button_mouse_down.png")) - (font (load-font "JuliaMono.ttf" 18)) - (colors - `((none . ,(make-color 80 225 100 255)) - (selected . ,(make-color 255 0 0 255)) - (pressed . ,(make-color 0 0 255 255)))) - (textures - `((none . ,texture) - (pressed . ,selected))) - (textures-radio - `((none . ,radio) - (pressed . ,radio-selected))) - (textures-button - `((none . ,simple) - (selected . ,simple-hover) - (pressed . ,simple-pressed))) - (checkbox-button - (make-button (s32vector 0 0) "" 0 font textures - #:dimensions (s32vector 25 25) - #:text-colors colors - #:anchor 'center - #:text-pos (s32vector 30 -7) - #:text-alignment '(left . top) - #:callback checkbox-button-callback)) - (checkbox-menu - (make-menu '() #:pos #s32(100 100) #:spacing #s32(0 50) - #:button-prototype checkbox-button - #:accumulator - (cute menu-fold <> '() cons))) - (radio-button - (make-button (s32vector 0 0) "" 0 font textures-radio - #:text-colors colors - #:dimensions (s32vector 200 20) - #:anchor 'top-left - #:text-alignment '(left . top) - #:text-pos (s32vector 30 0) - #:callback radio-button-callback)) - (radio-menu - (make-menu '() #:pos #s32(100 100) #:spacing #s32(0 50) - #:button-prototype radio-button)) - - (simple-button - (make-button (s32vector 0 0) "" 0 font textures-button - #:text-colors colors - ;; Put text at the center of the button - #:text-pos (s32vector 0 0) - #:anchor 'center - #:text-alignment '(center . center) - #:callback simple-button-callback)) - (simple-menu - (make-menu '() #:pos #s32(100 100) #:spacing #s32(0 50) - #:accumulator - (cute menu-fold <> *unspecified* (lambda (val seed) val)) - #:button-prototype simple-button)) - (nixo (make-speaker "nixo"))) + (frames (map + (compose load-image + (cute string-append + "animation/" <> ".png") + number->string) + (iota 8))) + (animation-looping + (make-animation (s32vector 100 100) frames 1000)) + (animation-boing + (make-animation (s32vector 100 200) frames 1000 #:loop 'rewind)) + (animation-stop + (make-animation (s32vector 200 100) frames 8000 #:loop #f)) + (animation-looping-slow + (make-animation (s32vector 200 200) frames 4000 #:loop #t))) + (map (cute scene-add-object! scene 'loaders <>) + (list animation-looping animation-boing + animation-stop animation-looping-slow)) (init-script! (lambda () (script - (begin - (background paper) - (nixo "This is not an exam!")) - (nixo "Choose one and press enter!") - (nixo - (format #f "You chose: ~a\n" - (run-menu - (make-menu '(("Select me!") - ("Or me!") - ("No, select me!")) - #:accumulator - (cute menu-fold <> *unspecified* (lambda (val seed) val)) - #:prototype radio-menu)))) - (nixo "Choose as many as you want!") - (nixo - (format #f "You chose ~a\n" - (run-menu - (make-menu '(("A" 0) - ("B" 1) - ("C" 2)) - #:accumulator (cute menu-fold <> '() cons) - #:prototype checkbox-menu)))) - (nixo "Choose as many as you want!") - (nixo - (format #f "You chose ~a\n" - (run-menu - (make-menu '(("A" 0 (pressed)) - ("B" 1 (selected)) - ("C" 2 (pressed))) - #:accumulator (cute menu-fold <> '() cons) - #:prototype checkbox-menu)))) - (nixo "Click it!") - (nixo - (format #f "You chose the element number: ~a\n" - (menu ("Yes" "Maybe" "No way")))) - (nixo "Click it again!") - (nixo - (format #f "You chose the element: ~a\n" - (menu (("Yes") ("Maybe") ("No way"))))) - ;; (nixo "Once more!" #f eol) - (nixo - (format #f "You chose the element: ~a\n" - (menu (("Yes" yep) ("Maybe" maybe) ("No way" nope))))) - *unspecified*)) - scene) - (init-menu! simple-menu) ; equal to - ;; (scene-add-object! scene 'menu simple-menu) - ;; roughly equivalent to init-menu! below - ;; (init-menu! #:pos #s32(100 100) #:spacing #s32(0 50) - ;; #:prototype simple-button - ;; #:accumulator (cute menu-fold <> *unspecified* - ;; (lambda (val seed) val)) - ;; #:scene scene) - (init-text! 10 300 280 font font #:scene scene))) + (background paper) + (pause))) + scene))) (run-game #:game-name ".tsukundere-example-buttons"