From c8de1a94ed00d8c6f304c2edb73e3a2419b0ce9b Mon Sep 17 00:00:00 2001 From: Ricardo Wurmus Date: Fri, 12 Jul 2019 23:07:32 +0200 Subject: Update to Chickadee 0.4.0. * characters/lorenzo.scm (default-shader): Remove. (lorenzo): Use #:tint instead of #:shader; hide shadow when dead. * engine/node-2d.scm (): Replace SHADER field with TINT. (draw ): Remove SHADER case. * engine/node.scm (run-node): Use RUN-GAME instead of RUN-GAME/SDL. * scenes/death.scm (ghost-shader): Remove. (populate): Use DEAD? keyword instead of SHADER. --- characters/lorenzo.scm | 66 +++++++++++++++----------------------------------- 1 file changed, 20 insertions(+), 46 deletions(-) (limited to 'characters') diff --git a/characters/lorenzo.scm b/characters/lorenzo.scm index 8a59e72..8c8971f 100644 --- a/characters/lorenzo.scm +++ b/characters/lorenzo.scm @@ -1,5 +1,5 @@ ;;; The Inevitable Game -;;; Copyright © 2018 Ricardo Wurmus +;;; Copyright © 2018, 2019 Ricardo Wurmus ;;; ;;; This program is free software: you can redistribute it and/or ;;; modify it under the terms of the GNU General Public License as @@ -18,7 +18,6 @@ (define-module (characters lorenzo) #:use-module (chickadee render texture) #:use-module (chickadee render color) - #:use-module (chickadee render shader) #:use-module (chickadee math rect) #:use-module (chickadee math vector) #:use-module (engine assets) @@ -40,34 +39,6 @@ player-atlas)) -;; Copied from (chickadee render sprite) -(define default-shader - (delay - (strings->shader - " -#version 130 - -in vec2 position; -in vec2 tex; -out vec2 frag_tex; -uniform mat4 mvp; - -void main(void) { - frag_tex = tex; - gl_Position = mvp * vec4(position.xy, 0.0, 1.0); -} -" - " -#version 130 - -in vec2 frag_tex; -uniform sampler2D color_texture; - -void main (void) { - gl_FragColor = texture2D(color_texture, frag_tex); -} -"))) - (define-class () (previous-key-presses #:accessor previous-key-presses #:init-form (list)) (selecting-message? #:accessor selecting-message? #:init-form #f) @@ -84,7 +55,7 @@ void main (void) { (define* (lorenzo #:key (position (vec2 0 0)) - (shader default-shader)) + (dead? #f)) (make #:name 'player #:position position @@ -93,7 +64,9 @@ void main (void) { (make #:name 'sprite #:atlas player-atlas - #:shader shader + #:tint (if dead? + (make-color 1.0 1.0 1.0 0.5) + (make-color 1.0 1.0 1.0 1.0)) #:animations '((idle-right . #(24 24 24 24 24 39 39 39 39 39)) (idle-left . #(32 32 32 32 32 31 31 31 31 31)) (idle-front . #(8 8 8 8 8 0 0 0 0 0)) @@ -104,17 +77,18 @@ void main (void) { (down . #(9 8 10 8))) #:current-animation 'idle-front #:frame-duration 10) - ;; Simple player shadow. This should better be done - ;; with a single ellipse shader. - (let ((color (make-color 0 0 0 0.2))) - (map (lambda (n x w) - (make - #:region (make-rect 0.0 0.0 w 1.0) - #:position (vec2 x (- 2 n)) - #:color color)) - ;; position in the stack - (iota 5) - ;; x offsets - (list 12 10 8 10 12) - ;; widths - (list 8 12 16 12 8)))))) + (if dead? '() + ;; Simple player shadow. This should better be done + ;; with a single ellipse shader. + (let ((color (make-color 0 0 0 0.2))) + (map (lambda (n x w) + (make + #:region (make-rect 0.0 0.0 w 1.0) + #:position (vec2 x (- 2 n)) + #:color color)) + ;; position in the stack + (iota 5) + ;; x offsets + (list 12 10 8 10 12) + ;; widths + (list 8 12 16 12 8))))))) -- cgit v1.2.3