Level Functionality Complete
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
radius = 4.47823
|
||||
|
||||
[node name="snowball_blue" type="Area2D" groups=[
|
||||
"enemy_projectile_1",
|
||||
"freeze",
|
||||
]]
|
||||
collision_layer = 0
|
||||
collision_mask = 2
|
||||
|
@@ -14,7 +14,9 @@ radius = 58.0175
|
||||
radius = 6.0
|
||||
height = 5.0
|
||||
|
||||
[node name="snowmen_enemy" type="KinematicBody2D"]
|
||||
[node name="snowmen_enemy" type="KinematicBody2D" groups=[
|
||||
"freeze",
|
||||
]]
|
||||
collision_layer = 2
|
||||
script = ExtResource( 2 )
|
||||
|
||||
@@ -38,7 +40,7 @@ shape = SubResource( 2 )
|
||||
autostart = true
|
||||
|
||||
[node name="hitbox" type="Area2D" parent="." groups=[
|
||||
"enemy_hitbox_1",
|
||||
"freeze",
|
||||
]]
|
||||
collision_layer = 4
|
||||
collision_mask = 2
|
||||
@@ -49,3 +51,4 @@ shape = SubResource( 3 )
|
||||
[connection signal="body_entered" from="detection" to="." method="_on_Area2D_body_entered"]
|
||||
[connection signal="body_exited" from="detection" to="." method="_on_Area2D_body_exited"]
|
||||
[connection signal="timeout" from="Timer" to="." method="_on_Timer_timeout"]
|
||||
[connection signal="area_entered" from="hitbox" to="." method="_on_hitbox_area_entered"]
|
||||
|
@@ -14,7 +14,9 @@ radius = 56.0659
|
||||
radius = 6.0
|
||||
height = 5.0
|
||||
|
||||
[node name="snowmen_enemy" type="KinematicBody2D"]
|
||||
[node name="snowmen_enemy" type="KinematicBody2D" groups=[
|
||||
"enemy",
|
||||
]]
|
||||
collision_layer = 2
|
||||
script = ExtResource( 2 )
|
||||
|
||||
@@ -50,3 +52,4 @@ shape = SubResource( 3 )
|
||||
[connection signal="body_entered" from="detection" to="." method="_on_Area2D_body_entered"]
|
||||
[connection signal="body_exited" from="detection" to="." method="_on_Area2D_body_exited"]
|
||||
[connection signal="timeout" from="Timer" to="." method="_on_Timer_timeout"]
|
||||
[connection signal="area_entered" from="hitbox" to="." method="_on_hitbox_area_entered"]
|
||||
|
File diff suppressed because one or more lines are too long
34
Levels/SlowTime.gd
Normal file
34
Levels/SlowTime.gd
Normal file
@@ -0,0 +1,34 @@
|
||||
extends Node
|
||||
|
||||
const END_VALUE = 1
|
||||
|
||||
signal unfreeze
|
||||
|
||||
var is_active = false
|
||||
var time_start
|
||||
var duration_ms
|
||||
var start_value
|
||||
|
||||
|
||||
|
||||
func start(duration = 1, strength = 0.9):
|
||||
time_start = OS.get_ticks_msec()
|
||||
duration_ms = duration * 1000
|
||||
start_value = 1 - strength
|
||||
Engine.time_scale = start_value
|
||||
is_active = true
|
||||
|
||||
|
||||
func _process(delta):
|
||||
if is_active:
|
||||
var current_time = OS.get_ticks_msec() - time_start
|
||||
var value = circl_ease_in(current_time, start_value, END_VALUE, duration_ms)
|
||||
if current_time >= duration_ms:
|
||||
is_active = false
|
||||
value = END_VALUE
|
||||
emit_signal('unfreeze')
|
||||
Engine.time_scale = value
|
||||
|
||||
func circl_ease_in(t, b, c, d):
|
||||
t /=d
|
||||
return -c * (sqrt(1 - t * t) - 1) + b
|
@@ -3,6 +3,8 @@ extends KinematicBody2D
|
||||
export var ACCELERATION: int = 1000
|
||||
export var MAX_SPEED: int = 120
|
||||
export var FRICTION: int = 1000
|
||||
signal frozen
|
||||
|
||||
|
||||
const HEALTH_SLICES: Array = [0, 18, 35, 50, 65, 82, 100]
|
||||
var health_index: int = 6
|
||||
@@ -104,6 +106,9 @@ func _on_hitbox_area_entered(area: Area2D) -> void:
|
||||
hit = 2
|
||||
elif area.is_in_group('enemy_hitbox_3') or area.is_in_group('enemy_projectile_3'):
|
||||
hit = 3
|
||||
elif area.is_in_group('freeze'):
|
||||
emit_signal('frozen')
|
||||
modulate = Color(0,.5,1)
|
||||
else:
|
||||
return
|
||||
#var timer = Timer.new()
|
||||
@@ -151,12 +156,13 @@ func _input(event: InputEvent) -> void:
|
||||
func _on_Hitbox_area_entered(area: Area2D) -> void:
|
||||
print(area.name)
|
||||
|
||||
if area.name.begins_with("coin"):
|
||||
print("COIN")
|
||||
|
||||
if area.name == 'detection':
|
||||
return
|
||||
|
||||
if 'freeze' in area.get_parent().get_groups():
|
||||
emit_signal('frozen')
|
||||
return
|
||||
|
||||
if 'enemies' in area.get_parent().get_groups() or area.name != 'detection' or 'damage' in area.get_groups():
|
||||
if health_index != 0:
|
||||
health_index -= 1
|
||||
@@ -164,3 +170,7 @@ func _on_Hitbox_area_entered(area: Area2D) -> void:
|
||||
else:
|
||||
get_tree().change_scene('res://Levels/Hub World.tscn')
|
||||
return
|
||||
|
||||
|
||||
func _on_SlowTime_unfreeze() -> void:
|
||||
modulate = Color(1,1,1)
|
||||
|
@@ -182,7 +182,9 @@ graph_offset = Vector2( -3591.37, -302.6 )
|
||||
|
||||
[sub_resource type="AnimationNodeStateMachinePlayback" id=14]
|
||||
|
||||
[node name="Player" type="KinematicBody2D" groups=["player"]]
|
||||
[node name="Player" type="KinematicBody2D" groups=[
|
||||
"player",
|
||||
]]
|
||||
collision_layer = 2
|
||||
script = ExtResource( 1 )
|
||||
|
||||
@@ -198,10 +200,12 @@ visible = false
|
||||
rotation = 1.5708
|
||||
shape = SubResource( 2 )
|
||||
|
||||
[node name="Hitbox" type="Area2D" parent="." groups=["player_hitbox"]]
|
||||
[node name="Hitbox" type="Area2D" parent="." groups=[
|
||||
"player_hitbox",
|
||||
]]
|
||||
input_pickable = false
|
||||
collision_layer = 2
|
||||
collision_mask = 4
|
||||
input_pickable = false
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Hitbox"]
|
||||
visible = false
|
||||
|
Reference in New Issue
Block a user