diff --git a/GUI/HUD.gd b/GUI/HUD.gd index 763a3e8..e68aee9 100644 --- a/GUI/HUD.gd +++ b/GUI/HUD.gd @@ -1,6 +1,7 @@ extends CanvasLayer signal add_currency(amount) +var weapon = "sword" func _on_Add_Currency_pressed() -> void: @@ -33,6 +34,7 @@ func _on_select_bow_pressed() -> void: $'Weapon Selection/Sword'.set_visible(true) $'Weapon Selection'.set_visible(false) + weapon = "bow" return @@ -46,6 +48,7 @@ func _on_select_javelin_pressed() -> void: $'Weapon Selection/Sword'.set_visible(true) $'Weapon Selection'.set_visible(false) + weapon = "javelin" return @@ -59,6 +62,7 @@ func _on_select_staff_pressed() -> void: $'Weapon Selection/Sword'.set_visible(true) $'Weapon Selection'.set_visible(false) + weapon = "staff" return @@ -72,4 +76,5 @@ func _on_select_sword_pressed() -> void: $'Weapon Selection/Staff'.set_visible(true) $'Weapon Selection'.set_visible(false) + weapon = "sword" return diff --git a/GUI/Main Menu.tscn b/GUI/Main Menu.tscn index 9278a89..9b7cfab 100644 --- a/GUI/Main Menu.tscn +++ b/GUI/Main Menu.tscn @@ -127,7 +127,7 @@ texture_hover = ExtResource( 11 ) [node name="BGM" type="AudioStreamPlayer" parent="."] pause_mode = 2 stream = ExtResource( 15 ) -volume_db = -15.0 +volume_db = -12.0 autoplay = true [node name="Menu Button Hover" type="AudioStreamPlayer" parent="."] diff --git a/GUI/Splash Screen.gd b/GUI/Splash Screen.gd index c205b99..af414e3 100644 --- a/GUI/Splash Screen.gd +++ b/GUI/Splash Screen.gd @@ -4,26 +4,26 @@ signal complete func _ready() -> void: - # Fade in - if not $Tween.interpolate_property(self, 'self_modulate:a', 0, 1, 3, Tween.TRANS_LINEAR, Tween.EASE_IN): - print('ERROR: Splash Screen fade in animation has errors.') - if not $Tween.start(): - print('ERROR: Splash Screen fade in animation failed to start.') + # Fade in + if not $Tween.interpolate_property(self, 'self_modulate:a', 0, 1, 3, Tween.TRANS_LINEAR, Tween.EASE_IN): + print('ERROR: Splash Screen fade in animation has errors.') + if not $Tween.start(): + print('ERROR: Splash Screen fade in animation failed to start.') - yield($Tween, 'tween_completed') # Wait for fade in to complete + yield($Tween, 'tween_completed') # Wait for fade in to complete - # Fade out - if not $Tween.interpolate_property(self, 'self_modulate:a', 1, 0, 3, Tween.TRANS_LINEAR, Tween.EASE_OUT, 2): - print('ERROR: Splash Screen fade out animation has errors.') - if not $Tween.start(): - print('ERROR: Splash Screen fade out animation failed to start.') + # Fade out + if not $Tween.interpolate_property(self, 'self_modulate:a', 1, 0, 3, Tween.TRANS_LINEAR, Tween.EASE_OUT, 2): + print('ERROR: Splash Screen fade out animation has errors.') + if not $Tween.start(): + print('ERROR: Splash Screen fade out animation failed to start.') - yield($Tween, 'tween_completed') # Wait for fade out to complete - emit_signal('complete') - return + yield($Tween, 'tween_completed') # Wait for fade out to complete + emit_signal('complete') + return func _input(event: InputEvent) -> void: - if event.is_action_pressed('ui_accept'): - emit_signal('complete') - return + if event.is_action_pressed('ui_accept'): + emit_signal('complete') + return diff --git a/GUI/Splash Screen.tscn b/GUI/Splash Screen.tscn index ba2c4d2..eff9c67 100644 --- a/GUI/Splash Screen.tscn +++ b/GUI/Splash Screen.tscn @@ -14,5 +14,5 @@ script = ExtResource( 2 ) [node name="BGM" type="AudioStreamPlayer" parent="."] stream = ExtResource( 3 ) -volume_db = -15.0 +volume_db = -10.0 autoplay = true diff --git a/Levels/Level 4.tscn b/Levels/Level 4.tscn index 85621ad..8d8dd7f 100644 --- a/Levels/Level 4.tscn +++ b/Levels/Level 4.tscn @@ -101,21 +101,21 @@ tile_data = PoolIntArray( -524290, 0, 5, -524289, 0, 196610, -589824, 0, 196610, [node name="Fire3" type="AnimatedSprite" parent="."] position = Vector2( -607.628, -210.601 ) frames = SubResource( 1 ) -frame = 10 +frame = 9 playing = true offset = Vector2( 679.819, 333.222 ) [node name="Fire2" type="AnimatedSprite" parent="."] position = Vector2( -543.25, -212.563 ) frames = SubResource( 1 ) -frame = 13 +frame = 12 playing = true offset = Vector2( 679.819, 333.222 ) [node name="Fire1" type="AnimatedSprite" parent="."] position = Vector2( -479.806, -214.167 ) frames = SubResource( 1 ) -frame = 6 +frame = 5 playing = true offset = Vector2( 679.819, 333.222 ) @@ -175,28 +175,26 @@ position = Vector2( 290, 273 ) position = Vector2( 35.1075, -101.959 ) scale = Vector2( 0.533564, 0.533564 ) frames = SubResource( 21 ) -frame = 1 playing = true [node name="Chest2" type="AnimatedSprite" parent="."] position = Vector2( 421.5, 34.687 ) scale = Vector2( 0.533564, 0.533564 ) frames = SubResource( 21 ) -frame = 2 +frame = 1 playing = true [node name="Chest3" type="AnimatedSprite" parent="."] position = Vector2( 289.9, 294.945 ) scale = Vector2( 0.533564, 0.533564 ) frames = SubResource( 21 ) -frame = 1 playing = true [node name="Chest4" type="AnimatedSprite" parent="."] position = Vector2( -99.4362, 161.242 ) scale = Vector2( 0.533564, 0.533564 ) frames = SubResource( 21 ) -frame = 2 +frame = 1 playing = true [node name="HUD" parent="." instance=ExtResource( 23 )] diff --git a/Player/Javelin.gd b/Player/Javelin.gd new file mode 100644 index 0000000..0744ed2 --- /dev/null +++ b/Player/Javelin.gd @@ -0,0 +1,26 @@ +extends Node2D + + +# Declare member variables here. Examples: +# var a: int = 2 +# var b: String = "text" + + +# Called when the node enters the scene tree for the first time. +func _ready() -> void: + pass # Replace with function body. + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +#func _process(delta: float) -> void: +# pass + + +func _on_AnimationPlayer_animation_started(anim_name: String) -> void: + $Javelin.visible = true + return + + +func _on_AnimationPlayer_animation_finished(anim_name: String) -> void: + $Javelin.visible = false + return diff --git a/Player/Javelin.tscn b/Player/Javelin.tscn new file mode 100644 index 0000000..ce53291 --- /dev/null +++ b/Player/Javelin.tscn @@ -0,0 +1,63 @@ +[gd_scene load_steps=5 format=2] + +[ext_resource path="res://Sprites/Items/Javelin.png" type="Texture" id=1] +[ext_resource path="res://Player/Javelin.gd" type="Script" id=2] + +[sub_resource type="Animation" id=1] +length = 0.001 +tracks/0/type = "value" +tracks/0/path = NodePath("Javelin:position") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/keys = { +"times": PoolRealArray( 0 ), +"transitions": PoolRealArray( 1 ), +"update": 0, +"values": [ Vector2( 0, 0 ) ] +} +tracks/1/type = "value" +tracks/1/path = NodePath("Javelin:rotation_degrees") +tracks/1/interp = 1 +tracks/1/loop_wrap = true +tracks/1/imported = false +tracks/1/enabled = true +tracks/1/keys = { +"times": PoolRealArray( 0 ), +"transitions": PoolRealArray( 1 ), +"update": 0, +"values": [ 135.0 ] +} + +[sub_resource type="Animation" id=2] +resource_name = "swing" +length = 0.6 +tracks/0/type = "value" +tracks/0/path = NodePath("Javelin:position") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/keys = { +"times": PoolRealArray( 0, 0.1 ), +"transitions": PoolRealArray( 1, 1 ), +"update": 0, +"values": [ Vector2( 0, 0 ), Vector2( 7, 0 ) ] +} + +[node name="JavelinAnimation" type="Node2D"] +script = ExtResource( 2 ) + +[node name="Javelin" type="Sprite" parent="."] +visible = false +rotation = 2.35619 +scale = Vector2( 0.65, 0.65 ) +texture = ExtResource( 1 ) + +[node name="JavelinAttack" type="AnimationPlayer" parent="."] +anims/RESET = SubResource( 1 ) +anims/swing = SubResource( 2 ) + +[connection signal="animation_finished" from="JavelinAttack" to="." method="_on_AnimationPlayer_animation_finished"] +[connection signal="animation_started" from="JavelinAttack" to="." method="_on_AnimationPlayer_animation_started"] diff --git a/Player/Player.gd b/Player/Player.gd index 568b136..4e75cae 100644 --- a/Player/Player.gd +++ b/Player/Player.gd @@ -10,7 +10,6 @@ var health_index: int = 6 var hud: CanvasLayer = null var velocity: Vector2 = Vector2.ZERO - func _physics_process(delta: float) -> void: var input_vector: Vector2 = Vector2.ZERO @@ -23,6 +22,7 @@ func _physics_process(delta: float) -> void: if input_vector != Vector2.ZERO: $AnimationTree.set('parameters/Idle/blend_position', input_vector) velocity = velocity.move_toward(input_vector * MAX_SPEED, ACCELERATION * delta) + set_weapon_position(input_vector) else: velocity = velocity.move_toward(Vector2.ZERO, FRICTION * delta) @@ -39,6 +39,56 @@ func load_hud(node: CanvasLayer) -> void: hud.update_currency($Inventory.get_currency()) return +func set_weapon_position(pos: Vector2) -> void: + if pos[0] < 0: # facing left + $SwordAnimation.position.x = -8 + $SwordAnimation.position.y = -6 + $SwordAnimation.scale.x = -1 + $SwordAnimation.rotation_degrees = 0 + $SwordAnimation.z_index = 0 + + $JavelinAnimation.position.x = -8 + $JavelinAnimation.position.y = -4 + $JavelinAnimation.scale.x = -1 + $JavelinAnimation.rotation_degrees = 0 + $JavelinAnimation.z_index = 0 + elif pos[0] > 0: # facing right + $SwordAnimation.position.x = 8 + $SwordAnimation.position.y = -6 + $SwordAnimation.scale.x = 1 + $SwordAnimation.rotation_degrees = 0 + $SwordAnimation.z_index = 0 + + $JavelinAnimation.position.x = 8 + $JavelinAnimation.position.y = -4 + $JavelinAnimation.scale.x = 1 + $JavelinAnimation.rotation_degrees = 0 + $JavelinAnimation.z_index = 0 + elif pos[1] < 0: # facing up + $SwordAnimation.position.x = -4 + $SwordAnimation.position.y = -12 + $SwordAnimation.scale.x = 1 + $SwordAnimation.rotation_degrees = -90 + $SwordAnimation.z_index = 0 + + $JavelinAnimation.position.x = 0 + $JavelinAnimation.position.y = -10 + $JavelinAnimation.scale.x = 1 + $JavelinAnimation.rotation_degrees = -90 + $JavelinAnimation.z_index = 0 + elif pos[1] > 0: # facing down + $SwordAnimation.position.x = 4 + $SwordAnimation.position.y = 2 + $SwordAnimation.scale.x = 1 + $SwordAnimation.rotation_degrees = 90 + $SwordAnimation.z_index = 1 + + $JavelinAnimation.position.x = 0 + $JavelinAnimation.position.y = 0 + $JavelinAnimation.scale.x = 1 + $JavelinAnimation.rotation_degrees = 90 + $JavelinAnimation.z_index = 1 + return func add_currency(amount: int) -> void: $Inventory.add_currency(amount) @@ -49,7 +99,6 @@ func _on_Inventory_update_currency(amount: int) -> void: hud.update_currency(amount) return - func _on_Hitbox_body_entered(body: Node) -> void: if not 'enemies' in body.get_groups(): return @@ -75,6 +124,10 @@ func _input(event: InputEvent) -> void: print('ERROR: Failed saving screenshot.') if event.is_action_pressed("player_attack"): - $SwordAnimation/SwordAttack.play("swing") + + if hud.weapon == "sword": + $SwordAnimation/SwordAttack.play("swing") + elif hud.weapon == "javelin": + $JavelinAnimation/JavelinAttack.play("swing") return diff --git a/Player/Player.tscn b/Player/Player.tscn index 71959f2..caea234 100644 --- a/Player/Player.tscn +++ b/Player/Player.tscn @@ -1,10 +1,11 @@ -[gd_scene load_steps=21 format=2] +[gd_scene load_steps=22 format=2] [ext_resource path="res://Player/Player.gd" type="Script" id=1] [ext_resource path="res://Sprites/Player/Player.png" type="Texture" id=2] [ext_resource path="res://Sprites/Player/Player_Down.png" type="Texture" id=3] [ext_resource path="res://Sprites/Player/Player_Up.png" type="Texture" id=4] [ext_resource path="res://Player/Inventory.tscn" type="PackedScene" id=5] +[ext_resource path="res://Player/Javelin.tscn" type="PackedScene" id=6] [ext_resource path="res://Player/Sword.tscn" type="PackedScene" id=7] [sub_resource type="SpriteFrames" id=1] @@ -187,6 +188,7 @@ script = ExtResource( 1 ) [node name="Sprite" type="AnimatedSprite" parent="."] light_mask = 2 +z_index = 1 frames = SubResource( 1 ) animation = "look_right" offset = Vector2( 0, -5 ) @@ -224,5 +226,8 @@ parameters/Idle/blend_position = Vector2( 0.0760697, 0 ) [node name="SwordAnimation" parent="." instance=ExtResource( 7 )] position = Vector2( 8, -6 ) +[node name="JavelinAnimation" parent="." instance=ExtResource( 6 )] +position = Vector2( 8, -4 ) + [connection signal="body_entered" from="Hitbox" to="." method="_on_Hitbox_body_entered"] [connection signal="update_currency" from="Inventory" to="." method="_on_Inventory_update_currency"]