Browse Source

Adjustments to resolution handling. Fixed bug when attempting to shoot in the verticle. Worked on shader for player body. Attempted to add texture to particle effect.

master
Bryan Miller 4 years ago
parent
commit
cef96c5204
7 changed files with 176 additions and 21 deletions
  1. +3
    -0
      .import/droplet_a.png-8f6c379deb142771389574f34129dfa4.md5
  2. BIN
      .import/droplet_a.png-8f6c379deb142771389574f34129dfa4.stex
  3. BIN
      Data/Graphics/droplet_a.png
  4. +34
    -0
      Data/Graphics/droplet_a.png.import
  5. +128
    -14
      Data/Objects/Player.tscn
  6. +10
    -6
      Data/Scripts/Controller.gd
  7. +1
    -1
      project.godot

+ 3
- 0
.import/droplet_a.png-8f6c379deb142771389574f34129dfa4.md5 View File

source_md5="647815dcbdbd31e343dd6b5c378def1a"
dest_md5="c90de94acc25789d5e4176113897a468"


BIN
.import/droplet_a.png-8f6c379deb142771389574f34129dfa4.stex View File


BIN
Data/Graphics/droplet_a.png View File

Before After
Width: 16  |  Height: 16  |  Size: 1.3KB

+ 34
- 0
Data/Graphics/droplet_a.png.import View File

[remap]

importer="texture"
type="StreamTexture"
path="res://.import/droplet_a.png-8f6c379deb142771389574f34129dfa4.stex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://Data/Graphics/droplet_a.png"
dest_files=[ "res://.import/droplet_a.png-8f6c379deb142771389574f34129dfa4.stex" ]

[params]

compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=false
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=false
svg/scale=1.0

+ 128
- 14
Data/Objects/Player.tscn View File

[gd_scene load_steps=7 format=2]
[gd_scene load_steps=11 format=2]


[ext_resource path="res://Data/Scripts/Controller.gd" type="Script" id=1] [ext_resource path="res://Data/Scripts/Controller.gd" type="Script" id=1]
[ext_resource path="res://Data/Colors/GooGradient.tres" type="Texture" id=2] [ext_resource path="res://Data/Colors/GooGradient.tres" type="Texture" id=2]
[ext_resource path="res://icon.png" type="Texture" id=3]
[ext_resource path="res://Data/Graphics/droplet_a.png" type="Texture" id=4]


[sub_resource type="CircleShape2D" id=1] [sub_resource type="CircleShape2D" id=1]
radius = 16.0


[sub_resource type="Curve" id=4] [sub_resource type="Curve" id=4]
_data = [ Vector2( 0, 1 ), 0.0, 0.219234, 0, 0, Vector2( 1, 0.559091 ), -0.228985, 0.0, 0, 0 ]
_data = [ Vector2( 0, 1 ), 0.0, 0.219234, 0, 0, Vector2( 1, 0.434091 ), -0.228985, 0.0, 0, 0 ]


[sub_resource type="CurveTexture" id=5] [sub_resource type="CurveTexture" id=5]
curve = SubResource( 4 ) curve = SubResource( 4 )


[sub_resource type="ParticlesMaterial" id=6] [sub_resource type="ParticlesMaterial" id=6]
lifetime_randomness = 0.28
lifetime_randomness = 0.52
emission_shape = 1 emission_shape = 1
emission_sphere_radius = 10.0
emission_sphere_radius = 16.0
flag_disable_z = true flag_disable_z = true
gravity = Vector3( 0, 0, 0 )
initial_velocity = 0.25
initial_velocity_random = 1.0
direction = Vector3( 0, 0, 0 )
spread = 0.0
gravity = Vector3( 0, 8, 0 )
orbit_velocity = 0.0 orbit_velocity = 0.0
orbit_velocity_random = 0.0 orbit_velocity_random = 0.0
radial_accel = -10.0
radial_accel_random = 0.54
linear_accel = 10.0
damping = 12.0 damping = 12.0
damping_random = 0.41 damping_random = 0.41
scale = 4.0
angle = 45.0
angle_random = 0.85
scale = 0.75
scale_curve = SubResource( 5 ) scale_curve = SubResource( 5 )
color_ramp = ExtResource( 2 ) color_ramp = ExtResource( 2 )


