diff --git a/week2/updated_files/.godot/editor/SceneManager.gd-folding-8ff368fa5a0946bdafb46afd013a16e2.cfg b/week2/updated_files/.godot/editor/SceneManager.gd-folding-8ff368fa5a0946bdafb46afd013a16e2.cfg new file mode 100644 index 0000000..e860dd4 --- /dev/null +++ b/week2/updated_files/.godot/editor/SceneManager.gd-folding-8ff368fa5a0946bdafb46afd013a16e2.cfg @@ -0,0 +1,3 @@ +[folding] + +sections_unfolded=PackedStringArray() diff --git a/week2/updated_files/.godot/editor/bullet.tscn-editstate-6d8e6ff1e6f20a36e0402d27c623c86c.cfg b/week2/updated_files/.godot/editor/bullet.tscn-editstate-6d8e6ff1e6f20a36e0402d27c623c86c.cfg index ac475b5..e72f1ee 100644 --- a/week2/updated_files/.godot/editor/bullet.tscn-editstate-6d8e6ff1e6f20a36e0402d27c623c86c.cfg +++ b/week2/updated_files/.godot/editor/bullet.tscn-editstate-6d8e6ff1e6f20a36e0402d27c623c86c.cfg @@ -175,4 +175,4 @@ Anim={ "zfar": 4000.01, "znear": 0.05 } -selected_nodes=Array[NodePath]([NodePath("/root/@EditorNode@16886/@Panel@13/@VBoxContainer@14/DockHSplitLeftL/DockHSplitLeftR/DockHSplitMain/@VBoxContainer@25/DockVSplitCenter/@VSplitContainer@52/@VBoxContainer@53/@PanelContainer@98/MainScreen/@CanvasItemEditor@9272/@VSplitContainer@9094/@HSplitContainer@9096/@HSplitContainer@9098/@Control@9099/@SubViewportContainer@9100/@SubViewport@9101/Game/level")]) +selected_nodes=Array[NodePath]([NodePath("/root/@EditorNode@16886/@Panel@13/@VBoxContainer@14/DockHSplitLeftL/DockHSplitLeftR/DockHSplitMain/@VBoxContainer@25/DockVSplitCenter/@VSplitContainer@52/@VBoxContainer@53/@PanelContainer@98/MainScreen/@CanvasItemEditor@9272/@VSplitContainer@9094/@HSplitContainer@9096/@HSplitContainer@9098/@Control@9099/@SubViewportContainer@9100/@SubViewport@9101/Game/SceneManager")]) diff --git a/week2/updated_files/.godot/editor/character.tscn-editstate-b6bd7a241034177d7fe082a7597ba8ea.cfg b/week2/updated_files/.godot/editor/character.tscn-editstate-b6bd7a241034177d7fe082a7597ba8ea.cfg index 9e2a893..38fc33e 100644 --- a/week2/updated_files/.godot/editor/character.tscn-editstate-b6bd7a241034177d7fe082a7597ba8ea.cfg +++ b/week2/updated_files/.godot/editor/character.tscn-editstate-b6bd7a241034177d7fe082a7597ba8ea.cfg @@ -8,7 +8,7 @@ Anim={ "grid_snap_active": false, "grid_step": Vector2(8, 8), "grid_visibility": 1, -"ofs": Vector2(-105.112, -79.4505), +"ofs": Vector2(-452.67, -210.078), "primary_grid_step": Vector2i(8, 8), "show_group_gizmos": true, "show_guides": true, @@ -34,7 +34,7 @@ Anim={ "snap_rotation_step": 0.261799, "snap_scale": false, "snap_scale_step": 0.1, -"zoom": 4.23785 +"zoom": 0.707107 } 3D={ "fov": 70.01, @@ -175,4 +175,4 @@ Anim={ "zfar": 4000.01, "znear": 0.05 } -selected_nodes=Array[NodePath]([NodePath("/root/@EditorNode@16886/@Panel@13/@VBoxContainer@14/DockHSplitLeftL/DockHSplitLeftR/DockHSplitMain/@VBoxContainer@25/DockVSplitCenter/@VSplitContainer@52/@VBoxContainer@53/@PanelContainer@98/MainScreen/@CanvasItemEditor@9272/@VSplitContainer@9094/@HSplitContainer@9096/@HSplitContainer@9098/@Control@9099/@SubViewportContainer@9100/@SubViewport@9101/Game/level")]) +selected_nodes=Array[NodePath]([NodePath("/root/@EditorNode@16886/@Panel@13/@VBoxContainer@14/DockHSplitLeftL/DockHSplitLeftR/DockHSplitMain/@VBoxContainer@25/DockVSplitCenter/@VSplitContainer@52/@VBoxContainer@53/@PanelContainer@98/MainScreen/@CanvasItemEditor@9272/@VSplitContainer@9094/@HSplitContainer@9096/@HSplitContainer@9098/@Control@9099/@SubViewportContainer@9100/@SubViewport@9101/Game/SceneManager")]) diff --git a/week2/updated_files/.godot/editor/create_recent.Node b/week2/updated_files/.godot/editor/create_recent.Node index 56a4f42..ab0f8ac 100644 --- a/week2/updated_files/.godot/editor/create_recent.Node +++ b/week2/updated_files/.godot/editor/create_recent.Node @@ -1,3 +1,4 @@ +Node Node2D CollisionShape2D Area2D diff --git a/week2/updated_files/.godot/editor/editor_layout.cfg b/week2/updated_files/.godot/editor/editor_layout.cfg index a52cf41..19ba4a2 100644 --- a/week2/updated_files/.godot/editor/editor_layout.cfg +++ b/week2/updated_files/.godot/editor/editor_layout.cfg @@ -19,7 +19,7 @@ dock_filesystem_split=0 dock_filesystem_display_mode=0 dock_filesystem_file_sort=0 dock_filesystem_file_list_display_mode=1 -dock_filesystem_selected_paths=PackedStringArray("res://scenes/bullet.tscn") +dock_filesystem_selected_paths=PackedStringArray("res://scripts/SceneManager.gd") dock_filesystem_uncollapsed_paths=PackedStringArray("Favorites", "res://", "res://scripts/", "res://scenes/") dock_bottom=[] dock_closed=[] @@ -40,8 +40,8 @@ selected_bottom_panel_item=0 [ScriptEditor] -open_scripts=["res://scripts/bullet.gd", "res://scripts/CharacterBody2D.gd", "res://scripts/gamecontroller.gd", "res://scripts/Trigger.gd"] -selected_script="res://scripts/Trigger.gd" +open_scripts=["res://scripts/bullet.gd", "res://scripts/CharacterBody2D.gd", "res://scripts/SceneManager.gd", "res://scripts/Trigger.gd"] +selected_script="res://scripts/SceneManager.gd" open_help=[] script_split_offset=70 list_split_offset=0 diff --git a/week2/updated_files/.godot/editor/favorites b/week2/updated_files/.godot/editor/favorites new file mode 100644 index 0000000..e69de29 diff --git a/week2/updated_files/.godot/editor/filesystem_cache8 b/week2/updated_files/.godot/editor/filesystem_cache8 index 58db59a..f2e61a9 100644 --- a/week2/updated_files/.godot/editor/filesystem_cache8 +++ b/week2/updated_files/.godot/editor/filesystem_cache8 @@ -2,12 +2,12 @@ ea4bc82a6ad023ab7ee23ee620429895 ::res://::1725904718 icon.svg::CompressedTexture2D::9114977118871582245::1718541837::1718541843::1::::<><>:: ::res://assets/::1718552371 -::res://scenes/::1725900535 -bullet.tscn::PackedScene::6880909734590904373::1725900535::0::1::::<><>::res://scripts/bullet.gd -character.tscn::PackedScene::451838158579532324::1725900535::0::1::::<><>::res://scripts/CharacterBody2D.gd -game.tscn::PackedScene::1738196330916037717::1725900535::0::1::::<><>::res://scripts/gamecontroller.gd<>uid://go4yc8hfo1gq::::res://scenes/character.tscn<>res://scripts/Trigger.gd -::res://scripts/::1722021779 +::res://scenes/::1725906775 +bullet.tscn::PackedScene::6880909734590904373::1725906775::0::1::::<><>::res://scripts/bullet.gd +character.tscn::PackedScene::451838158579532324::1725906775::0::1::::<><>::res://scripts/CharacterBody2D.gd +game.tscn::PackedScene::1738196330916037717::1725913478::0::1::::<><>::res://scripts/gamecontroller.gd<>uid://go4yc8hfo1gq::::res://scenes/character.tscn<>res://scripts/Trigger.gd +::res://scripts/::1725906775 bullet.gd::GDScript::-1::1722021779::0::1::::<>Area2D<>:: -CharacterBody2D.gd::GDScript::-1::1721179661::0::1::::<>CharacterBody2D<>:: +CharacterBody2D.gd::GDScript::-1::1725906775::0::1::::<>CharacterBody2D<>:: gamecontroller.gd::GDScript::-1::1718560874::0::1::::<>Node2D<>:: Trigger.gd::GDScript::-1::1718561036::0::1::::<>Area2D<>:: diff --git a/week2/updated_files/.godot/editor/filesystem_update4 b/week2/updated_files/.godot/editor/filesystem_update4 index f123e9a..999ce34 100644 --- a/week2/updated_files/.godot/editor/filesystem_update4 +++ b/week2/updated_files/.godot/editor/filesystem_update4 @@ -2,3 +2,4 @@ res://scenes/game.tscn res://scripts/CharacterBody2D.gd res://scenes/character.tscn res://scenes/bullet.tscn +res://scripts/SceneManager.gd diff --git a/week2/updated_files/.godot/editor/game.tscn-editstate-c2a7af834e91ff64325daddf58e45dc0.cfg b/week2/updated_files/.godot/editor/game.tscn-editstate-c2a7af834e91ff64325daddf58e45dc0.cfg index fc6bae6..38fc33e 100644 --- a/week2/updated_files/.godot/editor/game.tscn-editstate-c2a7af834e91ff64325daddf58e45dc0.cfg +++ b/week2/updated_files/.godot/editor/game.tscn-editstate-c2a7af834e91ff64325daddf58e45dc0.cfg @@ -175,4 +175,4 @@ Anim={ "zfar": 4000.01, "znear": 0.05 } -selected_nodes=Array[NodePath]([NodePath("/root/@EditorNode@16886/@Panel@13/@VBoxContainer@14/DockHSplitLeftL/DockHSplitLeftR/DockHSplitMain/@VBoxContainer@25/DockVSplitCenter/@VSplitContainer@52/@VBoxContainer@53/@PanelContainer@98/MainScreen/@CanvasItemEditor@9272/@VSplitContainer@9094/@HSplitContainer@9096/@HSplitContainer@9098/@Control@9099/@SubViewportContainer@9100/@SubViewport@9101/Game/level")]) +selected_nodes=Array[NodePath]([NodePath("/root/@EditorNode@16886/@Panel@13/@VBoxContainer@14/DockHSplitLeftL/DockHSplitLeftR/DockHSplitMain/@VBoxContainer@25/DockVSplitCenter/@VSplitContainer@52/@VBoxContainer@53/@PanelContainer@98/MainScreen/@CanvasItemEditor@9272/@VSplitContainer@9094/@HSplitContainer@9096/@HSplitContainer@9098/@Control@9099/@SubViewportContainer@9100/@SubViewport@9101/Game/SceneManager")]) diff --git a/week2/updated_files/.godot/editor/game.tscn-folding-c2a7af834e91ff64325daddf58e45dc0.cfg b/week2/updated_files/.godot/editor/game.tscn-folding-c2a7af834e91ff64325daddf58e45dc0.cfg index 781c64d..cb573f6 100644 --- a/week2/updated_files/.godot/editor/game.tscn-folding-c2a7af834e91ff64325daddf58e45dc0.cfg +++ b/week2/updated_files/.godot/editor/game.tscn-folding-c2a7af834e91ff64325daddf58e45dc0.cfg @@ -2,4 +2,4 @@ node_unfolds=[NodePath("."), PackedStringArray("Transform"), NodePath("RigidBody2D"), PackedStringArray("Transform"), NodePath("RigidBody2D/CollisionShape2D"), PackedStringArray("Transform"), NodePath("groundblock"), PackedStringArray("Transform"), NodePath("groundblock/CollisionShape2D"), PackedStringArray("Transform"), NodePath("groundblock2"), PackedStringArray("Transform"), NodePath("groundblock2/CollisionShape2D"), PackedStringArray("Transform"), NodePath("level/groundblock2"), PackedStringArray("Transform"), NodePath("level/groundblock2/CollisionShape2D"), PackedStringArray("Transform"), NodePath("level/groundblock3"), PackedStringArray("Transform"), NodePath("level/groundblock3/CollisionShape2D"), PackedStringArray("Transform"), NodePath("level/StaticBody2D"), PackedStringArray("Transform"), NodePath("CharacterBody2D"), PackedStringArray("Transform"), NodePath("Area2D"), PackedStringArray("Transform")] resource_unfolds=["res://scenes/game.tscn::RectangleShape2D_4vo4d", PackedStringArray("Resource"), "res://scenes/game.tscn::RectangleShape2D_cq7kj", PackedStringArray("Resource"), "res://scenes/game.tscn::WorldBoundaryShape2D_3u4a8", PackedStringArray("Resource"), "res://scenes/game.tscn::CircleShape2D_x8qck", PackedStringArray("Resource")] -nodes_folded=[NodePath("RigidBody2D"), NodePath("groundblock"), NodePath("groundblock2"), NodePath("level"), NodePath("Area2D")] +nodes_folded=[NodePath("RigidBody2D"), NodePath("groundblock"), NodePath("groundblock2"), NodePath("level")] diff --git a/week2/updated_files/.godot/editor/project_metadata.cfg b/week2/updated_files/.godot/editor/project_metadata.cfg index 9b24e37..175a37c 100644 --- a/week2/updated_files/.godot/editor/project_metadata.cfg +++ b/week2/updated_files/.godot/editor/project_metadata.cfg @@ -11,7 +11,7 @@ run_debug_collisions=true [recent_files] -scenes=["res://scenes/bullet.tscn", "res://scenes/character.tscn", "res://scenes/game.tscn"] +scenes=["res://scenes/game.tscn", "res://scenes/bullet.tscn", "res://scenes/character.tscn"] scripts=["res://scripts/Trigger.gd", "res://scripts/bullet.gd", "res://scripts/CharacterBody2D.gd", "res://scripts/gamecontroller.gd"] [linked_properties] diff --git a/week2/updated_files/.godot/editor/script_editor_cache.cfg b/week2/updated_files/.godot/editor/script_editor_cache.cfg index 3794381..140088f 100644 --- a/week2/updated_files/.godot/editor/script_editor_cache.cfg +++ b/week2/updated_files/.godot/editor/script_editor_cache.cfg @@ -1,32 +1,14 @@ -[res://scripts/gamecontroller.gd] - -state={ -"bookmarks": PackedInt32Array(), -"breakpoints": PackedInt32Array(), -"column": 45, -"folded_lines": Array[int]([]), -"h_scroll_position": 0, -"row": 13, -"scroll_position": 0.0, -"selection": false, -"syntax_highlighter": "GDScript" -} - [res://scripts/CharacterBody2D.gd] state={ "bookmarks": PackedInt32Array(), "breakpoints": PackedInt32Array(), -"column": 12, +"column": 38, "folded_lines": Array[int]([]), "h_scroll_position": 0, -"row": 33, -"scroll_position": 22.0, -"selection": true, -"selection_from_column": 2, -"selection_from_line": 33, -"selection_to_column": 12, -"selection_to_line": 33, +"row": 44, +"scroll_position": 31.0, +"selection": false, "syntax_highlighter": "GDScript" } @@ -57,3 +39,17 @@ state={ "selection": false, "syntax_highlighter": "GDScript" } + +[res://scripts/SceneManager.gd] + +state={ +"bookmarks": PackedInt32Array(), +"breakpoints": PackedInt32Array(), +"column": 22, +"folded_lines": Array[int]([]), +"h_scroll_position": 0, +"row": 13, +"scroll_position": 0.0, +"selection": false, +"syntax_highlighter": "GDScript" +} diff --git a/week2/updated_files/scenes/game.tscn b/week2/updated_files/scenes/game.tscn index 0c1405b..34ea19f 100644 --- a/week2/updated_files/scenes/game.tscn +++ b/week2/updated_files/scenes/game.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=8 format=3 uid="uid://y083suj12rld"] -[ext_resource type="Script" path="res://scripts/gamecontroller.gd" id="1_77wyw"] +[ext_resource type="Script" path="res://scripts/SceneManager.gd" id="1_77wyw"] [ext_resource type="PackedScene" uid="uid://go4yc8hfo1gq" path="res://scenes/character.tscn" id="2_64ccm"] [ext_resource type="Script" path="res://scripts/Trigger.gd" id="2_nfj1w"] @@ -16,6 +16,9 @@ size = Vector2(91, 20) radius = 60.2993 [node name="Game" type="Node2D"] + +[node name="SceneManager" type="Node" parent="."] +unique_name_in_owner = true script = ExtResource("1_77wyw") [node name="RigidBody2D" type="RigidBody2D" parent="." groups=["boxes"]] diff --git a/week2/updated_files/scripts/CharacterBody2D.gd b/week2/updated_files/scripts/CharacterBody2D.gd index cdbae93..3f711e1 100644 --- a/week2/updated_files/scripts/CharacterBody2D.gd +++ b/week2/updated_files/scripts/CharacterBody2D.gd @@ -41,11 +41,8 @@ func _physics_process(delta): #make a bullet var myBullet = bullet.instantiate() #set bullet speed? - - #put the bullet at the Marker - owner.add_child(myBullet) myBullet.transform = marker_right.global_transform - pass + %SceneManager.manageBullet(myBullet) # Get the input direction and handle the movement/deceleration. # As good practice, you should replace UI actions with custom gameplay actions. var direction = Input.get_axis("ui_left", "ui_right") diff --git a/week2/updated_files/scripts/gamecontroller.gd b/week2/updated_files/scripts/SceneManager.gd similarity index 56% rename from week2/updated_files/scripts/gamecontroller.gd rename to week2/updated_files/scripts/SceneManager.gd index 0ad265d..a8df008 100644 --- a/week2/updated_files/scripts/gamecontroller.gd +++ b/week2/updated_files/scripts/SceneManager.gd @@ -1,6 +1,6 @@ -extends Node2D - +extends Node +var bulletsFiredTotal := 0 # Called when the node enters the scene tree for the first time. func _ready(): pass # Replace with function body. @@ -10,6 +10,7 @@ func _ready(): func _process(delta): pass - -func _on_area_2d_areatrigger(effect, Object): - print("Game Controller sees the trigger") +func manageBullet(bullet): + bulletsFiredTotal +=1 + owner.add_child(bullet) + print("Total bullets fired "+str(bulletsFiredTotal))