moved game manager to unique object

This commit is contained in:
OddlyTimbot 2024-08-12 15:32:24 -04:00
parent aa44b13532
commit eebf4c2922
15 changed files with 34 additions and 26 deletions

View File

@ -172,4 +172,4 @@ Anim={
"zfar": 4000.01, "zfar": 4000.01,
"znear": 0.05 "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")]) 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/crates/boxtrap")])

View File

@ -172,4 +172,4 @@ Anim={
"zfar": 4000.01, "zfar": 4000.01,
"znear": 0.05 "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")]) 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/crates/boxtrap")])

View File

@ -172,4 +172,4 @@ Anim={
"zfar": 4000.01, "zfar": 4000.01,
"znear": 0.05 "znear": 0.05
} }
selected_nodes=Array[NodePath]([]) 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/crates/boxtrap")])

View File

@ -172,4 +172,4 @@ Anim={
"zfar": 4000.01, "zfar": 4000.01,
"znear": 0.05 "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")]) 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/crates/boxtrap")])

View File

@ -1,3 +1,4 @@
Node
RayCast2D RayCast2D
CollisionShape2D CollisionShape2D
AnimatedSprite2D AnimatedSprite2D

View File

@ -19,7 +19,7 @@ dock_filesystem_split=0
dock_filesystem_display_mode=0 dock_filesystem_display_mode=0
dock_filesystem_file_sort=0 dock_filesystem_file_sort=0
dock_filesystem_file_list_display_mode=1 dock_filesystem_file_list_display_mode=1
dock_filesystem_selected_paths=PackedStringArray("res://scenes/badguy.tscn") dock_filesystem_selected_paths=PackedStringArray("res://scenes/game.tscn")
dock_filesystem_uncollapsed_paths=PackedStringArray("Favorites", "res://", "res://scripts/", "res://scenes/", "res://graphics/") dock_filesystem_uncollapsed_paths=PackedStringArray("Favorites", "res://", "res://scripts/", "res://scenes/", "res://graphics/")
dock_3="Scene,Import" dock_3="Scene,Import"
dock_4="FileSystem" dock_4="FileSystem"
@ -28,16 +28,16 @@ dock_5="Inspector,Node,History"
[EditorNode] [EditorNode]
open_scenes=PackedStringArray("res://scenes/game.tscn", "res://scenes/character.tscn", "res://scenes/bullet.tscn", "res://scenes/crate.tscn", "res://scenes/badguy.tscn") open_scenes=PackedStringArray("res://scenes/game.tscn", "res://scenes/character.tscn", "res://scenes/bullet.tscn", "res://scenes/crate.tscn", "res://scenes/badguy.tscn")
current_scene="res://scenes/character.tscn" current_scene="res://scenes/game.tscn"
center_split_offset=-325 center_split_offset=-325
selected_default_debugger_tab_idx=0 selected_default_debugger_tab_idx=0
selected_main_editor_idx=2 selected_main_editor_idx=2
selected_bottom_panel_item=0 selected_bottom_panel_item=1
[ScriptEditor] [ScriptEditor]
open_scripts=["res://scripts/badguy.gd", "res://scripts/bullet.gd", "res://scripts/CharacterBody2D.gd", "res://scripts/coin.gd", "res://scripts/gamecontroller.gd", "res://scripts/Trigger.gd"] open_scripts=["res://scripts/badguy.gd", "res://scripts/bullet.gd", "res://scripts/CharacterBody2D.gd", "res://scripts/coin.gd", "res://scripts/gamecontroller.gd", "res://scripts/Trigger.gd"]
selected_script="res://scripts/CharacterBody2D.gd" selected_script="res://scripts/gamecontroller.gd"
open_help=[] open_help=[]
script_split_offset=70 script_split_offset=70
list_split_offset=0 list_split_offset=0

View File

@ -5,3 +5,4 @@ res://scenes/character.tscn
res://scenes/bullet.tscn res://scenes/bullet.tscn
res://scenes/crate.tscn res://scenes/crate.tscn
res://scripts/gamecontroller.gd res://scripts/gamecontroller.gd
res://scripts/coin.gd

View File

@ -172,4 +172,4 @@ Anim={
"zfar": 4000.01, "zfar": 4000.01,
"znear": 0.05 "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")]) 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/crates/boxtrap")])

View File

