diff --git a/project.godot b/project.godot index da358b6..8a275f5 100644 --- a/project.godot +++ b/project.godot @@ -12,7 +12,7 @@ config_version=5 config/name="Facsimile Wing" run/main_scene="uid://bj4fytc3sy482" -config/features=PackedStringArray("4.6", "Forward Plus") +config/features=PackedStringArray("4.7", "Forward Plus") config/icon="res://icon.svg" [display] @@ -52,6 +52,11 @@ shoot={ "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":32,"key_label":0,"unicode":32,"location":0,"echo":false,"script":null) ] } +cycle={ +"deadzone": 0.2, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194306,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) +] +} [physics] diff --git a/scenes/player.gd b/scenes/player.gd index 6439eb4..f61a309 100644 --- a/scenes/player.gd +++ b/scenes/player.gd @@ -20,7 +20,7 @@ var ship_displacement: float var travel: float = 0 func _ready() -> void: - + ## Set initial start position position = Vector2(screensize.x / 2, screensize.y - 45) @@ -37,12 +37,16 @@ func _process(delta) -> void: if is_shooting == true: shoot_component.shoot() $%MuzzleFlash.show() - + if is_shooting == false: $%MuzzleFlash.hide() - - + + # Read Movement Component movement_component.input = input_component.move_dir movement_component.tick(delta) + + # Cycle weapon (testing key) + if input_component.cycle_weapon: + weapon_component.cycle_weapon() diff --git a/scenes/player.tscn b/scenes/player.tscn index e60f549..c8b82bf 100644 --- a/scenes/player.tscn +++ b/scenes/player.tscn @@ -8,6 +8,9 @@ [ext_resource type="Script" uid="uid://c0rikbakpcags" path="res://scripts/movement_component.gd" id="5_ur7pv"] [ext_resource type="Script" uid="uid://suynuijl68qp" path="res://scripts/shoot_component.gd" id="6_y4r1p"] [ext_resource type="Script" uid="uid://ylmao2ndp22y" path="res://scripts/weapon_component.gd" id="7_d2wvv"] +[ext_resource type="Resource" uid="uid://b75ae840k03dy" path="res://resources/player_weapon_resources/weapon_shot_stock.tres" id="8_stock"] +[ext_resource type="Resource" uid="uid://bhc6aja38vyr" path="res://resources/player_weapon_resources/weapon_shot_spread.tres" id="9_ur7pv"] +[ext_resource type="Script" uid="uid://7n1itonn35fm" path="res://resources/player_weapon_resources/weapon_shot.gd" id="10_d2wvv"] [sub_resource type="AtlasTexture" id="AtlasTexture_tuyoq"] atlas = ExtResource("5_qlg0r") @@ -34,7 +37,7 @@ animations = [{ "duration": 1.0, "texture": SubResource("AtlasTexture_fjrip") }], -"loop": true, +"loop": 1, "name": &"banked", "speed": 15.0 }, { @@ -45,7 +48,7 @@ animations = [{ "duration": 1.0, "texture": SubResource("AtlasTexture_ur7pv") }], -"loop": true, +"loop": 1, "name": &"fwd", "speed": 15.0 }] @@ -74,7 +77,7 @@ animations = [{ "duration": 1.0, "texture": SubResource("AtlasTexture_d2wvv") }], -"loop": true, +"loop": 1, "name": &"stock", "speed": 15.0 }] @@ -90,9 +93,6 @@ size = Vector2(6, 5.75) [node name="Player" type="Area2D" unique_id=652131079] script = ExtResource("1_ur7pv") -can_shoot = null -is_shooting = null -muzzle_flash = null [node name="Ship" type="Sprite2D" parent="." unique_id=1155866924] unique_name_in_owner = true @@ -148,11 +148,12 @@ metadata/_custom_type_script = "uid://c0rikbakpcags" [node name="ShootComponent" type="Node" parent="." unique_id=623642425] unique_name_in_owner = true script = ExtResource("6_y4r1p") -metadata/_custom_type_script = "uid://bgd1hwindc2ui" [node name="WeaponComponent" type="Node" parent="." unique_id=1648685183] unique_name_in_owner = true script = ExtResource("7_d2wvv") +weapon_data = ExtResource("9_ur7pv") +available_weapons = Array[ExtResource("10_d2wvv")]([ExtResource("8_stock"), ExtResource("9_ur7pv")]) metadata/_custom_type_script = "uid://ylmao2ndp22y" [connection signal="timeout" from="WeaponCooldown" to="." method="_on_weapon_cooldown_timeout"] diff --git a/scripts/input_component.gd b/scripts/input_component.gd index 83131e6..f182984 100644 --- a/scripts/input_component.gd +++ b/scripts/input_component.gd @@ -3,13 +3,12 @@ class_name InputComponent extends Node var move_dir: Vector2 = Vector2.ZERO var shoot_pressed: bool = false var shooting: bool = false - +var cycle_weapon: bool = false func update() -> void: move_dir = Input.get_vector("left", "right", "up", "down") shoot_pressed = Input.is_action_just_pressed("shoot") shooting = Input.is_action_pressed("shoot") - # Development Keys - # Cycle Available Weapons + cycle_weapon = Input.is_action_just_pressed("cycle")