[sub_resource type="Shader" id=7]
code = "shader_type canvas_item;

uniform float rimWidth : hint_range(1.0, 3.0) = 2.0;
uniform vec4 rim_color : hint_color;
uniform vec4 cell_color : hint_color;
uniform float fisheye_power = 2.0;

vec2 random2(vec2 p){
return fract(sin(vec2(dot(p, vec2(127.1, 311.7)), dot(p, vec2(269.5, 183.3)))) * 43758.5453);
}

float ramp(float v, float f_min, float f_max){
if (v <= f_min){return 0.0;}
if (v >= f_max){return 1.0;}
return (v - f_min) / f_max;
}

float CellularNoise(vec2 vUV, float scale, float time){
// Code modified from...
// https://thebookofshaders.com/12/
vec2 st = vUV * scale;
//st.x = vres.x/vres.y;
vec2 i_st = floor(st);
vec2 f_st = fract(st);
float min_dist = 1.0;
for (int y = -1; y <= 1; y++){
for (int x = -1; x <= 1; x++){
vec2 neighbor = vec2(float(x), float(y));
vec2 point = random2(i_st + neighbor);
point = 0.5 + (0.5 * sin(time + (6.2831 * point)));
float dist = length((neighbor + point) - f_st);
min_dist = min(min_dist, dist);
}
}
return min_dist;
}


vec2 distort(vec2 p) {
// Function borrowed and slightly modified from...
// https://gist.github.com/henriquelalves/989fdd72e10c90091188
p *= 2.0;
p -= vec2(1.0, 1.0);
if (length(p) >= 1.5){return p;}
//return p;
if(p.x > 0.0){
float angle = p.y / p.x;
float theta = atan(angle);
float radius = length(p);
radius = pow(radius, fisheye_power);
p.x = radius * cos(theta);
p.y = radius * sin(theta);
} else {
float angle = p.y / p.x;
float theta = atan(angle);
float radius = length(p);
radius = pow(radius, fisheye_power);
p.y = radius * sin(-theta);
p.x = radius * cos(theta);
p.x = - p.x;
}
return 0.5 * (p + vec2(1.0,1.0));
}


void fragment(){
float n = ramp(CellularNoise(distort(UV.xy), 5.0, TIME), 0.2, 0.9);
float rim = length(vec2(0.5, 0.5) - (UV.xy));
if (rim > 0.5){
rim = 0.0;
}
rim = ramp(pow(rim, rimWidth), 0.0, 0.5);
vec4 color = texture(SCREEN_TEXTURE, SCREEN_UV);
if (rim > 0.0){
color = vec4(cell_color.rgb * n, n);
color = color + vec4(rim_color.rgb * rim, rim);
} else {
color = vec4(color.rgb, 0.0);
}
COLOR = color;
}"

[sub_resource type="ShaderMaterial" id=8]
shader = SubResource( 7 )
shader_param/rimWidth = 1.81
shader_param/rim_color = Color( 0.705882, 0.976471, 0.027451, 1 )
shader_param/cell_color = Color( 0.690196, 0.435294, 0.109804, 1 )
shader_param/fisheye_power = 3.0

[node name="Player" type="RigidBody2D"] [node name="Player" type="RigidBody2D"]
collision_mask = 3 collision_mask = 3
contacts_reported = 1 contacts_reported = 1
script = ExtResource( 1 ) script = ExtResource( 1 )


[node name="CollisionShape2D" type="CollisionShape2D" parent="."] [node name="CollisionShape2D" type="CollisionShape2D" parent="."]
visible = false
shape = SubResource( 1 ) shape = SubResource( 1 )


[node name="Particles" type="Particles2D" parent="."]
amount = 100
process_material = SubResource( 6 )