@ -14,7 +14,7 @@ run_debug_collisions=true
[recent_files] [recent_files]
scenes=["res://scenes/badguy.tscn", "res://scenes/area_trigger.tscn", "res://scenes/coin.tscn", "res://scenes/menu.tscn", "res://scenes/platform.tscn", "res://scenes/crate.tscn", "res://scenes/bullet.tscn", "res://scenes/character.tscn", "res://scenes/game.tscn", "res://scenes/animatedcoin.tscn"] scenes=["res://scenes/game.tscn", "res://scenes/badguy.tscn", "res://scenes/area_trigger.tscn", "res://scenes/coin.tscn", "res://scenes/menu.tscn", "res://scenes/platform.tscn", "res://scenes/crate.tscn", "res://scenes/bullet.tscn", "res://scenes/character.tscn", "res://scenes/animatedcoin.tscn"]
scripts=["res://scripts/badguy.gd", "res://scripts/coin.gd", "res://scripts/Trigger.gd", "res://scripts/bullet.gd", "res://scripts/CharacterBody2D.gd", "res://scripts/gamecontroller.gd"] scripts=["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] [linked_properties]

View File

@ -1,5 +1,5 @@
res://scenes
res://scripts res://scripts
res://scenes
res://graphics res://graphics
res://graphics/Player Jump res://graphics/Player Jump
res://graphics/Player Run res://graphics/Player Run

View File

@ -3,11 +3,11 @@
state={ state={
"bookmarks": PackedInt32Array(), "bookmarks": PackedInt32Array(),
"breakpoints": PackedInt32Array(), "breakpoints": PackedInt32Array(),
"column": 25, "column": 43,
"folded_lines": Array[int]([]), "folded_lines": Array[int]([]),
"h_scroll_position": 0, "h_scroll_position": 0,
"row": 27, "row": 7,
"scroll_position": 6.0, "scroll_position": 1.0,
"selection": false, "selection": false,
"syntax_highlighter": "GDScript" "syntax_highlighter": "GDScript"
} }
@ -45,10 +45,10 @@ state={
state={ state={
"bookmarks": PackedInt32Array(), "bookmarks": PackedInt32Array(),
"breakpoints": PackedInt32Array(), "breakpoints": PackedInt32Array(),
"column": 22, "column": 17,
"folded_lines": Array[int]([]), "folded_lines": Array[int]([]),
"h_scroll_position": 0, "h_scroll_position": 0,
"row": 6, "row": 2,
"scroll_position": 0.0, "scroll_position": 0.0,
"selection": false, "selection": false,
"syntax_highlighter": "GDScript" "syntax_highlighter": "GDScript"
@ -73,11 +73,11 @@ state={
state={ state={
"bookmarks": PackedInt32Array(), "bookmarks": PackedInt32Array(),
"breakpoints": PackedInt32Array(), "breakpoints": PackedInt32Array(),
"column": 20, "column": 17,
"folded_lines": Array[int]([]), "folded_lines": Array[int]([]),
"h_scroll_position": 0, "h_scroll_position": 0,
"row": 23, "row": 7,
"scroll_position": 10.0, "scroll_position": 0.0,
"selection": false, "selection": false,
"syntax_highlighter": "GDScript" "syntax_highlighter": "GDScript"
} }

View File

@ -520,6 +520,9 @@ _data = {
} }
[node name="Game" type="Node2D"] [node name="Game" type="Node2D"]
[node name="GameManager" type="Node" parent="."]
unique_name_in_owner = true
script = ExtResource("1_77wyw") script = ExtResource("1_77wyw")
[node name="TileMap" type="TileMap" parent="."] [node name="TileMap" type="TileMap" parent="."]
@ -591,4 +594,4 @@ position = Vector2(79, 88)
[node name="Area2D" parent="." instance=ExtResource("11_ghgxt")] [node name="Area2D" parent="." instance=ExtResource("11_ghgxt")]
position = Vector2(-28, 84) position = Vector2(-28, 84)
[connection signal="areatrigger" from="AreaTrigger" to="." method="_on_area_2d_areatrigger"] [connection signal="areatrigger" from="AreaTrigger" to="GameManager" method="_on_area_2d_areatrigger"]

View File

@ -5,7 +5,8 @@ var direction = 1
@onready var cast_right = $CastRight @onready var cast_right = $CastRight
@onready var cast_left = $CastLeft @onready var cast_left = $CastLeft
@onready var sprite = $AnimatedSprite2D @onready var sprite = $AnimatedSprite2D
@onready var game = $".." @onready var game = %GameManager
# Called every frame. 'delta' is the elapsed time since the previous frame. # Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta): func _process(delta):

View File

@ -1,6 +1,7 @@
extends Area2D extends Area2D
@onready var game = $".." @onready var game = %GameManager
func _on_body_entered(body): func _on_body_entered(body):
if body.is_in_group("player"): if body.is_in_group("player"):

View File

@ -1,10 +1,11 @@
extends Node2D extends Node
var coinsCollected = 0 var coinsCollected = 0
var crate = preload("res://scenes/crate.tscn") var crate = preload("res://scenes/crate.tscn")
@onready var boxtrap = $crates/boxtrap @onready var boxtrap = $"../crates/boxtrap"
@onready var player = $CharacterBody2D
@onready var player = $"../CharacterBody2D"
func _on_area_2d_areatrigger(effect, body): func _on_area_2d_areatrigger(effect, body):
print("Game Controller sees the trigger "+effect) print("Game Controller sees the trigger "+effect)
@ -14,7 +15,7 @@ func _on_area_2d_areatrigger(effect, body):
if body.is_in_group("player"): if body.is_in_group("player"):
for n in 3: for n in 3:
var box = crate.instantiate() var box = crate.instantiate()
add_child(box) owner.add_child(box)
box.position = boxtrap.position box.position = boxtrap.position
"powerup": "powerup":
print("you got power") print("you got power")