├── .gitignore ├── README.md ├── example.png ├── game.project ├── input └── game.input_binding └── main ├── assets ├── font │ ├── PrStart.ttf │ ├── bitmapfont.material │ ├── main.font │ └── prstartk.ttf ├── quad.dae └── quad.model ├── images ├── dialog9.png ├── main.atlas ├── stencil.atlas ├── stencil.psd ├── stencil_circle.png ├── stencil_circle_2.png ├── stencil_diagonal.png ├── stencil_stripe_diagonal.png ├── tiles.png ├── tiles.pyxel └── tiles.tilesource ├── main.collection ├── main.gui ├── main.gui_script ├── main.tilemap ├── render ├── custom.render ├── custom.render_script ├── screenfade.fp ├── screenfade.material └── screenfade.vp └── screenfade.script /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | .externalToolBuilders 3 | .DS_Store 4 | .lock-wscript 5 | build 6 | *.pyc 7 | .project 8 | .cproject 9 | builtins 10 | .internal 11 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | A small example on how to use a stencil mask to do a screen fade 2 | 3 | ![Example screen](./example.png) 4 | 5 | 6 | * Credits 7 | 8 | Font: [Press Start](http://www.dafont.com/press-start.font) by Cody Boisclair 9 | 10 | 11 | -------------------------------------------------------------------------------- /example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JCash/stencilfade/218fa044cc8bb4816969cc9db7687a95c9efe42f/example.png -------------------------------------------------------------------------------- /game.project: -------------------------------------------------------------------------------- 1 | [project] 2 | title = Screenfade 3 | version = 0.1 4 | 5 | [bootstrap] 6 | main_collection = /main/main.collectionc 7 | render = /main/render/custom.renderc 8 | 9 | [input] 10 | game_binding = /input/game.input_bindingc 11 | 12 | [display] 13 | width = 800 14 | height = 600 15 | 16 | [physics] 17 | scale = 0.02 18 | 19 | [script] 20 | shared_state = 1 21 | 22 | [graphics] 23 | default_texture_min_filter = nearest 24 | default_texture_mag_filter = nearest 25 | 26 | -------------------------------------------------------------------------------- /input/game.input_binding: -------------------------------------------------------------------------------- 1 | key_trigger { 2 | input: KEY_LEFT 3 | action: "key_left" 4 | } 5 | key_trigger { 6 | input: KEY_RIGHT 7 | action: "key_right" 8 | } 9 | key_trigger { 10 | input: KEY_UP 11 | action: "key_up" 12 | } 13 | key_trigger { 14 | input: KEY_DOWN 15 | action: "key_down" 16 | } -------------------------------------------------------------------------------- /main/assets/font/PrStart.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JCash/stencilfade/218fa044cc8bb4816969cc9db7687a95c9efe42f/main/assets/font/PrStart.ttf -------------------------------------------------------------------------------- /main/assets/font/bitmapfont.material: -------------------------------------------------------------------------------- 1 | name: "bitmapfont" 2 | tags: "gui" 3 | vertex_program: "/builtins/fonts/font.vp" 4 | fragment_program: "/builtins/fonts/font.fp" 5 | vertex_constants { 6 | name: "view_proj" 7 | type: CONSTANT_TYPE_VIEWPROJ 8 | } 9 | vertex_constants { 10 | name: "world" 11 | type: CONSTANT_TYPE_WORLD 12 | } 13 | samplers { 14 | name: "texture" 15 | wrap_u: WRAP_MODE_REPEAT 16 | wrap_v: WRAP_MODE_REPEAT 17 | filter_min: FILTER_MODE_MIN_NEAREST 18 | filter_mag: FILTER_MODE_MAG_NEAREST 19 | } 20 | -------------------------------------------------------------------------------- /main/assets/font/main.font: -------------------------------------------------------------------------------- 1 | font: "/main/assets/font/prstartk.ttf" 2 | material: "/main/assets/font/bitmapfont.material" 3 | size: 16 4 | antialias: 0 5 | -------------------------------------------------------------------------------- /main/assets/font/prstartk.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JCash/stencilfade/218fa044cc8bb4816969cc9db7687a95c9efe42f/main/assets/font/prstartk.ttf -------------------------------------------------------------------------------- /main/assets/quad.dae: -------------------------------------------------------------------------------- 1 | 2 | 3 | FBX COLLADA exporter2012-10-10T12:34:45Z2012-10-10T12:34:45ZY_UP 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 0.000000 0.000000 0.000000 1.000000 16 | 17 | 18 | 0.000000 0.000000 0.000000 1.000000 19 | 20 | 21 | 0.400000 0.400000 0.400000 1.000000 22 | 23 | 24 | 0.000000 0.000000 0.000000 1.000000 25 | 26 | 27 | 1.000000 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | -1.000000 -1.000000 0.000000 40 | 1.000000 -1.000000 0.000000 41 | -1.000000 1.000000 0.000000 42 | 1.000000 1.000000 0.000000 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 0.000000 0.000000 1.000000 55 | 0.000000 0.000000 1.000000 56 | 0.000000 0.000000 1.000000 57 | 0.000000 0.000000 1.000000 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 0.000000 1.000000 70 | 1.000000 1.000000 71 | 0.000000 0.000000 72 | 1.000000 0.000000 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 |

3 3 2 2 0 0 3 3 0 0 1 1

86 |
87 |
88 |
89 | 90 | 91 | 1.000000 0.000000 0.000000 0.000000 0.000000 1.000000 0.000000 0.000000 0.000000 0.000000 1.000000 0.000000 0.000000 0.000000 0.000000 1.0000001.000000 92 | 24.0000000.0416672.000000 93 | 94 | 95 | 96 | 97 | 98 |
-------------------------------------------------------------------------------- /main/assets/quad.model: -------------------------------------------------------------------------------- 1 | mesh: "/main/assets/quad.dae" 2 | skeleton: "" 3 | animations: "" 4 | default_animation: "" 5 | name: "quad" 6 | materials { 7 | name: "default" 8 | material: "/main/render/screenfade.material" 9 | textures { 10 | sampler: "DIFFUSE_TEXTURE" 11 | texture: "/builtins/graphics/particle_blob.png" 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /main/images/dialog9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JCash/stencilfade/218fa044cc8bb4816969cc9db7687a95c9efe42f/main/images/dialog9.png -------------------------------------------------------------------------------- /main/images/main.atlas: -------------------------------------------------------------------------------- 1 | images { 2 | image: "/main/images/dialog9.png" 3 | } 4 | margin: 0 5 | extrude_borders: 0 6 | inner_padding: 0 7 | -------------------------------------------------------------------------------- /main/images/stencil.atlas: -------------------------------------------------------------------------------- 1 | images { 2 | image: "/main/images/stencil_diagonal.png" 3 | } 4 | images { 5 | image: "/main/images/stencil_circle.png" 6 | } 7 | images { 8 | image: "/main/images/stencil_circle_2.png" 9 | } 10 | images { 11 | image: "/main/images/stencil_stripe_diagonal.png" 12 | } 13 | margin: 0 14 | extrude_borders: 0 15 | inner_padding: 0 16 | -------------------------------------------------------------------------------- /main/images/stencil.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JCash/stencilfade/218fa044cc8bb4816969cc9db7687a95c9efe42f/main/images/stencil.psd -------------------------------------------------------------------------------- /main/images/stencil_circle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JCash/stencilfade/218fa044cc8bb4816969cc9db7687a95c9efe42f/main/images/stencil_circle.png -------------------------------------------------------------------------------- /main/images/stencil_circle_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JCash/stencilfade/218fa044cc8bb4816969cc9db7687a95c9efe42f/main/images/stencil_circle_2.png -------------------------------------------------------------------------------- /main/images/stencil_diagonal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JCash/stencilfade/218fa044cc8bb4816969cc9db7687a95c9efe42f/main/images/stencil_diagonal.png -------------------------------------------------------------------------------- /main/images/stencil_stripe_diagonal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JCash/stencilfade/218fa044cc8bb4816969cc9db7687a95c9efe42f/main/images/stencil_stripe_diagonal.png -------------------------------------------------------------------------------- /main/images/tiles.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JCash/stencilfade/218fa044cc8bb4816969cc9db7687a95c9efe42f/main/images/tiles.png -------------------------------------------------------------------------------- /main/images/tiles.pyxel: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JCash/stencilfade/218fa044cc8bb4816969cc9db7687a95c9efe42f/main/images/tiles.pyxel -------------------------------------------------------------------------------- /main/images/tiles.tilesource: -------------------------------------------------------------------------------- 1 | image: "/main/images/tiles.png" 2 | tile_width: 32 3 | tile_height: 32 4 | tile_margin: 0 5 | tile_spacing: 0 6 | collision: "" 7 | material_tag: "tile" 8 | collision_groups: "default" 9 | animations { 10 | id: "anim" 11 | start_tile: 1 12 | end_tile: 1 13 | playback: PLAYBACK_ONCE_FORWARD 14 | fps: 30 15 | flip_horizontal: 0 16 | flip_vertical: 0 17 | } 18 | extrude_borders: 0 19 | inner_padding: 0 20 | -------------------------------------------------------------------------------- /main/main.collection: -------------------------------------------------------------------------------- 1 | name: "main" 2 | scale_along_z: 0 3 | embedded_instances { 4 | id: "main" 5 | data: "components {\n" 6 | " id: \"gui\"\n" 7 | " component: \"/main/main.gui\"\n" 8 | " position {\n" 9 | " x: 0.0\n" 10 | " y: 0.0\n" 11 | " z: 0.0\n" 12 | " }\n" 13 | " rotation {\n" 14 | " x: 0.0\n" 15 | " y: 0.0\n" 16 | " z: 0.0\n" 17 | " w: 1.0\n" 18 | " }\n" 19 | " property_decls {\n" 20 | " }\n" 21 | "}\n" 22 | "" 23 | position { 24 | x: 206.91264 25 | y: 167.22813 26 | z: 0.4 27 | } 28 | rotation { 29 | x: 0.0 30 | y: 0.0 31 | z: 0.0 32 | w: 1.0 33 | } 34 | scale3 { 35 | x: 1.0 36 | y: 1.0 37 | z: 1.0 38 | } 39 | } 40 | embedded_instances { 41 | id: "screenfade" 42 | data: "components {\n" 43 | " id: \"script\"\n" 44 | " component: \"/main/screenfade.script\"\n" 45 | " position {\n" 46 | " x: 0.0\n" 47 | " y: 0.0\n" 48 | " z: 0.0\n" 49 | " }\n" 50 | " rotation {\n" 51 | " x: 0.0\n" 52 | " y: 0.0\n" 53 | " z: 0.0\n" 54 | " w: 1.0\n" 55 | " }\n" 56 | " property_decls {\n" 57 | " }\n" 58 | "}\n" 59 | "embedded_components {\n" 60 | " id: \"circle\"\n" 61 | " type: \"model\"\n" 62 | " data: \"mesh: \\\"/main/assets/quad.dae\\\"\\n" 63 | "skeleton: \\\"\\\"\\n" 64 | "animations: \\\"\\\"\\n" 65 | "default_animation: \\\"\\\"\\n" 66 | "materials {\\n" 67 | " name: \\\"default\\\"\\n" 68 | " material: \\\"/main/render/screenfade.material\\\"\\n" 69 | " textures {\\n" 70 | " sampler: \\\"DIFFUSE_TEXTURE\\\"\\n" 71 | " texture: \\\"/main/images/stencil_circle.png\\\"\\n" 72 | " }\\n" 73 | "}\\n" 74 | "\"\n" 75 | " position {\n" 76 | " x: 0.0\n" 77 | " y: 0.0\n" 78 | " z: 0.0\n" 79 | " }\n" 80 | " rotation {\n" 81 | " x: 0.0\n" 82 | " y: 0.0\n" 83 | " z: 0.0\n" 84 | " w: 1.0\n" 85 | " }\n" 86 | "}\n" 87 | "embedded_components {\n" 88 | " id: \"circle_2\"\n" 89 | " type: \"model\"\n" 90 | " data: \"mesh: \\\"/main/assets/quad.dae\\\"\\n" 91 | "skeleton: \\\"\\\"\\n" 92 | "animations: \\\"\\\"\\n" 93 | "default_animation: \\\"\\\"\\n" 94 | "materials {\\n" 95 | " name: \\\"default\\\"\\n" 96 | " material: \\\"/main/render/screenfade.material\\\"\\n" 97 | " textures {\\n" 98 | " sampler: \\\"DIFFUSE_TEXTURE\\\"\\n" 99 | " texture: \\\"/main/images/stencil_circle_2.png\\\"\\n" 100 | " }\\n" 101 | "}\\n" 102 | "\"\n" 103 | " position {\n" 104 | " x: 0.0\n" 105 | " y: 0.0\n" 106 | " z: 0.0\n" 107 | " }\n" 108 | " rotation {\n" 109 | " x: 0.0\n" 110 | " y: 0.0\n" 111 | " z: 0.0\n" 112 | " w: 1.0\n" 113 | " }\n" 114 | "}\n" 115 | "embedded_components {\n" 116 | " id: \"diagonal\"\n" 117 | " type: \"model\"\n" 118 | " data: \"mesh: \\\"/main/assets/quad.dae\\\"\\n" 119 | "skeleton: \\\"\\\"\\n" 120 | "animations: \\\"\\\"\\n" 121 | "default_animation: \\\"\\\"\\n" 122 | "materials {\\n" 123 | " name: \\\"default\\\"\\n" 124 | " material: \\\"/main/render/screenfade.material\\\"\\n" 125 | " textures {\\n" 126 | " sampler: \\\"DIFFUSE_TEXTURE\\\"\\n" 127 | " texture: \\\"/main/images/stencil_diagonal.png\\\"\\n" 128 | " }\\n" 129 | "}\\n" 130 | "\"\n" 131 | " position {\n" 132 | " x: 0.0\n" 133 | " y: 0.0\n" 134 | " z: 0.0\n" 135 | " }\n" 136 | " rotation {\n" 137 | " x: 0.0\n" 138 | " y: 0.0\n" 139 | " z: 0.0\n" 140 | " w: 1.0\n" 141 | " }\n" 142 | "}\n" 143 | "embedded_components {\n" 144 | " id: \"stripe_diagonal\"\n" 145 | " type: \"model\"\n" 146 | " data: \"mesh: \\\"/main/assets/quad.dae\\\"\\n" 147 | "skeleton: \\\"\\\"\\n" 148 | "animations: \\\"\\\"\\n" 149 | "default_animation: \\\"\\\"\\n" 150 | "materials {\\n" 151 | " name: \\\"default\\\"\\n" 152 | " material: \\\"/main/render/screenfade.material\\\"\\n" 153 | " textures {\\n" 154 | " sampler: \\\"DIFFUSE_TEXTURE\\\"\\n" 155 | " texture: \\\"/main/images/stencil_stripe_diagonal.png\\\"\\n" 156 | " }\\n" 157 | "}\\n" 158 | "\"\n" 159 | " position {\n" 160 | " x: 0.0\n" 161 | " y: 0.0\n" 162 | " z: 0.0\n" 163 | " }\n" 164 | " rotation {\n" 165 | " x: 0.0\n" 166 | " y: 0.0\n" 167 | " z: 0.0\n" 168 | " w: 1.0\n" 169 | " }\n" 170 | "}\n" 171 | "" 172 | position { 173 | x: 0.0 174 | y: 0.0 175 | z: 0.4 176 | } 177 | rotation { 178 | x: 0.0 179 | y: 0.0 180 | z: 0.0 181 | w: 1.0 182 | } 183 | scale3 { 184 | x: 1.0 185 | y: 1.0 186 | z: 1.0 187 | } 188 | } 189 | embedded_instances { 190 | id: "tilemap" 191 | data: "components {\n" 192 | " id: \"tilemap\"\n" 193 | " component: \"/main/main.tilemap\"\n" 194 | " position {\n" 195 | " x: 0.0\n" 196 | " y: 0.0\n" 197 | " z: 0.0\n" 198 | " }\n" 199 | " rotation {\n" 200 | " x: 0.0\n" 201 | " y: 0.0\n" 202 | " z: 0.0\n" 203 | " w: 1.0\n" 204 | " }\n" 205 | " property_decls {\n" 206 | " }\n" 207 | "}\n" 208 | "" 209 | position { 210 | x: 0.0 211 | y: 0.0 212 | z: 0.0 213 | } 214 | rotation { 215 | x: 0.0 216 | y: 0.0 217 | z: 0.0 218 | w: 1.0 219 | } 220 | scale3 { 221 | x: 1.0 222 | y: 1.0 223 | z: 1.0 224 | } 225 | } 226 | -------------------------------------------------------------------------------- /main/main.gui: -------------------------------------------------------------------------------- 1 | script: "/main/main.gui_script" 2 | fonts { 3 | name: "main" 4 | font: "/main/assets/font/main.font" 5 | } 6 | textures { 7 | name: "main" 8 | texture: "/main/images/main.atlas" 9 | } 10 | textures { 11 | name: "stencil" 12 | texture: "/main/images/stencil.atlas" 13 | } 14 | background_color { 15 | x: 0.0 16 | y: 0.0 17 | z: 0.0 18 | w: 1.0 19 | } 20 | nodes { 21 | position { 22 | x: 195.07495 23 | y: 48.436832 24 | z: 0.0 25 | w: 1.0 26 | } 27 | rotation { 28 | x: 0.0 29 | y: 0.0 30 | z: 0.0 31 | w: 1.0 32 | } 33 | scale { 34 | x: 1.0 35 | y: 1.0 36 | z: 1.0 37 | w: 1.0 38 | } 39 | size { 40 | x: 340.0 41 | y: 70.0 42 | z: 0.0 43 | w: 1.0 44 | } 45 | color { 46 | x: 1.0 47 | y: 1.0 48 | z: 1.0 49 | w: 1.0 50 | } 51 | type: TYPE_BOX 52 | blend_mode: BLEND_MODE_ALPHA 53 | texture: "main/dialog9" 54 | id: "Instructions" 55 | xanchor: XANCHOR_NONE 56 | yanchor: YANCHOR_NONE 57 | pivot: PIVOT_CENTER 58 | adjust_mode: ADJUST_MODE_FIT 59 | layer: "" 60 | inherit_alpha: true 61 | slice9 { 62 | x: 16.0 63 | y: 16.0 64 | z: 16.0 65 | w: 16.0 66 | } 67 | clipping_mode: CLIPPING_MODE_NONE 68 | clipping_visible: true 69 | clipping_inverted: false 70 | alpha: 0.75 71 | template_node_child: false 72 | size_mode: SIZE_MODE_MANUAL 73 | } 74 | nodes { 75 | position { 76 | x: 0.0 77 | y: 0.0 78 | z: 0.0 79 | w: 1.0 80 | } 81 | rotation { 82 | x: 0.0 83 | y: 0.0 84 | z: 0.0 85 | w: 1.0 86 | } 87 | scale { 88 | x: 1.0 89 | y: 1.0 90 | z: 1.0 91 | w: 1.0 92 | } 93 | size { 94 | x: 310.0 95 | y: 100.0 96 | z: 0.0 97 | w: 1.0 98 | } 99 | color { 100 | x: 1.0 101 | y: 1.0 102 | z: 1.0 103 | w: 1.0 104 | } 105 | type: TYPE_TEXT 106 | blend_mode: BLEND_MODE_ALPHA 107 | text: "Texture: Left/Right Fade: Up/Down" 108 | font: "main" 109 | id: "text" 110 | xanchor: XANCHOR_NONE 111 | yanchor: YANCHOR_NONE 112 | pivot: PIVOT_CENTER 113 | outline { 114 | x: 1.0 115 | y: 1.0 116 | z: 1.0 117 | w: 1.0 118 | } 119 | shadow { 120 | x: 1.0 121 | y: 1.0 122 | z: 1.0 123 | w: 1.0 124 | } 125 | adjust_mode: ADJUST_MODE_FIT 126 | line_break: true 127 | parent: "Instructions" 128 | layer: "" 129 | inherit_alpha: false 130 | clipping_mode: CLIPPING_MODE_NONE 131 | clipping_visible: true 132 | clipping_inverted: false 133 | alpha: 1.0 134 | outline_alpha: 1.0 135 | shadow_alpha: 1.0 136 | template_node_child: false 137 | text_leading: 1.1 138 | text_tracking: 0.0 139 | size_mode: SIZE_MODE_AUTO 140 | } 141 | nodes { 142 | position { 143 | x: 344.13275 144 | y: 246.71948 145 | z: 0.0 146 | w: 1.0 147 | } 148 | rotation { 149 | x: 0.0 150 | y: 0.0 151 | z: 0.0 152 | w: 1.0 153 | } 154 | scale { 155 | x: 1.0 156 | y: 1.0 157 | z: 1.0 158 | w: 1.0 159 | } 160 | size { 161 | x: 96.0 162 | y: 96.0 163 | z: 0.0 164 | w: 1.0 165 | } 166 | color { 167 | x: 1.0 168 | y: 1.0 169 | z: 1.0 170 | w: 1.0 171 | } 172 | type: TYPE_BOX 173 | blend_mode: BLEND_MODE_ALPHA 174 | texture: "main/dialog9" 175 | id: "texture_frame" 176 | xanchor: XANCHOR_NONE 177 | yanchor: YANCHOR_NONE 178 | pivot: PIVOT_CENTER 179 | adjust_mode: ADJUST_MODE_FIT 180 | layer: "" 181 | inherit_alpha: true 182 | slice9 { 183 | x: 16.0 184 | y: 16.0 185 | z: 16.0 186 | w: 16.0 187 | } 188 | clipping_mode: CLIPPING_MODE_NONE 189 | clipping_visible: true 190 | clipping_inverted: false 191 | alpha: 1.0 192 | template_node_child: false 193 | size_mode: SIZE_MODE_MANUAL 194 | } 195 | nodes { 196 | position { 197 | x: 0.0 198 | y: 0.0 199 | z: 0.0 200 | w: 1.0 201 | } 202 | rotation { 203 | x: 0.0 204 | y: 0.0 205 | z: 0.0 206 | w: 1.0 207 | } 208 | scale { 209 | x: 1.0 210 | y: 1.0 211 | z: 1.0 212 | w: 1.0 213 | } 214 | size { 215 | x: 64.0 216 | y: 64.0 217 | z: 0.0 218 | w: 1.0 219 | } 220 | color { 221 | x: 1.0 222 | y: 1.0 223 | z: 1.0 224 | w: 1.0 225 | } 226 | type: TYPE_BOX 227 | blend_mode: BLEND_MODE_ALPHA 228 | texture: "stencil/stencil_diagonal" 229 | id: "texture" 230 | xanchor: XANCHOR_NONE 231 | yanchor: YANCHOR_NONE 232 | pivot: PIVOT_CENTER 233 | adjust_mode: ADJUST_MODE_FIT 234 | parent: "texture_frame" 235 | layer: "" 236 | inherit_alpha: true 237 | slice9 { 238 | x: 0.0 239 | y: 0.0 240 | z: 0.0 241 | w: 0.0 242 | } 243 | clipping_mode: CLIPPING_MODE_NONE 244 | clipping_visible: true 245 | clipping_inverted: false 246 | alpha: 1.0 247 | template_node_child: false 248 | size_mode: SIZE_MODE_MANUAL 249 | } 250 | material: "/builtins/materials/gui.material" 251 | adjust_reference: ADJUST_REFERENCE_PARENT 252 | max_nodes: 512 253 | -------------------------------------------------------------------------------- /main/main.gui_script: -------------------------------------------------------------------------------- 1 | function init(self) 2 | msg.post(".", "acquire_input_focus", {}) 3 | msg.post("@render:", "use_fixed_projection", {zoom = 2}) 4 | self.node = gui.get_node("texture") 5 | end 6 | 7 | function on_message(self, message_id, message, sender) 8 | if message_id == hash("texture_name")then 9 | gui.play_flipbook(self.node, message.texture) 10 | end 11 | end 12 | 13 | function on_input(self, action_id, action) 14 | if action_id == hash("key_left") and action.pressed then 15 | msg.post("screenfade", "prev_texture") 16 | 17 | elseif action_id == hash("key_right") and action.pressed then 18 | msg.post("screenfade", "next_texture") 19 | 20 | elseif action_id == hash("key_down") and action.pressed then 21 | msg.post("screenfade", "fade_out") 22 | 23 | elseif action_id == hash("key_up") and action.pressed then 24 | msg.post("screenfade", "fade_in") 25 | 26 | end 27 | end 28 | -------------------------------------------------------------------------------- /main/main.tilemap: -------------------------------------------------------------------------------- 1 | tile_set: "/main/images/tiles.tilesource" 2 | layers { 3 | id: "background" 4 | z: 0.0 5 | is_visible: 1 6 | cell { 7 | x: 0 8 | y: 0 9 | tile: 55 10 | h_flip: 0 11 | v_flip: 0 12 | rotate90: 0 13 | } 14 | cell { 15 | x: 1 16 | y: 0 17 | tile: 55 18 | h_flip: 0 19 | v_flip: 0 20 | rotate90: 0 21 | } 22 | cell { 23 | x: 2 24 | y: 0 25 | tile: 55 26 | h_flip: 0 27 | v_flip: 0 28 | rotate90: 0 29 | } 30 | cell { 31 | x: 3 32 | y: 0 33 | tile: 55 34 | h_flip: 0 35 | v_flip: 0 36 | rotate90: 0 37 | } 38 | cell { 39 | x: 4 40 | y: 0 41 | tile: 55 42 | h_flip: 0 43 | v_flip: 0 44 | rotate90: 0 45 | } 46 | cell { 47 | x: 5 48 | y: 0 49 | tile: 55 50 | h_flip: 0 51 | v_flip: 0 52 | rotate90: 0 53 | } 54 | cell { 55 | x: 6 56 | y: 0 57 | tile: 55 58 | h_flip: 0 59 | v_flip: 0 60 | rotate90: 0 61 | } 62 | cell { 63 | x: 7 64 | y: 0 65 | tile: 55 66 | h_flip: 0 67 | v_flip: 0 68 | rotate90: 0 69 | } 70 | cell { 71 | x: 8 72 | y: 0 73 | tile: 55 74 | h_flip: 0 75 | v_flip: 0 76 | rotate90: 0 77 | } 78 | cell { 79 | x: 9 80 | y: 0 81 | tile: 55 82 | h_flip: 0 83 | v_flip: 0 84 | rotate90: 0 85 | } 86 | cell { 87 | x: 10 88 | y: 0 89 | tile: 55 90 | h_flip: 0 91 | v_flip: 0 92 | rotate90: 0 93 | } 94 | cell { 95 | x: 11 96 | y: 0 97 | tile: 55 98 | h_flip: 0 99 | v_flip: 0 100 | rotate90: 0 101 | } 102 | cell { 103 | x: 12 104 | y: 0 105 | tile: 55 106 | h_flip: 0 107 | v_flip: 0 108 | rotate90: 0 109 | } 110 | cell { 111 | x: 0 112 | y: 1 113 | tile: 55 114 | h_flip: 0 115 | v_flip: 0 116 | rotate90: 0 117 | } 118 | cell { 119 | x: 1 120 | y: 1 121 | tile: 55 122 | h_flip: 0 123 | v_flip: 0 124 | rotate90: 0 125 | } 126 | cell { 127 | x: 2 128 | y: 1 129 | tile: 55 130 | h_flip: 0 131 | v_flip: 0 132 | rotate90: 0 133 | } 134 | cell { 135 | x: 3 136 | y: 1 137 | tile: 55 138 | h_flip: 0 139 | v_flip: 0 140 | rotate90: 0 141 | } 142 | cell { 143 | x: 4 144 | y: 1 145 | tile: 55 146 | h_flip: 0 147 | v_flip: 0 148 | rotate90: 0 149 | } 150 | cell { 151 | x: 5 152 | y: 1 153 | tile: 55 154 | h_flip: 0 155 | v_flip: 0 156 | rotate90: 0 157 | } 158 | cell { 159 | x: 6 160 | y: 1 161 | tile: 55 162 | h_flip: 0 163 | v_flip: 0 164 | rotate90: 0 165 | } 166 | cell { 167 | x: 7 168 | y: 1 169 | tile: 55 170 | h_flip: 0 171 | v_flip: 0 172 | rotate90: 0 173 | } 174 | cell { 175 | x: 8 176 | y: 1 177 | tile: 55 178 | h_flip: 0 179 | v_flip: 0 180 | rotate90: 0 181 | } 182 | cell { 183 | x: 9 184 | y: 1 185 | tile: 55 186 | h_flip: 0 187 | v_flip: 0 188 | rotate90: 0 189 | } 190 | cell { 191 | x: 10 192 | y: 1 193 | tile: 55 194 | h_flip: 0 195 | v_flip: 0 196 | rotate90: 0 197 | } 198 | cell { 199 | x: 11 200 | y: 1 201 | tile: 55 202 | h_flip: 0 203 | v_flip: 0 204 | rotate90: 0 205 | } 206 | cell { 207 | x: 12 208 | y: 1 209 | tile: 55 210 | h_flip: 0 211 | v_flip: 0 212 | rotate90: 0 213 | } 214 | cell { 215 | x: 0 216 | y: 2 217 | tile: 55 218 | h_flip: 0 219 | v_flip: 0 220 | rotate90: 0 221 | } 222 | cell { 223 | x: 1 224 | y: 2 225 | tile: 55 226 | h_flip: 0 227 | v_flip: 0 228 | rotate90: 0 229 | } 230 | cell { 231 | x: 2 232 | y: 2 233 | tile: 55 234 | h_flip: 0 235 | v_flip: 0 236 | rotate90: 0 237 | } 238 | cell { 239 | x: 3 240 | y: 2 241 | tile: 55 242 | h_flip: 0 243 | v_flip: 0 244 | rotate90: 0 245 | } 246 | cell { 247 | x: 4 248 | y: 2 249 | tile: 55 250 | h_flip: 0 251 | v_flip: 0 252 | rotate90: 0 253 | } 254 | cell { 255 | x: 5 256 | y: 2 257 | tile: 55 258 | h_flip: 0 259 | v_flip: 0 260 | rotate90: 0 261 | } 262 | cell { 263 | x: 6 264 | y: 2 265 | tile: 55 266 | h_flip: 0 267 | v_flip: 0 268 | rotate90: 0 269 | } 270 | cell { 271 | x: 7 272 | y: 2 273 | tile: 55 274 | h_flip: 0 275 | v_flip: 0 276 | rotate90: 0 277 | } 278 | cell { 279 | x: 8 280 | y: 2 281 | tile: 55 282 | h_flip: 0 283 | v_flip: 0 284 | rotate90: 0 285 | } 286 | cell { 287 | x: 9 288 | y: 2 289 | tile: 55 290 | h_flip: 0 291 | v_flip: 0 292 | rotate90: 0 293 | } 294 | cell { 295 | x: 10 296 | y: 2 297 | tile: 55 298 | h_flip: 0 299 | v_flip: 0 300 | rotate90: 0 301 | } 302 | cell { 303 | x: 11 304 | y: 2 305 | tile: 55 306 | h_flip: 0 307 | v_flip: 0 308 | rotate90: 0 309 | } 310 | cell { 311 | x: 12 312 | y: 2 313 | tile: 55 314 | h_flip: 0 315 | v_flip: 0 316 | rotate90: 0 317 | } 318 | cell { 319 | x: 0 320 | y: 3 321 | tile: 63 322 | h_flip: 0 323 | v_flip: 0 324 | rotate90: 0 325 | } 326 | cell { 327 | x: 1 328 | y: 3 329 | tile: 63 330 | h_flip: 0 331 | v_flip: 0 332 | rotate90: 0 333 | } 334 | cell { 335 | x: 2 336 | y: 3 337 | tile: 63 338 | h_flip: 0 339 | v_flip: 0 340 | rotate90: 0 341 | } 342 | cell { 343 | x: 3 344 | y: 3 345 | tile: 63 346 | h_flip: 0 347 | v_flip: 0 348 | rotate90: 0 349 | } 350 | cell { 351 | x: 4 352 | y: 3 353 | tile: 63 354 | h_flip: 0 355 | v_flip: 0 356 | rotate90: 0 357 | } 358 | cell { 359 | x: 5 360 | y: 3 361 | tile: 63 362 | h_flip: 0 363 | v_flip: 0 364 | rotate90: 0 365 | } 366 | cell { 367 | x: 6 368 | y: 3 369 | tile: 63 370 | h_flip: 0 371 | v_flip: 0 372 | rotate90: 0 373 | } 374 | cell { 375 | x: 7 376 | y: 3 377 | tile: 63 378 | h_flip: 0 379 | v_flip: 0 380 | rotate90: 0 381 | } 382 | cell { 383 | x: 8 384 | y: 3 385 | tile: 63 386 | h_flip: 0 387 | v_flip: 0 388 | rotate90: 0 389 | } 390 | cell { 391 | x: 9 392 | y: 3 393 | tile: 63 394 | h_flip: 0 395 | v_flip: 0 396 | rotate90: 0 397 | } 398 | cell { 399 | x: 10 400 | y: 3 401 | tile: 63 402 | h_flip: 0 403 | v_flip: 0 404 | rotate90: 0 405 | } 406 | cell { 407 | x: 11 408 | y: 3 409 | tile: 63 410 | h_flip: 0 411 | v_flip: 0 412 | rotate90: 0 413 | } 414 | cell { 415 | x: 12 416 | y: 3 417 | tile: 63 418 | h_flip: 0 419 | v_flip: 0 420 | rotate90: 0 421 | } 422 | cell { 423 | x: 0 424 | y: 4 425 | tile: 55 426 | h_flip: 0 427 | v_flip: 0 428 | rotate90: 0 429 | } 430 | cell { 431 | x: 1 432 | y: 4 433 | tile: 55 434 | h_flip: 0 435 | v_flip: 0 436 | rotate90: 0 437 | } 438 | cell { 439 | x: 2 440 | y: 4 441 | tile: 55 442 | h_flip: 0 443 | v_flip: 0 444 | rotate90: 0 445 | } 446 | cell { 447 | x: 3 448 | y: 4 449 | tile: 55 450 | h_flip: 0 451 | v_flip: 0 452 | rotate90: 0 453 | } 454 | cell { 455 | x: 4 456 | y: 4 457 | tile: 55 458 | h_flip: 0 459 | v_flip: 0 460 | rotate90: 0 461 | } 462 | cell { 463 | x: 5 464 | y: 4 465 | tile: 55 466 | h_flip: 0 467 | v_flip: 0 468 | rotate90: 0 469 | } 470 | cell { 471 | x: 6 472 | y: 4 473 | tile: 55 474 | h_flip: 0 475 | v_flip: 0 476 | rotate90: 0 477 | } 478 | cell { 479 | x: 7 480 | y: 4 481 | tile: 55 482 | h_flip: 0 483 | v_flip: 0 484 | rotate90: 0 485 | } 486 | cell { 487 | x: 8 488 | y: 4 489 | tile: 55 490 | h_flip: 0 491 | v_flip: 0 492 | rotate90: 0 493 | } 494 | cell { 495 | x: 9 496 | y: 4 497 | tile: 55 498 | h_flip: 0 499 | v_flip: 0 500 | rotate90: 0 501 | } 502 | cell { 503 | x: 10 504 | y: 4 505 | tile: 55 506 | h_flip: 0 507 | v_flip: 0 508 | rotate90: 0 509 | } 510 | cell { 511 | x: 11 512 | y: 4 513 | tile: 55 514 | h_flip: 0 515 | v_flip: 0 516 | rotate90: 0 517 | } 518 | cell { 519 | x: 12 520 | y: 4 521 | tile: 55 522 | h_flip: 0 523 | v_flip: 0 524 | rotate90: 0 525 | } 526 | cell { 527 | x: 0 528 | y: 5 529 | tile: 55 530 | h_flip: 0 531 | v_flip: 0 532 | rotate90: 0 533 | } 534 | cell { 535 | x: 1 536 | y: 5 537 | tile: 55 538 | h_flip: 0 539 | v_flip: 0 540 | rotate90: 0 541 | } 542 | cell { 543 | x: 2 544 | y: 5 545 | tile: 55 546 | h_flip: 0 547 | v_flip: 0 548 | rotate90: 0 549 | } 550 | cell { 551 | x: 3 552 | y: 5 553 | tile: 55 554 | h_flip: 0 555 | v_flip: 0 556 | rotate90: 0 557 | } 558 | cell { 559 | x: 4 560 | y: 5 561 | tile: 55 562 | h_flip: 0 563 | v_flip: 0 564 | rotate90: 0 565 | } 566 | cell { 567 | x: 5 568 | y: 5 569 | tile: 55 570 | h_flip: 0 571 | v_flip: 0 572 | rotate90: 0 573 | } 574 | cell { 575 | x: 6 576 | y: 5 577 | tile: 55 578 | h_flip: 0 579 | v_flip: 0 580 | rotate90: 0 581 | } 582 | cell { 583 | x: 7 584 | y: 5 585 | tile: 55 586 | h_flip: 0 587 | v_flip: 0 588 | rotate90: 0 589 | } 590 | cell { 591 | x: 8 592 | y: 5 593 | tile: 55 594 | h_flip: 0 595 | v_flip: 0 596 | rotate90: 0 597 | } 598 | cell { 599 | x: 9 600 | y: 5 601 | tile: 55 602 | h_flip: 0 603 | v_flip: 0 604 | rotate90: 0 605 | } 606 | cell { 607 | x: 10 608 | y: 5 609 | tile: 55 610 | h_flip: 0 611 | v_flip: 0 612 | rotate90: 0 613 | } 614 | cell { 615 | x: 11 616 | y: 5 617 | tile: 55 618 | h_flip: 0 619 | v_flip: 0 620 | rotate90: 0 621 | } 622 | cell { 623 | x: 12 624 | y: 5 625 | tile: 55 626 | h_flip: 0 627 | v_flip: 0 628 | rotate90: 0 629 | } 630 | cell { 631 | x: 0 632 | y: 6 633 | tile: 55 634 | h_flip: 0 635 | v_flip: 0 636 | rotate90: 0 637 | } 638 | cell { 639 | x: 1 640 | y: 6 641 | tile: 55 642 | h_flip: 0 643 | v_flip: 0 644 | rotate90: 0 645 | } 646 | cell { 647 | x: 2 648 | y: 6 649 | tile: 55 650 | h_flip: 0 651 | v_flip: 0 652 | rotate90: 0 653 | } 654 | cell { 655 | x: 3 656 | y: 6 657 | tile: 55 658 | h_flip: 0 659 | v_flip: 0 660 | rotate90: 0 661 | } 662 | cell { 663 | x: 4 664 | y: 6 665 | tile: 55 666 | h_flip: 0 667 | v_flip: 0 668 | rotate90: 0 669 | } 670 | cell { 671 | x: 5 672 | y: 6 673 | tile: 55 674 | h_flip: 0 675 | v_flip: 0 676 | rotate90: 0 677 | } 678 | cell { 679 | x: 6 680 | y: 6 681 | tile: 55 682 | h_flip: 0 683 | v_flip: 0 684 | rotate90: 0 685 | } 686 | cell { 687 | x: 7 688 | y: 6 689 | tile: 55 690 | h_flip: 0 691 | v_flip: 0 692 | rotate90: 0 693 | } 694 | cell { 695 | x: 8 696 | y: 6 697 | tile: 55 698 | h_flip: 0 699 | v_flip: 0 700 | rotate90: 0 701 | } 702 | cell { 703 | x: 9 704 | y: 6 705 | tile: 55 706 | h_flip: 0 707 | v_flip: 0 708 | rotate90: 0 709 | } 710 | cell { 711 | x: 10 712 | y: 6 713 | tile: 55 714 | h_flip: 0 715 | v_flip: 0 716 | rotate90: 0 717 | } 718 | cell { 719 | x: 11 720 | y: 6 721 | tile: 55 722 | h_flip: 0 723 | v_flip: 0 724 | rotate90: 0 725 | } 726 | cell { 727 | x: 12 728 | y: 6 729 | tile: 55 730 | h_flip: 0 731 | v_flip: 0 732 | rotate90: 0 733 | } 734 | cell { 735 | x: 0 736 | y: 7 737 | tile: 55 738 | h_flip: 0 739 | v_flip: 0 740 | rotate90: 0 741 | } 742 | cell { 743 | x: 1 744 | y: 7 745 | tile: 55 746 | h_flip: 0 747 | v_flip: 0 748 | rotate90: 0 749 | } 750 | cell { 751 | x: 2 752 | y: 7 753 | tile: 55 754 | h_flip: 0 755 | v_flip: 0 756 | rotate90: 0 757 | } 758 | cell { 759 | x: 3 760 | y: 7 761 | tile: 55 762 | h_flip: 0 763 | v_flip: 0 764 | rotate90: 0 765 | } 766 | cell { 767 | x: 4 768 | y: 7 769 | tile: 55 770 | h_flip: 0 771 | v_flip: 0 772 | rotate90: 0 773 | } 774 | cell { 775 | x: 5 776 | y: 7 777 | tile: 55 778 | h_flip: 0 779 | v_flip: 0 780 | rotate90: 0 781 | } 782 | cell { 783 | x: 6 784 | y: 7 785 | tile: 55 786 | h_flip: 0 787 | v_flip: 0 788 | rotate90: 0 789 | } 790 | cell { 791 | x: 7 792 | y: 7 793 | tile: 55 794 | h_flip: 0 795 | v_flip: 0 796 | rotate90: 0 797 | } 798 | cell { 799 | x: 8 800 | y: 7 801 | tile: 55 802 | h_flip: 0 803 | v_flip: 0 804 | rotate90: 0 805 | } 806 | cell { 807 | x: 9 808 | y: 7 809 | tile: 55 810 | h_flip: 0 811 | v_flip: 0 812 | rotate90: 0 813 | } 814 | cell { 815 | x: 10 816 | y: 7 817 | tile: 55 818 | h_flip: 0 819 | v_flip: 0 820 | rotate90: 0 821 | } 822 | cell { 823 | x: 11 824 | y: 7 825 | tile: 55 826 | h_flip: 0 827 | v_flip: 0 828 | rotate90: 0 829 | } 830 | cell { 831 | x: 12 832 | y: 7 833 | tile: 55 834 | h_flip: 0 835 | v_flip: 0 836 | rotate90: 0 837 | } 838 | cell { 839 | x: 0 840 | y: 8 841 | tile: 47 842 | h_flip: 0 843 | v_flip: 0 844 | rotate90: 0 845 | } 846 | cell { 847 | x: 1 848 | y: 8 849 | tile: 47 850 | h_flip: 0 851 | v_flip: 0 852 | rotate90: 0 853 | } 854 | cell { 855 | x: 2 856 | y: 8 857 | tile: 47 858 | h_flip: 0 859 | v_flip: 0 860 | rotate90: 0 861 | } 862 | cell { 863 | x: 3 864 | y: 8 865 | tile: 47 866 | h_flip: 0 867 | v_flip: 0 868 | rotate90: 0 869 | } 870 | cell { 871 | x: 4 872 | y: 8 873 | tile: 47 874 | h_flip: 0 875 | v_flip: 0 876 | rotate90: 0 877 | } 878 | cell { 879 | x: 5 880 | y: 8 881 | tile: 47 882 | h_flip: 0 883 | v_flip: 0 884 | rotate90: 0 885 | } 886 | cell { 887 | x: 6 888 | y: 8 889 | tile: 47 890 | h_flip: 0 891 | v_flip: 0 892 | rotate90: 0 893 | } 894 | cell { 895 | x: 7 896 | y: 8 897 | tile: 47 898 | h_flip: 0 899 | v_flip: 0 900 | rotate90: 0 901 | } 902 | cell { 903 | x: 8 904 | y: 8 905 | tile: 47 906 | h_flip: 0 907 | v_flip: 0 908 | rotate90: 0 909 | } 910 | cell { 911 | x: 9 912 | y: 8 913 | tile: 47 914 | h_flip: 0 915 | v_flip: 0 916 | rotate90: 0 917 | } 918 | cell { 919 | x: 10 920 | y: 8 921 | tile: 47 922 | h_flip: 0 923 | v_flip: 0 924 | rotate90: 0 925 | } 926 | cell { 927 | x: 11 928 | y: 8 929 | tile: 47 930 | h_flip: 0 931 | v_flip: 0 932 | rotate90: 0 933 | } 934 | cell { 935 | x: 12 936 | y: 8 937 | tile: 47 938 | h_flip: 0 939 | v_flip: 0 940 | rotate90: 0 941 | } 942 | cell { 943 | x: 0 944 | y: 9 945 | tile: 39 946 | h_flip: 0 947 | v_flip: 0 948 | rotate90: 0 949 | } 950 | cell { 951 | x: 1 952 | y: 9 953 | tile: 39 954 | h_flip: 0 955 | v_flip: 0 956 | rotate90: 0 957 | } 958 | cell { 959 | x: 2 960 | y: 9 961 | tile: 39 962 | h_flip: 0 963 | v_flip: 0 964 | rotate90: 0 965 | } 966 | cell { 967 | x: 3 968 | y: 9 969 | tile: 39 970 | h_flip: 0 971 | v_flip: 0 972 | rotate90: 0 973 | } 974 | cell { 975 | x: 4 976 | y: 9 977 | tile: 39 978 | h_flip: 0 979 | v_flip: 0 980 | rotate90: 0 981 | } 982 | cell { 983 | x: 5 984 | y: 9 985 | tile: 39 986 | h_flip: 0 987 | v_flip: 0 988 | rotate90: 0 989 | } 990 | cell { 991 | x: 6 992 | y: 9 993 | tile: 39 994 | h_flip: 0 995 | v_flip: 0 996 | rotate90: 0 997 | } 998 | cell { 999 | x: 7 1000 | y: 9 1001 | tile: 39 1002 | h_flip: 0 1003 | v_flip: 0 1004 | rotate90: 0 1005 | } 1006 | cell { 1007 | x: 8 1008 | y: 9 1009 | tile: 39 1010 | h_flip: 0 1011 | v_flip: 0 1012 | rotate90: 0 1013 | } 1014 | cell { 1015 | x: 9 1016 | y: 9 1017 | tile: 39 1018 | h_flip: 0 1019 | v_flip: 0 1020 | rotate90: 0 1021 | } 1022 | cell { 1023 | x: 10 1024 | y: 9 1025 | tile: 39 1026 | h_flip: 0 1027 | v_flip: 0 1028 | rotate90: 0 1029 | } 1030 | cell { 1031 | x: 11 1032 | y: 9 1033 | tile: 39 1034 | h_flip: 0 1035 | v_flip: 0 1036 | rotate90: 0 1037 | } 1038 | cell { 1039 | x: 12 1040 | y: 9 1041 | tile: 39 1042 | h_flip: 0 1043 | v_flip: 0 1044 | rotate90: 0 1045 | } 1046 | } 1047 | layers { 1048 | id: "tiles" 1049 | z: 0.1 1050 | is_visible: 1 1051 | cell { 1052 | x: 0 1053 | y: 0 1054 | tile: 21 1055 | h_flip: 0 1056 | v_flip: 0 1057 | rotate90: 0 1058 | } 1059 | cell { 1060 | x: 1 1061 | y: 0 1062 | tile: 21 1063 | h_flip: 0 1064 | v_flip: 0 1065 | rotate90: 0 1066 | } 1067 | cell { 1068 | x: 2 1069 | y: 0 1070 | tile: 21 1071 | h_flip: 0 1072 | v_flip: 0 1073 | rotate90: 0 1074 | } 1075 | cell { 1076 | x: 3 1077 | y: 0 1078 | tile: 21 1079 | h_flip: 0 1080 | v_flip: 0 1081 | rotate90: 0 1082 | } 1083 | cell { 1084 | x: 4 1085 | y: 0 1086 | tile: 21 1087 | h_flip: 0 1088 | v_flip: 0 1089 | rotate90: 0 1090 | } 1091 | cell { 1092 | x: 5 1093 | y: 0 1094 | tile: 21 1095 | h_flip: 0 1096 | v_flip: 0 1097 | rotate90: 0 1098 | } 1099 | cell { 1100 | x: 6 1101 | y: 0 1102 | tile: 21 1103 | h_flip: 0 1104 | v_flip: 0 1105 | rotate90: 0 1106 | } 1107 | cell { 1108 | x: 7 1109 | y: 0 1110 | tile: 21 1111 | h_flip: 0 1112 | v_flip: 0 1113 | rotate90: 0 1114 | } 1115 | cell { 1116 | x: 8 1117 | y: 0 1118 | tile: 21 1119 | h_flip: 0 1120 | v_flip: 0 1121 | rotate90: 0 1122 | } 1123 | cell { 1124 | x: 9 1125 | y: 0 1126 | tile: 21 1127 | h_flip: 0 1128 | v_flip: 0 1129 | rotate90: 0 1130 | } 1131 | cell { 1132 | x: 10 1133 | y: 0 1134 | tile: 21 1135 | h_flip: 0 1136 | v_flip: 0 1137 | rotate90: 0 1138 | } 1139 | cell { 1140 | x: 11 1141 | y: 0 1142 | tile: 21 1143 | h_flip: 0 1144 | v_flip: 0 1145 | rotate90: 0 1146 | } 1147 | cell { 1148 | x: 12 1149 | y: 0 1150 | tile: 21 1151 | h_flip: 0 1152 | v_flip: 0 1153 | rotate90: 0 1154 | } 1155 | cell { 1156 | x: 0 1157 | y: 1 1158 | tile: 21 1159 | h_flip: 0 1160 | v_flip: 0 1161 | rotate90: 0 1162 | } 1163 | cell { 1164 | x: 1 1165 | y: 1 1166 | tile: 21 1167 | h_flip: 0 1168 | v_flip: 0 1169 | rotate90: 0 1170 | } 1171 | cell { 1172 | x: 2 1173 | y: 1 1174 | tile: 21 1175 | h_flip: 0 1176 | v_flip: 0 1177 | rotate90: 0 1178 | } 1179 | cell { 1180 | x: 3 1181 | y: 1 1182 | tile: 21 1183 | h_flip: 0 1184 | v_flip: 0 1185 | rotate90: 0 1186 | } 1187 | cell { 1188 | x: 4 1189 | y: 1 1190 | tile: 21 1191 | h_flip: 0 1192 | v_flip: 0 1193 | rotate90: 0 1194 | } 1195 | cell { 1196 | x: 5 1197 | y: 1 1198 | tile: 21 1199 | h_flip: 0 1200 | v_flip: 0 1201 | rotate90: 0 1202 | } 1203 | cell { 1204 | x: 6 1205 | y: 1 1206 | tile: 21 1207 | h_flip: 0 1208 | v_flip: 0 1209 | rotate90: 0 1210 | } 1211 | cell { 1212 | x: 7 1213 | y: 1 1214 | tile: 21 1215 | h_flip: 0 1216 | v_flip: 0 1217 | rotate90: 0 1218 | } 1219 | cell { 1220 | x: 8 1221 | y: 1 1222 | tile: 21 1223 | h_flip: 0 1224 | v_flip: 0 1225 | rotate90: 0 1226 | } 1227 | cell { 1228 | x: 9 1229 | y: 1 1230 | tile: 21 1231 | h_flip: 0 1232 | v_flip: 0 1233 | rotate90: 0 1234 | } 1235 | cell { 1236 | x: 10 1237 | y: 1 1238 | tile: 21 1239 | h_flip: 0 1240 | v_flip: 0 1241 | rotate90: 0 1242 | } 1243 | cell { 1244 | x: 11 1245 | y: 1 1246 | tile: 21 1247 | h_flip: 0 1248 | v_flip: 0 1249 | rotate90: 0 1250 | } 1251 | cell { 1252 | x: 12 1253 | y: 1 1254 | tile: 21 1255 | h_flip: 0 1256 | v_flip: 0 1257 | rotate90: 0 1258 | } 1259 | cell { 1260 | x: 0 1261 | y: 2 1262 | tile: 13 1263 | h_flip: 0 1264 | v_flip: 0 1265 | rotate90: 0 1266 | } 1267 | cell { 1268 | x: 1 1269 | y: 2 1270 | tile: 13 1271 | h_flip: 0 1272 | v_flip: 0 1273 | rotate90: 0 1274 | } 1275 | cell { 1276 | x: 2 1277 | y: 2 1278 | tile: 13 1279 | h_flip: 0 1280 | v_flip: 0 1281 | rotate90: 0 1282 | } 1283 | cell { 1284 | x: 3 1285 | y: 2 1286 | tile: 13 1287 | h_flip: 0 1288 | v_flip: 0 1289 | rotate90: 0 1290 | } 1291 | cell { 1292 | x: 4 1293 | y: 2 1294 | tile: 13 1295 | h_flip: 0 1296 | v_flip: 0 1297 | rotate90: 0 1298 | } 1299 | cell { 1300 | x: 5 1301 | y: 2 1302 | tile: 13 1303 | h_flip: 0 1304 | v_flip: 0 1305 | rotate90: 0 1306 | } 1307 | cell { 1308 | x: 6 1309 | y: 2 1310 | tile: 13 1311 | h_flip: 0 1312 | v_flip: 0 1313 | rotate90: 0 1314 | } 1315 | cell { 1316 | x: 7 1317 | y: 2 1318 | tile: 13 1319 | h_flip: 0 1320 | v_flip: 0 1321 | rotate90: 0 1322 | } 1323 | cell { 1324 | x: 8 1325 | y: 2 1326 | tile: 13 1327 | h_flip: 0 1328 | v_flip: 0 1329 | rotate90: 0 1330 | } 1331 | cell { 1332 | x: 9 1333 | y: 2 1334 | tile: 13 1335 | h_flip: 0 1336 | v_flip: 0 1337 | rotate90: 0 1338 | } 1339 | cell { 1340 | x: 10 1341 | y: 2 1342 | tile: 13 1343 | h_flip: 0 1344 | v_flip: 0 1345 | rotate90: 0 1346 | } 1347 | cell { 1348 | x: 11 1349 | y: 2 1350 | tile: 13 1351 | h_flip: 0 1352 | v_flip: 0 1353 | rotate90: 0 1354 | } 1355 | cell { 1356 | x: 12 1357 | y: 2 1358 | tile: 13 1359 | h_flip: 0 1360 | v_flip: 0 1361 | rotate90: 0 1362 | } 1363 | cell { 1364 | x: 0 1365 | y: 3 1366 | tile: 21 1367 | h_flip: 0 1368 | v_flip: 0 1369 | rotate90: 0 1370 | } 1371 | cell { 1372 | x: 1 1373 | y: 3 1374 | tile: 21 1375 | h_flip: 0 1376 | v_flip: 0 1377 | rotate90: 0 1378 | } 1379 | cell { 1380 | x: 2 1381 | y: 3 1382 | tile: 13 1383 | h_flip: 0 1384 | v_flip: 0 1385 | rotate90: 0 1386 | } 1387 | cell { 1388 | x: 3 1389 | y: 3 1390 | tile: 10 1391 | h_flip: 0 1392 | v_flip: 0 1393 | rotate90: 0 1394 | } 1395 | cell { 1396 | x: 4 1397 | y: 3 1398 | tile: 5 1399 | h_flip: 0 1400 | v_flip: 0 1401 | rotate90: 0 1402 | } 1403 | cell { 1404 | x: 5 1405 | y: 3 1406 | tile: 6 1407 | h_flip: 0 1408 | v_flip: 0 1409 | rotate90: 0 1410 | } 1411 | cell { 1412 | x: 0 1413 | y: 4 1414 | tile: 21 1415 | h_flip: 0 1416 | v_flip: 0 1417 | rotate90: 0 1418 | } 1419 | cell { 1420 | x: 1 1421 | y: 4 1422 | tile: 21 1423 | h_flip: 0 1424 | v_flip: 0 1425 | rotate90: 0 1426 | } 1427 | cell { 1428 | x: 2 1429 | y: 4 1430 | tile: 22 1431 | h_flip: 0 1432 | v_flip: 0 1433 | rotate90: 0 1434 | } 1435 | cell { 1436 | x: 0 1437 | y: 5 1438 | tile: 13 1439 | h_flip: 0 1440 | v_flip: 0 1441 | rotate90: 0 1442 | } 1443 | cell { 1444 | x: 1 1445 | y: 5 1446 | tile: 13 1447 | h_flip: 0 1448 | v_flip: 0 1449 | rotate90: 0 1450 | } 1451 | cell { 1452 | x: 2 1453 | y: 5 1454 | tile: 14 1455 | h_flip: 0 1456 | v_flip: 0 1457 | rotate90: 0 1458 | } 1459 | } 1460 | layers { 1461 | id: "foreground" 1462 | z: 0.2 1463 | is_visible: 1 1464 | cell { 1465 | x: 0 1466 | y: 0 1467 | tile: 25 1468 | h_flip: 0 1469 | v_flip: 0 1470 | rotate90: 0 1471 | } 1472 | cell { 1473 | x: 1 1474 | y: 0 1475 | tile: 25 1476 | h_flip: 0 1477 | v_flip: 0 1478 | rotate90: 0 1479 | } 1480 | cell { 1481 | x: 2 1482 | y: 0 1483 | tile: 25 1484 | h_flip: 0 1485 | v_flip: 0 1486 | rotate90: 0 1487 | } 1488 | cell { 1489 | x: 3 1490 | y: 0 1491 | tile: 25 1492 | h_flip: 0 1493 | v_flip: 0 1494 | rotate90: 0 1495 | } 1496 | cell { 1497 | x: 4 1498 | y: 0 1499 | tile: 25 1500 | h_flip: 0 1501 | v_flip: 0 1502 | rotate90: 0 1503 | } 1504 | cell { 1505 | x: 5 1506 | y: 0 1507 | tile: 25 1508 | h_flip: 0 1509 | v_flip: 0 1510 | rotate90: 0 1511 | } 1512 | cell { 1513 | x: 6 1514 | y: 0 1515 | tile: 25 1516 | h_flip: 0 1517 | v_flip: 0 1518 | rotate90: 0 1519 | } 1520 | cell { 1521 | x: 7 1522 | y: 0 1523 | tile: 25 1524 | h_flip: 0 1525 | v_flip: 0 1526 | rotate90: 0 1527 | } 1528 | cell { 1529 | x: 8 1530 | y: 0 1531 | tile: 25 1532 | h_flip: 0 1533 | v_flip: 0 1534 | rotate90: 0 1535 | } 1536 | cell { 1537 | x: 9 1538 | y: 0 1539 | tile: 25 1540 | h_flip: 0 1541 | v_flip: 0 1542 | rotate90: 0 1543 | } 1544 | cell { 1545 | x: 10 1546 | y: 0 1547 | tile: 25 1548 | h_flip: 0 1549 | v_flip: 0 1550 | rotate90: 0 1551 | } 1552 | cell { 1553 | x: 11 1554 | y: 0 1555 | tile: 25 1556 | h_flip: 0 1557 | v_flip: 0 1558 | rotate90: 0 1559 | } 1560 | cell { 1561 | x: 12 1562 | y: 0 1563 | tile: 25 1564 | h_flip: 0 1565 | v_flip: 0 1566 | rotate90: 0 1567 | } 1568 | cell { 1569 | x: 0 1570 | y: 1 1571 | tile: 17 1572 | h_flip: 0 1573 | v_flip: 0 1574 | rotate90: 0 1575 | } 1576 | cell { 1577 | x: 1 1578 | y: 1 1579 | tile: 17 1580 | h_flip: 0 1581 | v_flip: 0 1582 | rotate90: 0 1583 | } 1584 | cell { 1585 | x: 2 1586 | y: 1 1587 | tile: 17 1588 | h_flip: 0 1589 | v_flip: 0 1590 | rotate90: 0 1591 | } 1592 | cell { 1593 | x: 3 1594 | y: 1 1595 | tile: 17 1596 | h_flip: 0 1597 | v_flip: 0 1598 | rotate90: 0 1599 | } 1600 | cell { 1601 | x: 4 1602 | y: 1 1603 | tile: 17 1604 | h_flip: 0 1605 | v_flip: 0 1606 | rotate90: 0 1607 | } 1608 | cell { 1609 | x: 5 1610 | y: 1 1611 | tile: 17 1612 | h_flip: 0 1613 | v_flip: 0 1614 | rotate90: 0 1615 | } 1616 | cell { 1617 | x: 6 1618 | y: 1 1619 | tile: 17 1620 | h_flip: 0 1621 | v_flip: 0 1622 | rotate90: 0 1623 | } 1624 | cell { 1625 | x: 7 1626 | y: 1 1627 | tile: 17 1628 | h_flip: 0 1629 | v_flip: 0 1630 | rotate90: 0 1631 | } 1632 | cell { 1633 | x: 8 1634 | y: 1 1635 | tile: 17 1636 | h_flip: 0 1637 | v_flip: 0 1638 | rotate90: 0 1639 | } 1640 | cell { 1641 | x: 9 1642 | y: 1 1643 | tile: 17 1644 | h_flip: 0 1645 | v_flip: 0 1646 | rotate90: 0 1647 | } 1648 | cell { 1649 | x: 10 1650 | y: 1 1651 | tile: 17 1652 | h_flip: 0 1653 | v_flip: 0 1654 | rotate90: 0 1655 | } 1656 | cell { 1657 | x: 11 1658 | y: 1 1659 | tile: 17 1660 | h_flip: 0 1661 | v_flip: 0 1662 | rotate90: 0 1663 | } 1664 | cell { 1665 | x: 12 1666 | y: 1 1667 | tile: 17 1668 | h_flip: 0 1669 | v_flip: 0 1670 | rotate90: 0 1671 | } 1672 | cell { 1673 | x: 1 1674 | y: 3 1675 | tile: 12 1676 | h_flip: 0 1677 | v_flip: 0 1678 | rotate90: 0 1679 | } 1680 | } 1681 | material: "/builtins/materials/tile_map.material" 1682 | blend_mode: BLEND_MODE_ALPHA 1683 | -------------------------------------------------------------------------------- /main/render/custom.render: -------------------------------------------------------------------------------- 1 | script: "/main/render/custom.render_script" 2 | -------------------------------------------------------------------------------- /main/render/custom.render_script: -------------------------------------------------------------------------------- 1 | -- Copyright 2020-2024 The Defold Foundation 2 | -- Copyright 2014-2020 King 3 | -- Copyright 2009-2014 Ragnar Svensson, Christian Murray 4 | -- Licensed under the Defold License version 1.0 (the "License"); you may not use 5 | -- this file except in compliance with the License. 6 | -- 7 | -- You may obtain a copy of the License, together with FAQs at 8 | -- https://www.defold.com/license 9 | -- 10 | -- Unless required by applicable law or agreed to in writing, software distributed 11 | -- under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 12 | -- CONDITIONS OF ANY KIND, either express or implied. See the License for the 13 | -- specific language governing permissions and limitations under the License. 14 | 15 | -- 16 | -- message constants 17 | -- 18 | local MSG_CLEAR_COLOR = hash("clear_color") 19 | local MSG_WINDOW_RESIZED = hash("window_resized") 20 | local MSG_SET_VIEW_PROJ = hash("set_view_projection") 21 | local MSG_SET_CAMERA_PROJ = hash("use_camera_projection") 22 | local MSG_USE_STRETCH_PROJ = hash("use_stretch_projection") 23 | local MSG_USE_FIXED_PROJ = hash("use_fixed_projection") 24 | local MSG_USE_FIXED_FIT_PROJ = hash("use_fixed_fit_projection") 25 | 26 | local DEFAULT_NEAR = -1 27 | local DEFAULT_FAR = 1 28 | local DEFAULT_ZOOM = 1 29 | 30 | -- 31 | -- projection that centers content with maintained aspect ratio and optional zoom 32 | -- 33 | local function get_fixed_projection(camera, state) 34 | camera.zoom = camera.zoom or DEFAULT_ZOOM 35 | local projected_width = state.window_width / camera.zoom 36 | local projected_height = state.window_height / camera.zoom 37 | local left = -(projected_width - state.width) / 2 38 | local bottom = -(projected_height - state.height) / 2 39 | local right = left + projected_width 40 | local top = bottom + projected_height 41 | return vmath.matrix4_orthographic(left, right, bottom, top, camera.near, camera.far) 42 | end 43 | -- 44 | -- projection that centers and fits content with maintained aspect ratio 45 | -- 46 | local function get_fixed_fit_projection(camera, state) 47 | camera.zoom = math.min(state.window_width / state.width, state.window_height / state.height) 48 | return get_fixed_projection(camera, state) 49 | end 50 | -- 51 | -- projection that stretches content 52 | -- 53 | local function get_stretch_projection(camera, state) 54 | return vmath.matrix4_orthographic(0, state.width, 0, state.height, camera.near, camera.far) 55 | end 56 | -- 57 | -- projection for gui 58 | -- 59 | local function get_gui_projection(camera, state) 60 | return vmath.matrix4_orthographic(0, state.window_width, 0, state.window_height, camera.near, camera.far) 61 | end 62 | 63 | local function update_clear_color(state, color) 64 | if color then 65 | state.clear_buffers[render.BUFFER_COLOR_BIT] = color 66 | end 67 | end 68 | 69 | local function update_camera(camera, state) 70 | camera.proj = camera.projection_fn(camera, state) 71 | camera.frustum.frustum = camera.proj * camera.view 72 | end 73 | 74 | local function update_state(state) 75 | state.window_width = render.get_window_width() 76 | state.window_height = render.get_window_height() 77 | state.valid = state.window_width > 0 and state.window_height > 0 78 | if not state.valid then 79 | return false 80 | end 81 | -- Make sure state updated only once when resize window 82 | if state.window_width == state.prev_window_width and state.window_height == state.prev_window_height then 83 | return true 84 | end 85 | state.prev_window_width = state.window_width 86 | state.prev_window_height = state.window_height 87 | state.width = render.get_width() 88 | state.height = render.get_height() 89 | for _, camera in pairs(state.cameras) do 90 | update_camera(camera, state) 91 | end 92 | return true 93 | end 94 | 95 | local function init_camera(camera, projection_fn, near, far, zoom) 96 | camera.view = vmath.matrix4() 97 | camera.near = near == nil and DEFAULT_NEAR or near 98 | camera.far = far == nil and DEFAULT_FAR or far 99 | camera.zoom = zoom == nil and DEFAULT_ZOOM or zoom 100 | camera.projection_fn = projection_fn 101 | end 102 | 103 | local function create_predicates(...) 104 | local arg = {...} 105 | local predicates = {} 106 | for _, predicate_name in pairs(arg) do 107 | predicates[predicate_name] = render.predicate({predicate_name}) 108 | end 109 | return predicates 110 | end 111 | 112 | local function create_camera(state, name, is_main_camera) 113 | local camera = {} 114 | camera.frustum = {} 115 | state.cameras[name] = camera 116 | if is_main_camera then 117 | state.main_camera = camera 118 | end 119 | return camera 120 | end 121 | 122 | local function create_state() 123 | local state = {} 124 | local color = vmath.vector4(0, 0, 0, 0) 125 | color.x = sys.get_config_number("render.clear_color_red", 0) 126 | color.y = sys.get_config_number("render.clear_color_green", 0) 127 | color.z = sys.get_config_number("render.clear_color_blue", 0) 128 | color.w = sys.get_config_number("render.clear_color_alpha", 0) 129 | state.clear_buffers = { 130 | [render.BUFFER_COLOR_BIT] = color, 131 | [render.BUFFER_DEPTH_BIT] = 1, 132 | [render.BUFFER_STENCIL_BIT] = 0 133 | } 134 | state.cameras = {} 135 | return state 136 | end 137 | 138 | function init(self) 139 | self.predicates = create_predicates("tile", "gui", "particle", "model", "debug_text") 140 | 141 | -- default is stretch projection. copy from builtins and change for different projection 142 | -- or send a message to the render script to change projection: 143 | -- msg.post("@render:", "use_stretch_projection", { near = -1, far = 1 }) 144 | -- msg.post("@render:", "use_fixed_projection", { near = -1, far = 1, zoom = 2 }) 145 | -- msg.post("@render:", "use_fixed_fit_projection", { near = -1, far = 1 }) 146 | 147 | local state = create_state() 148 | self.state = state 149 | local camera_world = create_camera(state, "camera_world", true) 150 | init_camera(camera_world, get_stretch_projection) 151 | local camera_gui = create_camera(state, "camera_gui") 152 | init_camera(camera_gui, get_gui_projection) 153 | update_state(state) 154 | 155 | self.mask_pred = render.predicate({"screenfade"}) 156 | self.stencil_mask_enabled = true 157 | end 158 | 159 | function update(self) 160 | local state = self.state 161 | if not state.valid then 162 | if not update_state(state) then 163 | return 164 | end 165 | end 166 | 167 | local predicates = self.predicates 168 | -- clear screen buffers 169 | -- 170 | -- turn on depth_mask before `render.clear()` to clear it as well 171 | render.set_depth_mask(true) 172 | render.set_stencil_mask(0xff) 173 | render.clear(state.clear_buffers) 174 | 175 | -- setup camera view and projection 176 | -- 177 | local camera_world = state.cameras.camera_world 178 | render.set_viewport(0, 0, state.window_width, state.window_height) 179 | render.set_view(camera_world.view) 180 | render.set_projection(camera_world.proj) 181 | 182 | render.set_depth_mask(false) 183 | render.disable_state(render.STATE_DEPTH_TEST) 184 | 185 | if self.stencil_mask_enabled then 186 | -- Using the simple trick from Sven's post here: https://forum.defold.com/t/making-a-flashlight/286/3 187 | -- 1. We need to disable color drawing while rendering the mask 188 | render.set_color_mask(false, false, false, false) 189 | 190 | -- 2. Enable stencil test and setup stencil mask parameters 191 | render.enable_state(render.STATE_STENCIL_TEST) 192 | render.set_stencil_func(render.COMPARE_FUNC_ALWAYS, 1, 255) 193 | render.set_stencil_op(render.STENCIL_OP_KEEP, render.STENCIL_OP_KEEP, render.STENCIL_OP_REPLACE) 194 | render.set_stencil_mask(255) 195 | 196 | -- 3. Draw the mask 197 | render.set_view(vmath.matrix4()) 198 | render.set_projection(vmath.matrix4()) 199 | render.draw(self.mask_pred) 200 | 201 | -- 4. Update the stencil function to only let pixel pass that are equal to the mask result 202 | render.set_stencil_func(render.COMPARE_FUNC_EQUAL, 1, 255) 203 | 204 | -- 5. Re-enable color drawing 205 | render.set_color_mask(true, true, true, true) 206 | end 207 | 208 | -- 6. Continue as rendering usual! :) 209 | render.enable_state(render.STATE_BLEND) 210 | render.set_blend_func(render.BLEND_SRC_ALPHA, render.BLEND_ONE_MINUS_SRC_ALPHA) 211 | render.disable_state(render.STATE_CULL_FACE) 212 | 213 | 214 | render.set_view(camera_world.view) 215 | -- 216 | render.set_projection(vmath.matrix4_orthographic(0, state.width / camera_world.zoom, 0, state.height / camera_world.zoom, -1, 1)) 217 | --render.set_projection(camera_world.proj) 218 | 219 | -- set states used for all the world predicates 220 | render.set_blend_func(render.BLEND_SRC_ALPHA, render.BLEND_ONE_MINUS_SRC_ALPHA) 221 | render.enable_state(render.STATE_DEPTH_TEST) 222 | 223 | -- render `model` predicate for default 3D material 224 | -- 225 | render.enable_state(render.STATE_CULL_FACE) 226 | render.draw(predicates.model, camera_world.frustum) 227 | render.set_depth_mask(false) 228 | render.disable_state(render.STATE_CULL_FACE) 229 | 230 | -- render the other components: sprites, tilemaps, particles etc 231 | -- 232 | render.enable_state(render.STATE_BLEND) 233 | render.draw(predicates.tile, camera_world.frustum) 234 | render.draw(predicates.particle, camera_world.frustum) 235 | render.disable_state(render.STATE_DEPTH_TEST) 236 | 237 | render.draw_debug3d() 238 | 239 | -- render GUI 240 | -- 241 | local camera_gui = state.cameras.camera_gui 242 | render.set_view(camera_gui.view) 243 | -- Let's use the world camera's projection (as it has the zoom value) 244 | render.set_projection(camera_world.proj) 245 | --render.set_projection(camera_gui.proj) 246 | 247 | render.enable_state(render.STATE_STENCIL_TEST) 248 | render.draw(predicates.gui, camera_gui.frustum) 249 | render.draw(predicates.debug_text, camera_gui.frustum) 250 | render.disable_state(render.STATE_STENCIL_TEST) 251 | render.disable_state(render.STATE_BLEND) 252 | end 253 | 254 | function on_message(self, message_id, message) 255 | local state = self.state 256 | local camera = state.main_camera 257 | if message_id == MSG_CLEAR_COLOR then 258 | update_clear_color(state, message.color) 259 | elseif message_id == MSG_WINDOW_RESIZED then 260 | update_state(state) 261 | elseif message_id == MSG_SET_VIEW_PROJ then 262 | camera.view = message.view 263 | self.camera_projection = message.projection or vmath.matrix4() 264 | update_camera(camera, state) 265 | elseif message_id == MSG_SET_CAMERA_PROJ then 266 | camera.projection_fn = function() return self.camera_projection end 267 | elseif message_id == MSG_USE_STRETCH_PROJ then 268 | init_camera(camera, get_stretch_projection, message.near, message.far) 269 | update_camera(camera, state) 270 | elseif message_id == MSG_USE_FIXED_PROJ then 271 | init_camera(camera, get_fixed_projection, message.near, message.far, message.zoom) 272 | update_camera(camera, state) 273 | elseif message_id == MSG_USE_FIXED_FIT_PROJ then 274 | init_camera(camera, get_fixed_fit_projection, message.near, message.far) 275 | update_camera(camera, state) 276 | end 277 | end 278 | -------------------------------------------------------------------------------- /main/render/screenfade.fp: -------------------------------------------------------------------------------- 1 | varying mediump vec4 position; 2 | varying mediump vec2 var_texcoord0; 3 | 4 | uniform lowp sampler2D DIFFUSE_TEXTURE; 5 | uniform lowp vec4 tint; 6 | uniform lowp vec4 offset; 7 | 8 | void main() 9 | { 10 | vec4 mask_color = texture2D(DIFFUSE_TEXTURE, var_texcoord0.xy); 11 | if ((mask_color.r + offset.r) < 1.0) { 12 | discard; 13 | } 14 | gl_FragColor = mask_color; 15 | } 16 | -------------------------------------------------------------------------------- /main/render/screenfade.material: -------------------------------------------------------------------------------- 1 | name: "screenfade" 2 | tags: "screenfade" 3 | vertex_program: "/main/render/screenfade.vp" 4 | fragment_program: "/main/render/screenfade.fp" 5 | vertex_space: VERTEX_SPACE_WORLD 6 | vertex_constants { 7 | name: "view_proj" 8 | type: CONSTANT_TYPE_VIEWPROJ 9 | } 10 | vertex_constants { 11 | name: "world" 12 | type: CONSTANT_TYPE_WORLD 13 | } 14 | fragment_constants { 15 | name: "tint" 16 | type: CONSTANT_TYPE_USER 17 | value { 18 | x: 1.0 19 | y: 1.0 20 | z: 1.0 21 | w: 1.0 22 | } 23 | } 24 | fragment_constants { 25 | name: "offset" 26 | type: CONSTANT_TYPE_USER 27 | value { 28 | x: 0.0 29 | y: 0.0 30 | z: 0.0 31 | w: 0.0 32 | } 33 | } 34 | samplers { 35 | name: "DIFFUSE_TEXTURE" 36 | wrap_u: WRAP_MODE_REPEAT 37 | wrap_v: WRAP_MODE_REPEAT 38 | filter_min: FILTER_MODE_MIN_NEAREST 39 | filter_mag: FILTER_MODE_MAG_NEAREST 40 | max_anisotropy: 0.0 41 | } 42 | max_page_count: 0 43 | -------------------------------------------------------------------------------- /main/render/screenfade.vp: -------------------------------------------------------------------------------- 1 | uniform mediump mat4 view_proj; 2 | uniform mediump mat4 world; 3 | 4 | attribute mediump vec4 position; 5 | attribute mediump vec2 texcoord0; 6 | 7 | varying mediump vec2 var_texcoord0; 8 | 9 | void main() 10 | { 11 | // NOTE: world isn't used here. Sprite positions are already transformed 12 | // prior to rendering but the world-transform is set for sorting. 13 | gl_Position = view_proj * vec4(position.xyz, 1.0); 14 | var_texcoord0 = texcoord0; 15 | } 16 | -------------------------------------------------------------------------------- /main/screenfade.script: -------------------------------------------------------------------------------- 1 | local FADE_TIME = 1 2 | local FADE_IN_OFFSET = 1 3 | local FADE_OUT_OFFSET = 0 4 | 5 | go.property("offset", 1) 6 | 7 | function init(self) 8 | self.names = { "diagonal", "circle", "circle_2", "stripe_diagonal" } 9 | self.index = 1 10 | self.name = nil 11 | self.component_name = nil 12 | self.texture_name = nil 13 | 14 | set_stencil(self, self.index) 15 | end 16 | 17 | function set_stencil(self, index) 18 | for i, v in ipairs(self.names) do 19 | sprite.set_constant(self.component_name, "offset", vmath.vector4(0, 1, 1, 1)) 20 | end 21 | 22 | self.index = (index - 1) % #self.names + 1 23 | self.name = self.names[self.index] 24 | self.component_name = "#" .. self.name 25 | self.texture_name = "stencil_" .. self.name 26 | 27 | sprite.set_constant(self.component_name, "offset", vmath.vector4(self.offset, 1, 1, 1)) 28 | 29 | --[[ 30 | if self.index == 4 then 31 | msg.post("@system:", "start_record", { file_name = "/Users/mawe/defold_rec.ivf" } ) 32 | print("RECORDING") 33 | end 34 | --]] 35 | end 36 | 37 | function update(self, dt) 38 | sprite.set_constant(self.component_name, "offset", vmath.vector4(self.offset, 1, 1, 1)) 39 | end 40 | 41 | function done(self, url, property) 42 | --[[if self.index == 4 and self.offset == 1 then 43 | msg.post("@system:", "stop_record") 44 | print("STOPPED RECORDING") 45 | end 46 | --]] 47 | end 48 | 49 | function on_message(self, message_id, message, sender) 50 | if message_id == hash("fade_out") then -- hide the game 51 | if self.offset == FADE_IN_OFFSET then 52 | go.animate("#", "offset", go.PLAYBACK_ONCE_FORWARD, FADE_OUT_OFFSET, go.EASING_LINEAR, FADE_TIME, 0, done) 53 | end 54 | 55 | elseif message_id == hash("fade_in") then -- show the game 56 | if self.offset == FADE_OUT_OFFSET then 57 | go.animate("#", "offset", go.PLAYBACK_ONCE_FORWARD, FADE_IN_OFFSET, go.EASING_LINEAR, FADE_TIME, 0, done) 58 | end 59 | 60 | elseif message_id == hash("next_texture") then 61 | set_stencil(self, self.index + 1) 62 | msg.post(sender, "texture_name", {texture=self.texture_name}) 63 | 64 | elseif message_id == hash("prev_texture") then 65 | set_stencil(self, self.index - 1) 66 | msg.post(sender, "texture_name", {texture=self.texture_name}) 67 | 68 | end 69 | end 70 | --------------------------------------------------------------------------------