slowtrail
This commit is contained in:
parent
afa8f09aaf
commit
25598c1b76
BIN
Assets/BigPlaceholder.png
Normal file
BIN
Assets/BigPlaceholder.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 236 B |
34
Assets/BigPlaceholder.png.import
Normal file
34
Assets/BigPlaceholder.png.import
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="StreamTexture"
|
||||||
|
path="res://.import/BigPlaceholder.png-9c0a4f83e393ffb882dc587d443d0c12.stex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://Assets/BigPlaceholder.png"
|
||||||
|
dest_files=[ "res://.import/BigPlaceholder.png-9c0a4f83e393ffb882dc587d443d0c12.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
|
||||||
@ -208,8 +208,11 @@ _data = {
|
|||||||
"points": PoolVector2Array( -15.7724, -10.548, 15.7724, 10.548, 79.9353, -88.996, 8.91483, -9.7366, -8.91483, 9.7366, 75.135, -62.2204, 10.2863, 13.7935, -10.2863, -13.7935, -33.2145, -63.0318, -10.2863, 9.7366, 10.2863, -9.7366, -16.7564, -88.1847, -14.4009, 13.7935, 14.4009, -13.7935, -16.7564, -88.996, -6.85756, -19.4732, 6.85756, 19.4732, 79.9353, -88.996 )
|
"points": PoolVector2Array( -15.7724, -10.548, 15.7724, 10.548, 79.9353, -88.996, 8.91483, -9.7366, -8.91483, 9.7366, 75.135, -62.2204, 10.2863, 13.7935, -10.2863, -13.7935, -33.2145, -63.0318, -10.2863, 9.7366, 10.2863, -9.7366, -16.7564, -88.1847, -14.4009, 13.7935, 14.4009, -13.7935, -16.7564, -88.996, -6.85756, -19.4732, 6.85756, 19.4732, 79.9353, -88.996 )
|
||||||
}
|
}
|
||||||
|
|
||||||
[node name="KinematicBody2D" type="KinematicBody2D"]
|
[node name="KinematicBody2D" type="KinematicBody2D" groups=[
|
||||||
|
"Player",
|
||||||
|
]]
|
||||||
script = ExtResource( 2 )
|
script = ExtResource( 2 )
|
||||||
|
slow_cooldown = 3
|
||||||
|
|
||||||
[node name="Sprite" type="Sprite" parent="."]
|
[node name="Sprite" type="Sprite" parent="."]
|
||||||
texture = ExtResource( 1 )
|
texture = ExtResource( 1 )
|
||||||
@ -254,6 +257,7 @@ rotate = false
|
|||||||
position = Vector2( 0.823479, -2.89215 )
|
position = Vector2( 0.823479, -2.89215 )
|
||||||
rotation = -0.639347
|
rotation = -0.639347
|
||||||
scale = Vector2( 1.1136, 1.2906 )
|
scale = Vector2( 1.1136, 1.2906 )
|
||||||
|
z_index = -1
|
||||||
texture = ExtResource( 3 )
|
texture = ExtResource( 3 )
|
||||||
|
|
||||||
[node name="PathFollow2D2" type="PathFollow2D" parent="ConfusionStars/Path2D"]
|
[node name="PathFollow2D2" type="PathFollow2D" parent="ConfusionStars/Path2D"]
|
||||||
@ -266,4 +270,5 @@ rotate = false
|
|||||||
position = Vector2( 0.823479, -2.89215 )
|
position = Vector2( 0.823479, -2.89215 )
|
||||||
rotation = -0.639347
|
rotation = -0.639347
|
||||||
scale = Vector2( 1.1136, 1.2906 )
|
scale = Vector2( 1.1136, 1.2906 )
|
||||||
|
z_index = -1
|
||||||
texture = ExtResource( 3 )
|
texture = ExtResource( 3 )
|
||||||
|
|||||||
21
Scene/SlowTrail.tscn
Normal file
21
Scene/SlowTrail.tscn
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
[gd_scene load_steps=4 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://Assets/BigPlaceholder.png" type="Texture" id=1]
|
||||||
|
[ext_resource path="res://Scripts/SlowTrail.gd" type="Script" id=2]
|
||||||
|
|
||||||
|
[sub_resource type="RectangleShape2D" id=1]
|
||||||
|
extents = Vector2( 88.8117, 26.2111 )
|
||||||
|
|
||||||
|
[node name="SlowTrail" type="Node2D"]
|
||||||
|
rotation = -6.28319
|
||||||
|
script = ExtResource( 2 )
|
||||||
|
|
||||||
|
[node name="Sprite" type="Sprite" parent="."]
|
||||||
|
z_index = 10
|
||||||
|
texture = ExtResource( 1 )
|
||||||
|
offset = Vector2( 88, 0 )
|
||||||
|
|
||||||
|
[node name="Area2D" type="Area2D" parent="Sprite"]
|
||||||
|
|
||||||
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="Sprite/Area2D"]
|
||||||
|
shape = SubResource( 1 )
|
||||||
@ -6,11 +6,17 @@ var FRICTION = 2000
|
|||||||
var MAX_LIFE = 30
|
var MAX_LIFE = 30
|
||||||
const PICKUP_BONUS = 5
|
const PICKUP_BONUS = 5
|
||||||
export var rota_speed = 100
|
export var rota_speed = 100
|
||||||
|
export var slow_cooldown = 5
|
||||||
|
|
||||||
|
var slow_trail = load("res://Scene/SlowPaint.tscn")
|
||||||
|
|
||||||
|
var slow_cooldown_elapsed = 5
|
||||||
|
|
||||||
var follow1;
|
var follow1;
|
||||||
var follow2;
|
var follow2;
|
||||||
|
|
||||||
var vel = Vector2.ZERO
|
var vel = Vector2.ZERO
|
||||||
|
var last_dir = Vector2.ZERO
|
||||||
var curLife = MAX_LIFE
|
var curLife = MAX_LIFE
|
||||||
|
|
||||||
var coroutines = []
|
var coroutines = []
|
||||||
@ -40,16 +46,40 @@ func _ready():
|
|||||||
healthBar = get_tree().get_nodes_in_group("healthbar")[1]
|
healthBar = get_tree().get_nodes_in_group("healthbar")[1]
|
||||||
healthBar.maxHealthUpdated(MAX_LIFE)
|
healthBar.maxHealthUpdated(MAX_LIFE)
|
||||||
|
|
||||||
|
func launch_slow():
|
||||||
|
if slow_cooldown_elapsed < slow_cooldown:
|
||||||
|
return
|
||||||
|
slow_cooldown_elapsed = 0
|
||||||
|
var world = get_parent()
|
||||||
|
var inst = load("res://Scene/SlowTrail.tscn").instance()
|
||||||
|
var dir = get_dir()
|
||||||
|
if dir == Vector2.ZERO:
|
||||||
|
dir = (last_dir if last_dir != Vector2.ZERO else Vector2.DOWN)
|
||||||
|
var angle = acos(dir.dot(Vector2.RIGHT))
|
||||||
|
var modifier = 0
|
||||||
|
if dir.y < 0:
|
||||||
|
modifier += angle * -2
|
||||||
|
inst.transform = inst.transform.rotated(angle + modifier)
|
||||||
|
inst.position = self.position
|
||||||
|
inst.slowFactor = 2
|
||||||
|
world.add_child(inst)
|
||||||
|
|
||||||
func _process(delta):
|
func _process(delta):
|
||||||
follow1.set_offset(follow1.get_offset() + delta * rota_speed)
|
follow1.set_offset(follow1.get_offset() + delta * rota_speed)
|
||||||
follow2.set_offset(follow2.get_offset() + delta * rota_speed)
|
follow2.set_offset(follow2.get_offset() + delta * rota_speed)
|
||||||
|
|
||||||
|
if (self.name == "Player1" && Input.get_action_strength("gameplay_slow") > 0) \
|
||||||
|
|| (self.name == "Player2" && Input.get_action_strength("gameplay_slow2") > 0):
|
||||||
|
launch_slow()
|
||||||
|
|
||||||
updatePaintEffects(delta)
|
updatePaintEffects(delta)
|
||||||
curLife -= delta
|
curLife -= delta
|
||||||
|
slow_cooldown_elapsed += delta
|
||||||
if curLife <= 0:
|
if curLife <= 0:
|
||||||
get_node("/root/World/GameManager").endGame()
|
get_node("/root/World/GameManager").endGame()
|
||||||
healthBar.healthUpdated(curLife)
|
healthBar.healthUpdated(curLife)
|
||||||
|
|
||||||
func _physics_process(delta):
|
func get_dir():
|
||||||
var input_vector = Vector2.ZERO
|
var input_vector = Vector2.ZERO
|
||||||
|
|
||||||
if self.name == "Player1":
|
if self.name == "Player1":
|
||||||
@ -60,8 +90,13 @@ func _physics_process(delta):
|
|||||||
input_vector.y = Input.get_action_strength(inputs[EInput.DOWN] + "2") - Input.get_action_strength(inputs[EInput.UP] + "2")
|
input_vector.y = Input.get_action_strength(inputs[EInput.DOWN] + "2") - Input.get_action_strength(inputs[EInput.UP] + "2")
|
||||||
|
|
||||||
input_vector = input_vector.normalized()
|
input_vector = input_vector.normalized()
|
||||||
|
return input_vector
|
||||||
|
|
||||||
|
func _physics_process(delta):
|
||||||
|
var input_vector = get_dir()
|
||||||
|
|
||||||
if input_vector != Vector2.ZERO:
|
if input_vector != Vector2.ZERO:
|
||||||
|
last_dir = input_vector
|
||||||
animationTree.set("parameters/Idle/blend_position", input_vector)
|
animationTree.set("parameters/Idle/blend_position", input_vector)
|
||||||
animationTree.set("parameters/Run/blend_position", input_vector)
|
animationTree.set("parameters/Run/blend_position", input_vector)
|
||||||
animationState.travel("Run")
|
animationState.travel("Run")
|
||||||
@ -72,7 +107,6 @@ func _physics_process(delta):
|
|||||||
|
|
||||||
vel = move_and_slide(vel)
|
vel = move_and_slide(vel)
|
||||||
|
|
||||||
|
|
||||||
func updatePaintEffects(delta):
|
func updatePaintEffects(delta):
|
||||||
var updated = []
|
var updated = []
|
||||||
for rout in coroutines:
|
for rout in coroutines:
|
||||||
|
|||||||
27
Scripts/SlowTrail.gd
Normal file
27
Scripts/SlowTrail.gd
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
extends Node
|
||||||
|
|
||||||
|
var slowFactor
|
||||||
|
var lifetime = 5
|
||||||
|
var elapsed = 0
|
||||||
|
var sprite
|
||||||
|
|
||||||
|
func slow_player(victim):
|
||||||
|
if victim.is_in_group("Player"):
|
||||||
|
victim.MAX_SPEED /= slowFactor
|
||||||
|
|
||||||
|
func unslow_player(victim):
|
||||||
|
if victim.is_in_group("Player"):
|
||||||
|
victim.MAX_SPEED *= slowFactor
|
||||||
|
|
||||||
|
# Called when the node enters the scene tree for the first time.
|
||||||
|
func _ready():
|
||||||
|
sprite = get_node("Sprite")
|
||||||
|
get_node("Sprite/Area2D").connect("body_entered", self, "slow_player")
|
||||||
|
get_node("Sprite/Area2D").connect("body_exited", self, "unslow_player")
|
||||||
|
|
||||||
|
func _process(delta):
|
||||||
|
elapsed += delta
|
||||||
|
if elapsed >= lifetime * 0.7:
|
||||||
|
sprite.self_modulate = Color(1,1,1,lerp(1, 0, (elapsed - lifetime * 0.7) / (lifetime * 0.3)))
|
||||||
|
if elapsed >= lifetime:
|
||||||
|
queue_free()
|
||||||
@ -115,6 +115,30 @@ pause={
|
|||||||
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777217,"unicode":0,"echo":false,"script":null)
|
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777217,"unicode":0,"echo":false,"script":null)
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
gameplay_slow={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777220,"unicode":0,"echo":false,"script":null)
|
||||||
|
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":2,"pressure":0.0,"pressed":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
gameplay_slow2={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":69,"unicode":0,"echo":false,"script":null)
|
||||||
|
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":1,"button_index":2,"pressure":0.0,"pressed":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
gameplay_fast={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777221,"unicode":0,"echo":false,"script":null)
|
||||||
|
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":0,"pressure":0.0,"pressed":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
gameplay_fast2={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":65,"unicode":0,"echo":false,"script":null)
|
||||||
|
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":1,"button_index":0,"pressure":0.0,"pressed":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
[rendering]
|
[rendering]
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user