[node name="Joint" type="PinJoint2D" parent="."] [node name="Joint" type="PinJoint2D" parent="."]
bias = 0.9 bias = 0.9
softness = 0.1 softness = 0.1
[node name="Camera" type="Camera2D" parent="."] [node name="Camera" type="Camera2D" parent="."]
current = true current = true
smoothing_enabled = true smoothing_enabled = true

[node name="Particles" type="Particles2D" parent="."]
visible = false
amount = 50
lifetime = 8.0
local_coords = false
process_material = SubResource( 6 )
texture = ExtResource( 4 )

[node name="Sprite" type="Sprite" parent="."]
material = SubResource( 8 )
scale = Vector2( 0.5, 0.5 )
texture = ExtResource( 3 )
[connection signal="body_entered" from="." to="." method="_on_Player_body_entered"] [connection signal="body_entered" from="." to="." method="_on_Player_body_entered"]
[connection signal="body_exited" from="." to="." method="_on_Player_body_exited"] [connection signal="body_exited" from="." to="." method="_on_Player_body_exited"]

+ 10
- 6
Data/Scripts/Controller.gd View File

export var max_tangential_accel = 32 export var max_tangential_accel = 32
export var max_travel_time = 2.0 export var max_travel_time = 2.0
export var push_force = 128 export var push_force = 128
export var collision_minor_speed_threshold = 16
export var collision_major_speed_threshold = 56
export var collision_minor_speed_threshold = 8
export var collision_major_speed_threshold = 32
export var collision_timedt_threshold = 0.1 export var collision_timedt_threshold = 0.1






var in_air = true var in_air = true
var air_time = 0 var air_time = 0
var last_speed = 0




# Called when the node enters the scene tree for the first time. # Called when the node enters the scene tree for the first time.
if mouse_down: if mouse_down:
return # We don't follow the mouse or move the squiq when mouse is down. return # We don't follow the mouse or move the squiq when mouse is down.
var distance = clamp(mouse_position.x - position.x, -max_distance, max_distance)
var dpercent = distance / max_distance
if push: if push:
push = false push = false
traveling = max_travel_time traveling = max_travel_time
var v_direction = (position - mouse_position).normalized() var v_direction = (position - mouse_position).normalized()
apply_central_impulse(v_direction * abs(dpercent) * push_force)
apply_central_impulse(v_direction * abs(v_direction.length()) * push_force)
elif in_air: elif in_air:
air_time += delta air_time += delta
else: else:
var distance = clamp(mouse_position.x - position.x, -max_distance, max_distance)
var dpercent = distance / max_distance
if abs(distance) > body_radius: if abs(distance) > body_radius:
var v_horizontal = Physics2DServer.area_get_param(get_world_2d().get_space(), Physics2DServer.AREA_PARAM_GRAVITY_VECTOR).rotated(deg2rad(-90)) var v_horizontal = Physics2DServer.area_get_param(get_world_2d().get_space(), Physics2DServer.AREA_PARAM_GRAVITY_VECTOR).rotated(deg2rad(-90))
$Particles.process_material.tangential_accel = dpercent * max_tangential_accel; $Particles.process_material.tangential_accel = dpercent * max_tangential_accel;
else: else:
$Particles.process_material.tangential_accel = 0 $Particles.process_material.tangential_accel = 0
last_speed = linear_velocity.length()
#print(last_speed)




func _process(delta): func _process(delta):


func _on_Player_body_entered(body): func _on_Player_body_entered(body):
in_air = false in_air = false
print(linear_velocity)
#print(linear_velocity)
if air_time > collision_timedt_threshold: if air_time > collision_timedt_threshold:
var lvlen = linear_velocity.length() var lvlen = linear_velocity.length()
if lvlen >= collision_minor_speed_threshold and lvlen < collision_major_speed_threshold: if lvlen >= collision_minor_speed_threshold and lvlen < collision_major_speed_threshold:

+ 1
- 1
project.godot View File

[display] [display]


window/size/width=800 window/size/width=800
window/stretch/mode="viewport"
window/stretch/mode="2d"
window/stretch/aspect="keep" window/stretch/aspect="keep"


[input] [input]

Loading…
Cancel
Save