Created
July 16, 2017 11:27
-
-
Save securas/64e059f21af6e0b439f766132dffd931 to your computer and use it in GitHub Desktop.
Glass Bubbles (Texscreen)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extends Control | |
# Member variables | |
const MAX_BUBBLES = 10 | |
func _ready(): | |
for i in range(MAX_BUBBLES): | |
var bubble = preload("res://lens.tscn").instance() | |
add_child(bubble) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[gd_scene load_steps=3 format=1] | |
[ext_resource path="res://bubbles.gd" type="Script" id=1] | |
[ext_resource path="res://burano.png" type="Texture" id=2] | |
[node name="texscreen_demo" type="Control"] | |
anchor/right = 1 | |
anchor/bottom = 1 | |
focus/ignore_mouse = false | |
focus/stop_mouse = true | |
size_flags/horizontal = 2 | |
size_flags/vertical = 2 | |
margin/left = 0.0 | |
margin/top = 0.0 | |
margin/right = 0.0 | |
margin/bottom = 0.0 | |
script/script = ExtResource( 1 ) | |
[node name="burano" type="TextureFrame" parent="."] | |
focus/ignore_mouse = true | |
focus/stop_mouse = true | |
size_flags/horizontal = 2 | |
size_flags/vertical = 2 | |
margin/left = 0.0 | |
margin/top = 0.0 | |
margin/right = 800.0 | |
margin/bottom = 600.0 | |
texture = ExtResource( 2 ) | |
stretch_mode = 0 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[application] | |
name="Glass Bubbles (Texscreen)" | |
main_scene="res://bubbles.tscn" | |
icon="res://icon.png" | |
[display] | |
width=800 | |
height=600 | |
stretch_mode="2d" | |
stretch_aspect="keep" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extends BackBufferCopy | |
# Member variables | |
const MOTION_SPEED = 150 | |
var vsize | |
var dir | |
func _process(delta): | |
var pos = get_pos() + dir*delta*MOTION_SPEED | |
if (pos.x < 0): | |
dir.x = abs(dir.x) | |
elif (pos.x > vsize.x): | |
dir.x = -abs(dir.x) | |
if (pos.y < 0): | |
dir.y = abs(dir.y) | |
elif (pos.y > vsize.y): | |
dir.y = -abs(dir.y) | |
set_pos(pos) | |
func _ready(): | |
vsize = get_viewport_rect().size | |
var pos = vsize*Vector2(randf(), randf()) | |
set_pos(pos) | |
dir = Vector2(randf()*2.0 - 1, randf()*2.0 - 1).normalized() | |
set_process(true) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[gd_scene load_steps=5 format=1] | |
[ext_resource path="res://lens.gd" type="Script" id=1] | |
[ext_resource path="res://bubble.png" type="Texture" id=2] | |
[sub_resource type="CanvasItemShader" id=1] | |
_code = { | |
"fragment": "vec4 normal = tex(TEXTURE,UV); | |
vec2 offset = normal.xy * 2.0 - vec2(1.0); | |
COLOR.rgb=texscreen(SCREEN_UV+offset*0.03); | |
COLOR.a=normal.a; | |
COLOR.rgb*=vec3(1.0,0.8,0.7); | |
", | |
"fragment_ofs": 0, | |
"light": "", | |
"light_ofs": 0, | |
"vertex": "", | |
"vertex_ofs": 0 | |
} | |
[sub_resource type="CanvasItemMaterial" id=2] | |
shader/shader = SubResource( 1 ) | |
shader/shading_mode = 0 | |
[node name="glass" type="BackBufferCopy"] | |
transform/pos = Vector2( 482.908, 346.807 ) | |
transform/scale = Vector2( 1.31289, 1.34009 ) | |
copy_mode = 1 | |
rect = Rect2( -100, -100, 200, 200 ) | |
script/script = ExtResource( 1 ) | |
[node name="lens" type="Sprite" parent="."] | |
material/material = SubResource( 2 ) | |
transform/pos = Vector2( 1.6427, -2.90363 ) | |
texture = ExtResource( 2 ) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment