diff options
author | Ricardo Wurmus <rekado@elephly.net> | 2018-07-22 14:07:40 +0200 |
---|---|---|
committer | Ricardo Wurmus <rekado@elephly.net> | 2018-07-27 17:15:47 +0200 |
commit | 4cbf14f214dff7af40c0270699d5202b00bb0d2b (patch) | |
tree | 3788e39b2ce892bc9ddb8bf97556f1eb9b281cae /characters | |
parent | 9339716f26faea54d5ce5c5abe61534d11e1997f (diff) |
lorenzo: Accept shader and position keyword args.
Diffstat (limited to 'characters')
-rw-r--r-- | characters/lorenzo.scm | 40 |
1 files changed, 37 insertions, 3 deletions
diff --git a/characters/lorenzo.scm b/characters/lorenzo.scm index 5fa2268..7117c4e 100644 --- a/characters/lorenzo.scm +++ b/characters/lorenzo.scm @@ -18,6 +18,7 @@ (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) @@ -35,7 +36,37 @@ music talking? - lorenzo)) + lorenzo + + 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 <player> (<character>) (previous-key-presses #:accessor previous-key-presses #:init-form (list)) @@ -51,15 +82,18 @@ (define-asset player-atlas (load-atlas "assets/images/lorenzo.png" 32 32)) -(define (lorenzo the-position) +(define* (lorenzo #:key + (position (vec2 0 0)) + (shader default-shader)) (make <player> #:name 'player - #:position the-position + #:position position #:children (cons (make <animated-sprite> #:name 'sprite #:atlas player-atlas + #:shader shader #:animations '((idle-right . #(8 8 8 8 8 7 7 7 7 7)) (idle-left . #(0 0 0 0 0 15 15 15 15 15)) (idle-front . #(24 24 24 24 24 32 32 32 32 32)) |