Level Functionality Complete

This commit is contained in:
tiffanyfrias10
2021-12-06 19:25:29 -06:00
parent f774ea1741
commit 8d119ff0c9
7 changed files with 85 additions and 23 deletions

View File

@@ -7,7 +7,7 @@
radius = 4.47823 radius = 4.47823
[node name="snowball_blue" type="Area2D" groups=[ [node name="snowball_blue" type="Area2D" groups=[
"enemy_projectile_1", "freeze",
]] ]]
collision_layer = 0 collision_layer = 0
collision_mask = 2 collision_mask = 2

View File

@@ -14,7 +14,9 @@ radius = 58.0175
radius = 6.0 radius = 6.0
height = 5.0 height = 5.0
[node name="snowmen_enemy" type="KinematicBody2D"] [node name="snowmen_enemy" type="KinematicBody2D" groups=[
"freeze",
]]
collision_layer = 2 collision_layer = 2
script = ExtResource( 2 ) script = ExtResource( 2 )
@@ -38,7 +40,7 @@ shape = SubResource( 2 )
autostart = true autostart = true
[node name="hitbox" type="Area2D" parent="." groups=[ [node name="hitbox" type="Area2D" parent="." groups=[
"enemy_hitbox_1", "freeze",
]] ]]
collision_layer = 4 collision_layer = 4
collision_mask = 2 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_entered" from="detection" to="." method="_on_Area2D_body_entered"]
[connection signal="body_exited" from="detection" to="." method="_on_Area2D_body_exited"] [connection signal="body_exited" from="detection" to="." method="_on_Area2D_body_exited"]
[connection signal="timeout" from="Timer" to="." method="_on_Timer_timeout"] [connection signal="timeout" from="Timer" to="." method="_on_Timer_timeout"]
[connection signal="area_entered" from="hitbox" to="." method="_on_hitbox_area_entered"]

View File

@@ -14,7 +14,9 @@ radius = 56.0659
radius = 6.0 radius = 6.0
height = 5.0 height = 5.0
[node name="snowmen_enemy" type="KinematicBody2D"] [node name="snowmen_enemy" type="KinematicBody2D" groups=[
"enemy",
]]
collision_layer = 2 collision_layer = 2
script = ExtResource( 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_entered" from="detection" to="." method="_on_Area2D_body_entered"]
[connection signal="body_exited" from="detection" to="." method="_on_Area2D_body_exited"] [connection signal="body_exited" from="detection" to="." method="_on_Area2D_body_exited"]
[connection signal="timeout" from="Timer" to="." method="_on_Timer_timeout"] [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
View 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

View File

@@ -3,6 +3,8 @@ extends KinematicBody2D
export var ACCELERATION: int = 1000 export var ACCELERATION: int = 1000
export var MAX_SPEED: int = 120 export var MAX_SPEED: int = 120
export var FRICTION: int = 1000 export var FRICTION: int = 1000
signal frozen
const HEALTH_SLICES: Array = [0, 18, 35, 50, 65, 82, 100] const HEALTH_SLICES: Array = [0, 18, 35, 50, 65, 82, 100]
var health_index: int = 6 var health_index: int = 6
@@ -104,6 +106,9 @@ func _on_hitbox_area_entered(area: Area2D) -> void:
hit = 2 hit = 2
elif area.is_in_group('enemy_hitbox_3') or area.is_in_group('enemy_projectile_3'): elif area.is_in_group('enemy_hitbox_3') or area.is_in_group('enemy_projectile_3'):
hit = 3 hit = 3
elif area.is_in_group('freeze'):
emit_signal('frozen')
modulate = Color(0,.5,1)
else: else:
return return
#var timer = Timer.new() #var timer = Timer.new()
@@ -151,11 +156,12 @@ func _input(event: InputEvent) -> void:
func _on_Hitbox_area_entered(area: Area2D) -> void: func _on_Hitbox_area_entered(area: Area2D) -> void:
print(area.name) print(area.name)
if area.name.begins_with("coin"):
print("COIN")
if area.name == 'detection': if area.name == 'detection':
return 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 'enemies' in area.get_parent().get_groups() or area.name != 'detection' or 'damage' in area.get_groups():
if health_index != 0: if health_index != 0:
@@ -164,3 +170,7 @@ func _on_Hitbox_area_entered(area: Area2D) -> void:
else: else:
get_tree().change_scene('res://Levels/Hub World.tscn') get_tree().change_scene('res://Levels/Hub World.tscn')
return return
func _on_SlowTime_unfreeze() -> void:
modulate = Color(1,1,1)

View File

@@ -182,7 +182,9 @@ graph_offset = Vector2( -3591.37, -302.6 )
[sub_resource type="AnimationNodeStateMachinePlayback" id=14] [sub_resource type="AnimationNodeStateMachinePlayback" id=14]
[node name="Player" type="KinematicBody2D" groups=["player"]] [node name="Player" type="KinematicBody2D" groups=[
"player",
]]
collision_layer = 2 collision_layer = 2
script = ExtResource( 1 ) script = ExtResource( 1 )
@@ -198,10 +200,12 @@ visible = false
rotation = 1.5708 rotation = 1.5708
shape = SubResource( 2 ) 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_layer = 2
collision_mask = 4 collision_mask = 4
input_pickable = false
[node name="CollisionShape2D" type="CollisionShape2D" parent="Hitbox"] [node name="CollisionShape2D" type="CollisionShape2D" parent="Hitbox"]
visible = false visible = false