Added snowmen damage + music

This commit is contained in:
tiffanyfrias10
2021-11-30 20:16:38 -06:00
parent e8d659ed93
commit 73efc1ffea
22 changed files with 447 additions and 351 deletions

View File

@@ -12,65 +12,86 @@ var velocity: Vector2 = Vector2.ZERO
func _physics_process(delta: float) -> void:
var input_vector: Vector2 = Vector2.ZERO
var input_vector: Vector2 = Vector2.ZERO
input_vector.x = Input.get_action_strength('player_right') \
- Input.get_action_strength('player_left')
input_vector.y = Input.get_action_strength('player_down') \
- Input.get_action_strength('player_up')
input_vector = input_vector.normalized()
input_vector.x = Input.get_action_strength('player_right') \
- Input.get_action_strength('player_left')
input_vector.y = Input.get_action_strength('player_down') \
- Input.get_action_strength('player_up')
input_vector = input_vector.normalized()
if input_vector != Vector2.ZERO:
$AnimationTree.set('parameters/Idle/blend_position', input_vector)
velocity = velocity.move_toward(input_vector * MAX_SPEED, ACCELERATION * delta)
else:
velocity = velocity.move_toward(Vector2.ZERO, FRICTION * delta)
if input_vector != Vector2.ZERO:
$AnimationTree.set('parameters/Idle/blend_position', input_vector)
velocity = velocity.move_toward(input_vector * MAX_SPEED, ACCELERATION * delta)
else:
velocity = velocity.move_toward(Vector2.ZERO, FRICTION * delta)
velocity = move_and_slide(velocity)
return
velocity = move_and_slide(velocity)
return
func load_hud(node: CanvasLayer) -> void:
hud = node
if hud.connect('add_currency', self, 'add_currency') != OK:
print('ERROR: HUD "add_currency" signal already connected.')
hud = node
if hud.connect('add_currency', self, 'add_currency') != OK:
print('ERROR: HUD "add_currency" signal already connected.')
hud.update_health(HEALTH_SLICES[health_index])
hud.update_currency($Inventory.get_currency())
return
hud.update_health(HEALTH_SLICES[health_index])
hud.update_currency($Inventory.get_currency())
return
func add_currency(amount: int) -> void:
$Inventory.add_currency(amount)
return
$Inventory.add_currency(amount)
return
func _on_Inventory_update_currency(amount: int) -> void:
hud.update_currency(amount)
return
hud.update_currency(amount)
return
func _on_Hitbox_body_entered(body: Node) -> void:
if not 'enemies' in body.get_groups():
return
if not 'enemies' in body.get_groups():
return
#var timer = Timer.new()
elif body.name.begins_with("blue_snowman"):
MAX_SPEED = 20
yield(get_tree().create_timer(3.0), "timeout")
MAX_SPEED = 120
if health_index != 0:
health_index -= 1
hud.update_health(HEALTH_SLICES[health_index])
return
else:
health_index != 0
health_index -= 1
hud.update_health(HEALTH_SLICES[health_index])
return
func _input(event: InputEvent) -> void:
if event.is_action_pressed('screenshot'):
var img: Image = get_viewport().get_texture().get_data()
yield(get_tree(), "idle_frame")
yield(get_tree(), "idle_frame")
if event.is_action_pressed('screenshot'):
var img: Image = get_viewport().get_texture().get_data()
yield(get_tree(), "idle_frame")
yield(get_tree(), "idle_frame")
img.flip_y()
img.flip_y()
var time: Dictionary = OS.get_datetime_from_unix_time(OS.get_unix_time())
var time_msecs: int = OS.get_system_time_msecs()
var time: Dictionary = OS.get_datetime_from_unix_time(OS.get_unix_time())
var time_msecs: int = OS.get_system_time_msecs()
if img.save_png('user://Screenshot_%d%d%d_%d.png' % [time.year, time.month, time.day, time_msecs]) != OK:
print('ERROR: Failed saving screenshot.')
return
if img.save_png('user://Screenshot_%d%d%d_%d.png' % [time.year, time.month, time.day, time_msecs]) != OK:
print('ERROR: Failed saving screenshot.')
return
func _on_Hitbox_area_entered(area: Area2D) -> void:
if not 'enemies' in area.get_parent().get_groups() or area.name.begins_with("detection") or (not area.name.begins_with("snowball")) :
return
if area.name.begins_with("snowball"):
print("SNOWBALL FIGHT")
if health_index != 0:
health_index -= 1
hud.update_health(HEALTH_SLICES[health_index])
return

View File

@@ -8,16 +8,6 @@
[sub_resource type="SpriteFrames" id=1]
animations = [ {
"frames": [ ExtResource( 4 ) ],
"loop": false,
"name": "look_up",
"speed": 5.0
}, {
"frames": [ ExtResource( 3 ) ],
"loop": false,
"name": "look_down",
"speed": 5.0
}, {
"frames": [ ExtResource( 2 ) ],
"loop": false,
"name": "look_left",
@@ -27,6 +17,16 @@ animations = [ {
"loop": false,
"name": "look_right",
"speed": 5.0
}, {
"frames": [ ExtResource( 4 ) ],
"loop": false,
"name": "look_up",
"speed": 5.0
}, {
"frames": [ ExtResource( 3 ) ],
"loop": false,
"name": "look_down",
"speed": 5.0
} ]
[sub_resource type="CapsuleShape2D" id=2]
@@ -220,5 +220,6 @@ parameters/Idle/blend_position = Vector2( 0.0760697, 0 )
[node name="Inventory" parent="." instance=ExtResource( 5 )]
[connection signal="area_entered" from="Hitbox" to="." method="_on_Hitbox_area_entered"]
[connection signal="body_entered" from="Hitbox" to="." method="_on_Hitbox_body_entered"]
[connection signal="update_currency" from="Inventory" to="." method="_on_Inventory_update_currency"]