diff --git a/week6/README.md b/week6/README.md index 1ea94f1..12dc688 100644 --- a/week6/README.md +++ b/week6/README.md @@ -20,4 +20,15 @@ An autoload resource is one that can be specified in the project settings. It wi An autoload script is a good place to put any persistent game logic and data, as well as any helper methods that may be useful to a wide variety of nodes in your game. -It is possible that an autoload script can get quite cluttered with information, so a good combination is to use an autoload script and data objects together. \ No newline at end of file +It is possible that an autoload script can get quite cluttered with information, so a good combination is to use an autoload script and data objects together. + +## Relevance to UI + +A good UI is essentially a graphical representation of the state of the game. Once that state is centralized in one place it becomes easier to make UI that accurately reflects all the data in the game (such as player health, coins collected, points, timers etc.) + +Our goals for UI: + +* Create a Canvas Layer to float the UI over the viewport +* Create a Control node to contain our UI nodes +* Create Container nodes (vbox and hbox) +* Use a MarginContainer node to wrap our UI nodes \ No newline at end of file diff --git a/week6/updated_project/.godot/editor/badguy.tscn-editstate-e196a632ea77e9a0d8baa608f164a4d2.cfg b/week6/updated_project/.godot/editor/badguy.tscn-editstate-e196a632ea77e9a0d8baa608f164a4d2.cfg index 942dae0..1f2772a 100644 --- a/week6/updated_project/.godot/editor/badguy.tscn-editstate-e196a632ea77e9a0d8baa608f164a4d2.cfg +++ b/week6/updated_project/.godot/editor/badguy.tscn-editstate-e196a632ea77e9a0d8baa608f164a4d2.cfg @@ -172,4 +172,4 @@ Anim={ "zfar": 4000.01, "znear": 0.05 } -selected_nodes=Array[NodePath]([NodePath("/root/@EditorNode@17140/@Panel@13/@VBoxContainer@14/@HSplitContainer@17/@HSplitContainer@25/@HSplitContainer@33/@VBoxContainer@34/@VSplitContainer@36/@VSplitContainer@62/@VBoxContainer@63/@PanelContainer@110/MainScreen/@CanvasItemEditor@9462/@VSplitContainer@9281/@HSplitContainer@9283/@HSplitContainer@9285/@Control@9286/@SubViewportContainer@9287/@SubViewport@9288/CharacterBody2D/AnimatedSprite2D")]) +selected_nodes=Array[NodePath]([NodePath("/root/@EditorNode@17140/@Panel@13/@VBoxContainer@14/@HSplitContainer@17/@HSplitContainer@25/@HSplitContainer@33/@VBoxContainer@34/@VSplitContainer@36/@VSplitContainer@62/@VBoxContainer@63/@PanelContainer@110/MainScreen/@CanvasItemEditor@9462/@VSplitContainer@9281/@HSplitContainer@9283/@HSplitContainer@9285/@Control@9286/@SubViewportContainer@9287/@SubViewport@9288/Game/CanvasLayer/UI")]) diff --git a/week6/updated_project/.godot/editor/character.tscn-editstate-b6bd7a241034177d7fe082a7597ba8ea.cfg b/week6/updated_project/.godot/editor/character.tscn-editstate-b6bd7a241034177d7fe082a7597ba8ea.cfg index 6a24c40..965daad 100644 --- a/week6/updated_project/.godot/editor/character.tscn-editstate-b6bd7a241034177d7fe082a7597ba8ea.cfg +++ b/week6/updated_project/.godot/editor/character.tscn-editstate-b6bd7a241034177d7fe082a7597ba8ea.cfg @@ -172,4 +172,4 @@ Anim={ "zfar": 4000.01, "znear": 0.05 } -selected_nodes=Array[NodePath]([NodePath("/root/@EditorNode@17140/@Panel@13/@VBoxContainer@14/@HSplitContainer@17/@HSplitContainer@25/@HSplitContainer@33/@VBoxContainer@34/@VSplitContainer@36/@VSplitContainer@62/@VBoxContainer@63/@PanelContainer@110/MainScreen/@CanvasItemEditor@9462/@VSplitContainer@9281/@HSplitContainer@9283/@HSplitContainer@9285/@Control@9286/@SubViewportContainer@9287/@SubViewport@9288/CharacterBody2D/AnimatedSprite2D")]) +selected_nodes=Array[NodePath]([NodePath("/root/@EditorNode@17140/@Panel@13/@VBoxContainer@14/@HSplitContainer@17/@HSplitContainer@25/@HSplitContainer@33/@VBoxContainer@34/@VSplitContainer@36/@VSplitContainer@62/@VBoxContainer@63/@PanelContainer@110/MainScreen/@CanvasItemEditor@9462/@VSplitContainer@9281/@HSplitContainer@9283/@HSplitContainer@9285/@Control@9286/@SubViewportContainer@9287/@SubViewport@9288/Game/CanvasLayer/UI")]) diff --git a/week6/updated_project/.godot/editor/coin.tscn-editstate-96b2131180b71dd158e52c5527d22dd4.cfg b/week6/updated_project/.godot/editor/coin.tscn-editstate-96b2131180b71dd158e52c5527d22dd4.cfg index 5f0475f..ec22c0b 100644 --- a/week6/updated_project/.godot/editor/coin.tscn-editstate-96b2131180b71dd158e52c5527d22dd4.cfg +++ b/week6/updated_project/.godot/editor/coin.tscn-editstate-96b2131180b71dd158e52c5527d22dd4.cfg @@ -172,4 +172,4 @@ Anim={ "zfar": 4000.01, "znear": 0.05 } -selected_nodes=Array[NodePath]([NodePath("/root/@EditorNode@17140/@Panel@13/@VBoxContainer@14/@HSplitContainer@17/@HSplitContainer@25/@HSplitContainer@33/@VBoxContainer@34/@VSplitContainer@36/@VSplitContainer@62/@VBoxContainer@63/@PanelContainer@110/MainScreen/@CanvasItemEditor@9462/@VSplitContainer@9281/@HSplitContainer@9283/@HSplitContainer@9285/@Control@9286/@SubViewportContainer@9287/@SubViewport@9288/CharacterBody2D/AnimatedSprite2D")]) +selected_nodes=Array[NodePath]([NodePath("/root/@EditorNode@17140/@Panel@13/@VBoxContainer@14/@HSplitContainer@17/@HSplitContainer@25/@HSplitContainer@33/@VBoxContainer@34/@VSplitContainer@36/@VSplitContainer@62/@VBoxContainer@63/@PanelContainer@110/MainScreen/@CanvasItemEditor@9462/@VSplitContainer@9281/@HSplitContainer@9283/@HSplitContainer@9285/@Control@9286/@SubViewportContainer@9287/@SubViewport@9288/Game/CanvasLayer/UI")]) diff --git a/week6/updated_project/.godot/editor/create_recent.Node b/week6/updated_project/.godot/editor/create_recent.Node index bca5623..c0870a5 100644 --- a/week6/updated_project/.godot/editor/create_recent.Node +++ b/week6/updated_project/.godot/editor/create_recent.Node @@ -1,3 +1,9 @@ +MarginContainer +CanvasLayer +Label +HBoxContainer +VBoxContainer +ColorRect RayCast2D Timer Node @@ -6,9 +12,3 @@ AnimatedSprite2D Area2D Node2D CenterContainer -Sprite2D -ParallaxLayer -ParallaxBackground -AnimationPlayer -AnimatableBody2D -StaticBody2D diff --git a/week6/updated_project/.godot/editor/editor_layout.cfg b/week6/updated_project/.godot/editor/editor_layout.cfg index 47c238c..0f2c5df 100644 --- a/week6/updated_project/.godot/editor/editor_layout.cfg +++ b/week6/updated_project/.godot/editor/editor_layout.cfg @@ -4,7 +4,7 @@ dock_1_selected_tab_idx=0 dock_2_selected_tab_idx=0 dock_3_selected_tab_idx=0 dock_4_selected_tab_idx=0 -dock_5_selected_tab_idx=1 +dock_5_selected_tab_idx=0 dock_6_selected_tab_idx=0 dock_7_selected_tab_idx=0 dock_8_selected_tab_idx=0 @@ -19,16 +19,16 @@ 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://graphics/Player Hurt/") -dock_filesystem_uncollapsed_paths=PackedStringArray("Favorites", "res://", "res://scripts/resources/", "res://scripts/gameManager/", "res://graphics/", "res://graphics/Player Hurt/") +dock_filesystem_selected_paths=PackedStringArray("res://scenes/ui.tscn") +dock_filesystem_uncollapsed_paths=PackedStringArray("Favorites", "res://", "res://scripts/resources/", "res://scripts/gameManager/", "res://scenes/", "res://graphics/", "res://graphics/Player Hurt/") dock_3="Scene,Import" dock_4="FileSystem" dock_5="Inspector,Node,History" [EditorNode] -open_scenes=PackedStringArray("res://scenes/game.tscn", "res://scenes/character.tscn", "res://scenes/badguy.tscn", "res://scenes/coin.tscn") -current_scene="res://scenes/character.tscn" +open_scenes=PackedStringArray("res://scenes/game.tscn", "res://scenes/character.tscn", "res://scenes/badguy.tscn", "res://scenes/coin.tscn", "res://scenes/ui.tscn") +current_scene="res://scenes/game.tscn" center_split_offset=-252 selected_default_debugger_tab_idx=0 selected_main_editor_idx=2 @@ -36,8 +36,8 @@ selected_bottom_panel_item=0 [ScriptEditor] -open_scripts=["res://scripts/badguy.gd", "res://scripts/bullet.gd", "res://scripts/CharacterBody2D.gd", "res://scripts/resources/character_stats.gd", "res://scripts/coin.gd", "res://scripts/gamecontroller.gd", "res://scripts/gameManager/gamemanager.gd", "res://scripts/Trigger.gd"] -selected_script="res://scripts/CharacterBody2D.gd" +open_scripts=["res://scripts/badguy.gd", "res://scripts/bullet.gd", "res://scripts/CharacterBody2D.gd", "res://scripts/resources/character_stats.gd", "res://scripts/coin.gd", "res://scripts/gamecontroller.gd", "res://scripts/gameManager/gamemanager.gd", "res://scripts/Trigger.gd", "res://scripts/ui.gd"] +selected_script="res://scripts/gamecontroller.gd" open_help=[] script_split_offset=70 list_split_offset=0 diff --git a/week6/updated_project/.godot/editor/filesystem_cache8 b/week6/updated_project/.godot/editor/filesystem_cache8 index 5026386..6fc0c50 100644 --- a/week6/updated_project/.godot/editor/filesystem_cache8 +++ b/week6/updated_project/.godot/editor/filesystem_cache8 @@ -1,5 +1,5 @@ ea4bc82a6ad023ab7ee23ee620429895 -::res://::1724071986 +::res://::1724081296 icon.svg::CompressedTexture2D::9114977118871582245::1724024726::1724024726::1::::<><>:: ::res://graphics/::1724076966 coin.png::CompressedTexture2D::7063880403899111552::1724024726::1724024726::1::::<><>:: @@ -23,22 +23,22 @@ player jump 48x48.png::CompressedTexture2D::1627608568707791839::1724024726::172 player land 48x48.png::CompressedTexture2D::3499637713582873633::1724024726::1724024726::1::::<><>:: ::res://graphics/Player Run/::1724024726 player run 48x48.png::CompressedTexture2D::1502492849971408816::1724024726::1724024726::1::::<><>:: -::res://scenes/::1724076532 +::res://scenes/::1724078633 area_trigger.tscn::PackedScene::2953141911562060689::1724024726::0::1::::<><>::res://scripts/Trigger.gd -badguy.tscn::PackedScene::8923528729538756339::1724076532::0::1::::<><>::res://scripts/badguy.gd<>uid://c4g3ypigewuuu::::res://graphics/slime_green.png +badguy.tscn::PackedScene::8923528729538756339::1724078633::0::1::::<><>::res://scripts/badguy.gd<>uid://c4g3ypigewuuu::::res://graphics/slime_green.png bullet.tscn::PackedScene::6880909734590904373::1724035820::0::1::::<><>::res://scripts/bullet.gd -character.tscn::PackedScene::451838158579532324::1724076532::0::1::::<><>::res://scripts/CharacterBody2D.gd<>uid://c0iiaebonyhh0::::res://graphics/Player Idle/Player Idle 48x48.png<>uid://bwnec1thq1btr::::res://graphics/Player Death/Player Death 64x64.png<>uid://xgoqfqmvorcx::::res://graphics/Player Jump/player jump 48x48.png<>uid://vn23qn3f0dvc::::res://graphics/Player Run/player run 48x48.png -coin.tscn::PackedScene::61828818800194477::1724076532::0::1::::<><>::uid://c7v2cwn2826lg::::res://graphics/coin.png<>res://scripts/coin.gd +character.tscn::PackedScene::451838158579532324::1724078633::0::1::::<><>::res://scripts/CharacterBody2D.gd<>uid://c0iiaebonyhh0::::res://graphics/Player Idle/Player Idle 48x48.png<>uid://bwnec1thq1btr::::res://graphics/Player Death/Player Death 64x64.png<>uid://dytvp6158kit2::::res://graphics/Player Hurt/Player Hurt 48x48.png<>uid://xgoqfqmvorcx::::res://graphics/Player Jump/player jump 48x48.png<>uid://vn23qn3f0dvc::::res://graphics/Player Run/player run 48x48.png +coin.tscn::PackedScene::61828818800194477::1724078633::0::1::::<><>::uid://c7v2cwn2826lg::::res://graphics/coin.png<>res://scripts/coin.gd crate.tscn::PackedScene::41931541512830250::1724035820::0::1::::<><>::uid://ddxm7hj323fta::::res://graphics/items/cannister.png -game.tscn::PackedScene::1738196330916037717::1724076532::0::1::::<><>::res://scripts/gamecontroller.gd<>uid://go4yc8hfo1gq::::res://scenes/character.tscn<>uid://dwb83f7uoweuy::::res://graphics/Terrain (32x32).png<>uid://ukuu7p7vhlq::::res://scenes/crate.tscn<>uid://dvd1p6xue0ub2::::res://scenes/platform.tscn<>uid://dly4g7fvvtamm::::res://graphics/background/BG Image.png<>uid://bicr20de8c3jp::::res://scenes/area_trigger.tscn<>uid://cw50mfjp2np08::::res://graphics/background/Additional Sky.png<>uid://6olcj1w1svdg::::res://graphics/background/Additional Water.png<>uid://47kuhu1ukph::::res://scenes/coin.tscn<>uid://d0evhj5ayp0ep::::res://scenes/badguy.tscn +game.tscn::PackedScene::1738196330916037717::1724078633::0::1::::<><>::res://scripts/gamecontroller.gd<>uid://go4yc8hfo1gq::::res://scenes/character.tscn<>uid://dwb83f7uoweuy::::res://graphics/Terrain (32x32).png<>uid://ukuu7p7vhlq::::res://scenes/crate.tscn<>uid://dvd1p6xue0ub2::::res://scenes/platform.tscn<>uid://dly4g7fvvtamm::::res://graphics/background/BG Image.png<>uid://bicr20de8c3jp::::res://scenes/area_trigger.tscn<>uid://cw50mfjp2np08::::res://graphics/background/Additional Sky.png<>uid://6olcj1w1svdg::::res://graphics/background/Additional Water.png<>uid://47kuhu1ukph::::res://scenes/coin.tscn<>uid://d0evhj5ayp0ep::::res://scenes/badguy.tscn menu.tscn::PackedScene::1738029604261438007::1724024726::0::1::::<><>:: platform.tscn::PackedScene::8641027994130079701::1724024726::0::1::::<><>:: -::res://scripts/::1724076382 -badguy.gd::GDScript::-1::1724072417::0::1::::<>Area2D<>:: +::res://scripts/::1724077882 +badguy.gd::GDScript::-1::1724077297::0::1::::<>Area2D<>:: bullet.gd::GDScript::-1::1724024726::0::1::::<>Area2D<>:: -CharacterBody2D.gd::GDScript::-1::1724075537::0::1::::<>CharacterBody2D<>:: +CharacterBody2D.gd::GDScript::-1::1724077882::0::1::::<>CharacterBody2D<>:: coin.gd::GDScript::-1::1724076175::0::1::::<>Area2D<>:: -gamecontroller.gd::GDScript::-1::1724076382::0::1::::<>Node<>:: +gamecontroller.gd::GDScript::-1::1724077508::0::1::::<>Node<>:: Trigger.gd::GDScript::-1::1724024726::0::1::::<>Area2D<>:: ::res://scripts/gameManager/::1724073623 gamemanager.gd::GDScript::-1::1724073623::0::1::::<>Node<>:: diff --git a/week6/updated_project/.godot/editor/filesystem_update4 b/week6/updated_project/.godot/editor/filesystem_update4 index 58fe59a..d4c6573 100644 --- a/week6/updated_project/.godot/editor/filesystem_update4 +++ b/week6/updated_project/.godot/editor/filesystem_update4 @@ -1,11 +1,7 @@ -res://scenes/character.tscn -res://scripts/resources/player_stats.tres -res://scripts/gameManager/gamemanager.gd -res://scenes/badguy.tscn -res://scripts/badguy.gd -res://scripts/gamecontroller.gd res://scenes/game.tscn -res://scripts/CharacterBody2D.gd -res://scripts/resources/slime_stats.tres +res://scenes/character.tscn +res://scenes/badguy.tscn res://scenes/coin.tscn -res://scripts/coin.gd +res://scenes/ui.tscn +res://scripts/ui.gd +res://scripts/gamecontroller.gd diff --git a/week6/updated_project/.godot/editor/game.tscn-editstate-c2a7af834e91ff64325daddf58e45dc0.cfg b/week6/updated_project/.godot/editor/game.tscn-editstate-c2a7af834e91ff64325daddf58e45dc0.cfg index 9687f15..f74e3f7 100644 --- a/week6/updated_project/.godot/editor/game.tscn-editstate-c2a7af834e91ff64325daddf58e45dc0.cfg +++ b/week6/updated_project/.godot/editor/game.tscn-editstate-c2a7af834e91ff64325daddf58e45dc0.cfg @@ -172,4 +172,4 @@ Anim={ "zfar": 4000.01, "znear": 0.05 } -selected_nodes=Array[NodePath]([NodePath("/root/@EditorNode@17140/@Panel@13/@VBoxContainer@14/@HSplitContainer@17/@HSplitContainer@25/@HSplitContainer@33/@VBoxContainer@34/@VSplitContainer@36/@VSplitContainer@62/@VBoxContainer@63/@PanelContainer@110/MainScreen/@CanvasItemEditor@9462/@VSplitContainer@9281/@HSplitContainer@9283/@HSplitContainer@9285/@Control@9286/@SubViewportContainer@9287/@SubViewport@9288/CharacterBody2D/AnimatedSprite2D")]) +selected_nodes=Array[NodePath]([NodePath("/root/@EditorNode@17140/@Panel@13/@VBoxContainer@14/@HSplitContainer@17/@HSplitContainer@25/@HSplitContainer@33/@VBoxContainer@34/@VSplitContainer@36/@VSplitContainer@62/@VBoxContainer@63/@PanelContainer@110/MainScreen/@CanvasItemEditor@9462/@VSplitContainer@9281/@HSplitContainer@9283/@HSplitContainer@9285/@Control@9286/@SubViewportContainer@9287/@SubViewport@9288/Game/CanvasLayer/UI")]) diff --git a/week6/updated_project/.godot/editor/game.tscn-folding-c2a7af834e91ff64325daddf58e45dc0.cfg b/week6/updated_project/.godot/editor/game.tscn-folding-c2a7af834e91ff64325daddf58e45dc0.cfg index 50fba4c..b7473bb 100644 --- a/week6/updated_project/.godot/editor/game.tscn-folding-c2a7af834e91ff64325daddf58e45dc0.cfg +++ b/week6/updated_project/.godot/editor/game.tscn-folding-c2a7af834e91ff64325daddf58e45dc0.cfg @@ -2,4 +2,4 @@ node_unfolds=[NodePath("."), PackedStringArray("Transform"), NodePath("TileMap"), PackedStringArray("layer__array", "tile_set"), NodePath("ParallaxBackground/ParallaxLayer"), PackedStringArray("Motion"), NodePath("ParallaxBackground/ParallaxLayer/Sprite2D"), PackedStringArray("Transform", "texture"), NodePath("Ground"), PackedStringArray("Transform"), NodePath("MovingPlatform"), PackedStringArray("Transform")] resource_unfolds=["res://scenes/game.tscn::TileSet_47g5u", PackedStringArray("terrain_set_0/terrain__array", "physics_layer__array"), "res://scenes/game.tscn::WorldBoundaryShape2D_xkyim", PackedStringArray(), "res://scenes/game.tscn::CircleShape2D_j8ltg", PackedStringArray()] -nodes_folded=[NodePath("ParallaxBackground"), NodePath("ParallaxBackground/ParallaxLayer"), NodePath("Ground"), NodePath("CharacterBody2D"), NodePath("BoxTrapTrigger"), NodePath("crates"), NodePath("MovingPlatform")] +nodes_folded=[NodePath("SceneManager"), NodePath("ParallaxBackground"), NodePath("ParallaxBackground/ParallaxLayer"), NodePath("Ground"), NodePath("CharacterBody2D"), NodePath("BoxTrapTrigger"), NodePath("crates"), NodePath("MovingPlatform")] diff --git a/week6/updated_project/.godot/editor/project_metadata.cfg b/week6/updated_project/.godot/editor/project_metadata.cfg index 2bd0329..bb0fa4d 100644 --- a/week6/updated_project/.godot/editor/project_metadata.cfg +++ b/week6/updated_project/.godot/editor/project_metadata.cfg @@ -14,8 +14,8 @@ run_debug_collisions=false [recent_files] -scenes=["res://scenes/coin.tscn", "res://scenes/badguy.tscn", "res://scenes/crate.tscn", "res://scenes/bullet.tscn", "res://scenes/character.tscn", "res://scenes/game.tscn", "res://scenes/area_trigger.tscn", "res://scenes/menu.tscn", "res://scenes/platform.tscn", "res://scenes/animatedcoin.tscn"] -scripts=["res://scripts/gameManager/gamemanager.gd", "res://scripts/resources/character_stats.gd", "res://scripts/badguy.gd", "res://scripts/coin.gd", "res://scripts/Trigger.gd", "res://scripts/bullet.gd", "res://scripts/CharacterBody2D.gd", "res://scripts/gamecontroller.gd"] +scenes=["res://scenes/ui.tscn", "res://scenes/coin.tscn", "res://scenes/badguy.tscn", "res://scenes/character.tscn", "res://scenes/game.tscn", "res://scenes/crate.tscn", "res://scenes/bullet.tscn", "res://scenes/area_trigger.tscn", "res://scenes/menu.tscn", "res://scenes/platform.tscn"] +scripts=["res://scripts/ui.gd", "res://scripts/gameManager/gamemanager.gd", "res://scripts/resources/character_stats.gd", "res://scripts/badguy.gd", "res://scripts/coin.gd", "res://scripts/Trigger.gd", "res://scripts/bullet.gd", "res://scripts/CharacterBody2D.gd", "res://scripts/gamecontroller.gd"] [linked_properties] @@ -38,6 +38,13 @@ ParallaxLayer:motion_scale=true ParallaxLayer:scale=true AnimatableBody2D:scale=true CenterContainer:scale=true +Control:scale=true +VBoxContainer:scale=true +HBoxContainer:scale=true +Label:scale=true +ColorRect:scale=true +CanvasLayer:scale=true +MarginContainer:scale=true [dialog_bounds] @@ -46,7 +53,7 @@ project_settings=Rect2(510, 190, 900, 700) [color_picker] -recent_presets=PackedColorArray(0.616312, 0.404074, 0.899578, 0.42, 0.720388, 0.338613, 0.856219, 0.42, 0.724243, 0.309912, 0.904036, 0.42, 0.708381, 0.310171, 0.933753, 0.42) +recent_presets=PackedColorArray(0.616312, 0.404074, 0.899578, 0.42, 0.720388, 0.338613, 0.856219, 0.42, 0.724243, 0.309912, 0.904036, 0.42, 0.708381, 0.310171, 0.933753, 0.42, 0.313726, 1, 1, 1, 0.313726, 1, 0.317647, 1, 0, 0.507899, 0.0451613, 1, 2.55093e-06, 0.743836, 0.0871435, 1) [script_setup] diff --git a/week6/updated_project/.godot/editor/recent_dirs b/week6/updated_project/.godot/editor/recent_dirs index 6270c6d..6c84f9d 100644 --- a/week6/updated_project/.godot/editor/recent_dirs +++ b/week6/updated_project/.godot/editor/recent_dirs @@ -1,9 +1,9 @@ +res://scripts +res://scenes res://graphics/Player Hurt res://scripts/gameManager res://scripts/resources/ res://graphics/Player Death -res://scripts -res://scenes res://graphics res://graphics/Player Jump res://graphics/Player Run diff --git a/week6/updated_project/.godot/editor/script_editor_cache.cfg b/week6/updated_project/.godot/editor/script_editor_cache.cfg index 719eaed..227da02 100644 --- a/week6/updated_project/.godot/editor/script_editor_cache.cfg +++ b/week6/updated_project/.godot/editor/script_editor_cache.cfg @@ -6,8 +6,8 @@ state={ "column": 0, "folded_lines": Array[int]([]), "h_scroll_position": 0, -"row": 41, -"scroll_position": 29.0, +"row": 43, +"scroll_position": 30.0, "selection": false, "syntax_highlighter": "GDScript" } @@ -19,9 +19,9 @@ state={ "breakpoints": PackedInt32Array(), "column": 36, "folded_lines": Array[int]([]), -"h_scroll_position": 0, +"h_scroll_position": 129, "row": 40, -"scroll_position": 35.0, +"scroll_position": 40.0, "selection": false, "syntax_highlighter": "GDScript" } @@ -109,3 +109,17 @@ state={ "selection": false, "syntax_highlighter": "GDScript" } + +[res://scripts/ui.gd] + +state={ +"bookmarks": PackedInt32Array(), +"breakpoints": PackedInt32Array(), +"column": 16, +"folded_lines": Array[int]([]), +"h_scroll_position": 0, +"row": 8, +"scroll_position": 0.0, +"selection": false, +"syntax_highlighter": "GDScript" +} diff --git a/week6/updated_project/.godot/editor/ui.gd-folding-3b8d530734b8023ccf565168363a2129.cfg b/week6/updated_project/.godot/editor/ui.gd-folding-3b8d530734b8023ccf565168363a2129.cfg new file mode 100644 index 0000000..e860dd4 --- /dev/null +++ b/week6/updated_project/.godot/editor/ui.gd-folding-3b8d530734b8023ccf565168363a2129.cfg @@ -0,0 +1,3 @@ +[folding] + +sections_unfolded=PackedStringArray() diff --git a/week6/updated_project/.godot/editor/ui.tscn-editstate-9211dc52ac9df169ba4fe77cbc1dc833.cfg b/week6/updated_project/.godot/editor/ui.tscn-editstate-9211dc52ac9df169ba4fe77cbc1dc833.cfg new file mode 100644 index 0000000..7fbf099 --- /dev/null +++ b/week6/updated_project/.godot/editor/ui.tscn-editstate-9211dc52ac9df169ba4fe77cbc1dc833.cfg @@ -0,0 +1,175 @@ +[editor_states] + +Anim={ +"visible": false +} +2D={ +"grid_offset": Vector2(0, 0), +"grid_snap_active": false, +"grid_step": Vector2(8, 8), +"grid_visibility": 1, +"ofs": Vector2(-165, -110), +"primary_grid_step": Vector2i(8, 8), +"show_edit_locks": true, +"show_guides": true, +"show_helpers": false, +"show_origin": true, +"show_rulers": true, +"show_transformation_gizmos": true, +"show_viewport": true, +"show_zoom_control": true, +"smart_snap_active": false, +"snap_guides": true, +"snap_node_anchors": true, +"snap_node_center": true, +"snap_node_parent": true, +"snap_node_sides": true, +"snap_other_nodes": true, +"snap_pixel": true, +"snap_relative": false, +"snap_rotation": false, +"snap_rotation_offset": 0.0, +"snap_rotation_step": 0.261799, +"snap_scale": false, +"snap_scale_step": 0.1, +"zoom": 1.0 +} +3D={ +"fov": 70.01, +"gizmos_status": { +"AudioListener3D": 0, +"AudioStreamPlayer3D": 0, +"CPUParticles3D": 0, +"CSGShape3D": 0, +"Camera3D": 0, +"CollisionObject3D": 0, +"CollisionPolygon3D": 0, +"CollisionShape3D": 0, +"Decal": 0, +"FogVolume": 0, +"GPUParticles3D": 0, +"GPUParticlesCollision3D": 0, +"Joint3D": 0, +"Light3D": 0, +"LightmapGI": 0, +"LightmapProbe": 0, +"Marker3D": 0, +"NavigationLink3D": 0, +"NavigationRegion3D": 0, +"OccluderInstance3D": 0, +"Path3D": 0, +"PhysicalBone3D": 0, +"RayCast3D": 0, +"ReflectionProbe": 0, +"ShapeCast3D": 0, +"Skeleton3D": 0, +"SoftBody3D": 0, +"SpringArm3D": 0, +"VehicleWheel3D": 0, +"VisibleOnScreenNotifier3D": 0, +"VoxelGI": 0 +}, +"local_coords": false, +"preview_sun_env": { +"environ_ao_enabled": false, +"environ_enabled": true, +"environ_energy": 1.0, +"environ_gi_enabled": false, +"environ_glow_enabled": true, +"environ_ground_color": Color(0.2, 0.169, 0.133, 1), +"environ_sky_color": Color(0.385, 0.454, 0.55, 1), +"environ_tonemap_enabled": true, +"sun_color": Color(1, 1, 1, 1), +"sun_enabled": true, +"sun_energy": 1.0, +"sun_max_distance": 100.0, +"sun_rotation": Vector2(-1.0472, 2.61799) +}, +"rotate_snap": 15.0, +"scale_snap": 10.0, +"show_grid": true, +"show_origin": true, +"snap_enabled": false, +"translate_snap": 1.0, +"viewport_mode": 1, +"viewports": [{ +"auto_orthogonal": false, +"auto_orthogonal_enabled": true, +"cinematic_preview": false, +"display_mode": 20, +"distance": 4.0, +"doppler": false, +"frame_time": false, +"gizmos": true, +"half_res": false, +"information": false, +"listener": true, +"lock_rotation": false, +"orthogonal": false, +"position": Vector3(0, 0, 0), +"use_environment": false, +"view_type": 0, +"x_rotation": 0.5, +"y_rotation": -0.5 +}, { +"auto_orthogonal": false, +"auto_orthogonal_enabled": true, +"cinematic_preview": false, +"display_mode": 20, +"distance": 4.0, +"doppler": false, +"frame_time": false, +"gizmos": true, +"half_res": false, +"information": false, +"listener": false, +"lock_rotation": false, +"orthogonal": false, +"position": Vector3(0, 0, 0), +"use_environment": false, +"view_type": 0, +"x_rotation": 0.5, +"y_rotation": -0.5 +}, { +"auto_orthogonal": false, +"auto_orthogonal_enabled": true, +"cinematic_preview": false, +"display_mode": 20, +"distance": 4.0, +"doppler": false, +"frame_time": false, +"gizmos": true, +"half_res": false, +"information": false, +"listener": false, +"lock_rotation": false, +"orthogonal": false, +"position": Vector3(0, 0, 0), +"use_environment": false, +"view_type": 0, +"x_rotation": 0.5, +"y_rotation": -0.5 +}, { +"auto_orthogonal": false, +"auto_orthogonal_enabled": true, +"cinematic_preview": false, +"display_mode": 20, +"distance": 4.0, +"doppler": false, +"frame_time": false, +"gizmos": true, +"half_res": false, +"information": false, +"listener": false, +"lock_rotation": false, +"orthogonal": false, +"position": Vector3(0, 0, 0), +"use_environment": false, +"view_type": 0, +"x_rotation": 0.5, +"y_rotation": -0.5 +}], +"zfar": 4000.01, +"znear": 0.05 +} +selected_nodes=Array[NodePath]([NodePath("/root/@EditorNode@17140/@Panel@13/@VBoxContainer@14/@HSplitContainer@17/@HSplitContainer@25/@HSplitContainer@33/@VBoxContainer@34/@VSplitContainer@36/@VSplitContainer@62/@VBoxContainer@63/@PanelContainer@110/MainScreen/@CanvasItemEditor@9462/@VSplitContainer@9281/@HSplitContainer@9283/@HSplitContainer@9285/@Control@9286/@SubViewportContainer@9287/@SubViewport@9288/Game/CanvasLayer/UI")]) diff --git a/week6/updated_project/.godot/editor/ui.tscn-folding-9211dc52ac9df169ba4fe77cbc1dc833.cfg b/week6/updated_project/.godot/editor/ui.tscn-folding-9211dc52ac9df169ba4fe77cbc1dc833.cfg new file mode 100644 index 0000000..f032965 --- /dev/null +++ b/week6/updated_project/.godot/editor/ui.tscn-folding-9211dc52ac9df169ba4fe77cbc1dc833.cfg @@ -0,0 +1,5 @@ +[folding] + +node_unfolds=[NodePath("."), PackedStringArray("Layout", "Layout/Transform", "Layout/Container Sizing"), NodePath("VBoxContainer"), PackedStringArray("Layout", "Layout/Transform"), NodePath("VBoxContainer/HBoxContainer"), PackedStringArray("Layout", "Layout/Container Sizing"), NodePath("VBoxContainer/HBoxContainer/MarginContainer2"), PackedStringArray("Layout", "Layout/Container Sizing"), NodePath("VBoxContainer/HBoxContainer/MarginContainer"), PackedStringArray("Layout", "Layout/Container Sizing")] +resource_unfolds=[] +nodes_folded=[] diff --git a/week6/updated_project/.godot/uid_cache.bin b/week6/updated_project/.godot/uid_cache.bin index caf5513..158e2da 100644 Binary files a/week6/updated_project/.godot/uid_cache.bin and b/week6/updated_project/.godot/uid_cache.bin differ diff --git a/week6/updated_project/scenes/game.tscn b/week6/updated_project/scenes/game.tscn index 79d24b4..772cecd 100644 --- a/week6/updated_project/scenes/game.tscn +++ b/week6/updated_project/scenes/game.tscn @@ -1,6 +1,7 @@ -[gd_scene load_steps=19 format=3 uid="uid://y083suj12rld"] +[gd_scene load_steps=20 format=3 uid="uid://y083suj12rld"] [ext_resource type="Script" path="res://scripts/gamecontroller.gd" id="1_77wyw"] +[ext_resource type="PackedScene" uid="uid://w7al4r6vnaye" path="res://scenes/ui.tscn" id="1_l1h5o"] [ext_resource type="PackedScene" uid="uid://go4yc8hfo1gq" path="res://scenes/character.tscn" id="2_64ccm"] [ext_resource type="Texture2D" uid="uid://dwb83f7uoweuy" path="res://graphics/Terrain (32x32).png" id="2_l22q1"] [ext_resource type="PackedScene" uid="uid://ukuu7p7vhlq" path="res://scenes/crate.tscn" id="5_u8rgi"] @@ -527,6 +528,10 @@ script = ExtResource("1_77wyw") [node name="Timer" type="Timer" parent="SceneManager"] +[node name="CanvasLayer" type="CanvasLayer" parent="."] + +[node name="UI" parent="CanvasLayer" instance=ExtResource("1_l1h5o")] + [node name="TileMap" type="TileMap" parent="."] tile_set = SubResource("TileSet_47g5u") format = 2 diff --git a/week6/updated_project/scenes/ui.tscn b/week6/updated_project/scenes/ui.tscn new file mode 100644 index 0000000..bd62a5d --- /dev/null +++ b/week6/updated_project/scenes/ui.tscn @@ -0,0 +1,40 @@ +[gd_scene load_steps=2 format=3 uid="uid://w7al4r6vnaye"] + +[ext_resource type="Script" path="res://scripts/ui.gd" id="1_fbdq6"] + +[node name="Control" type="Control"] +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +script = ExtResource("1_fbdq6") + +[node name="VBoxContainer" type="VBoxContainer" parent="."] +layout_mode = 1 +anchors_preset = 10 +anchor_right = 1.0 +offset_bottom = 23.0 +grow_horizontal = 2 + +[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer"] +layout_mode = 2 + +[node name="MarginContainer2" type="MarginContainer" parent="VBoxContainer/HBoxContainer"] +layout_mode = 2 +size_flags_horizontal = 3 + +[node name="Health" type="Label" parent="VBoxContainer/HBoxContainer/MarginContainer2"] +layout_mode = 2 +text = "Health : 100" + +[node name="MarginContainer" type="MarginContainer" parent="VBoxContainer/HBoxContainer"] +layout_mode = 2 +size_flags_horizontal = 3 + +[node name="Coins" type="Label" parent="VBoxContainer/HBoxContainer/MarginContainer"] +layout_mode = 2 +text = "Coins : 0 +" +horizontal_alignment = 2 diff --git a/week6/updated_project/scripts/gamecontroller.gd b/week6/updated_project/scripts/gamecontroller.gd index 5470fae..55da393 100644 --- a/week6/updated_project/scripts/gamecontroller.gd +++ b/week6/updated_project/scripts/gamecontroller.gd @@ -11,6 +11,7 @@ var crate = preload("res://scenes/crate.tscn") @onready var boxtrap = $"../crates/boxtrap" @onready var timer = $Timer @onready var player = $"../CharacterBody2D" +@onready var ui = $"../CanvasLayer/UI" func _ready(): GameManager.resetPlayer() @@ -28,6 +29,7 @@ func _on_area_2d_areatrigger(effect, body): func coinCollected(): print("scene manager saw coin collected") GameManager.coinsCollected +=1 + ui.coinsUpdate(GameManager.coinsCollected) func resetGame(): timer.start(.5) @@ -42,3 +44,4 @@ func _process(delta): func _on_badguy_player_damage(): player.hurt() + ui.healthUpdate(GameManager.player.health) diff --git a/week6/updated_project/scripts/ui.gd b/week6/updated_project/scripts/ui.gd new file mode 100644 index 0000000..5c6f123 --- /dev/null +++ b/week6/updated_project/scripts/ui.gd @@ -0,0 +1,10 @@ +extends Control + +@onready var health = $VBoxContainer/HBoxContainer/MarginContainer2/Health +@onready var coins = $VBoxContainer/HBoxContainer/MarginContainer/Coins + +# Called when the node enters the scene tree for the first time. +func healthUpdate(amt): + health.text = "Health : "+str(amt) +func coinsUpdate(amt): + coins.text = "Coins : "+str(amt)