organized coins and enemies

This commit is contained in:
OddlyTimbot 2024-08-19 15:27:40 -04:00
parent b94006c28e
commit 753efaa3d3
30 changed files with 185 additions and 62 deletions

View File

@ -8,6 +8,12 @@ Resources do nothing on their own. They must be a property of a node for their d
The resoource only gets loaded into memory once. Any nodes referencing a node are accessing the SAME data. This behavior can be changed so that the resource is unique for each node referencing it.
Lessons:
* Create a script to use as a data object
* Create a resource based on the script for the player, and the enemy
* Learn to load resources
## Autoload Singletons
The scene system in Godot is great for building multiple levels of a game and being able to run each one of them individually during development. However it does have a limitation.
@ -22,6 +28,10 @@ An autoload script is a good place to put any persistent game logic and data, as
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.
Lessons:
* Create a script to be the game controller, set it to autoload
## 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.)

View File

@ -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/Game/CanvasLayer/UI")])
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/enemies")])

View File

@ -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/Game/CanvasLayer/UI")])
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/enemies")])

View File

@ -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/Game/CanvasLayer/UI")])
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/enemies")])

View File

@ -1,3 +1,4 @@
Node
MarginContainer
CanvasLayer
Label
@ -6,7 +7,6 @@ VBoxContainer
ColorRect
RayCast2D
Timer
Node
CollisionShape2D
AnimatedSprite2D
Area2D

View File

@ -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=0
dock_5_selected_tab_idx=1
dock_6_selected_tab_idx=0
dock_7_selected_tab_idx=0
dock_8_selected_tab_idx=0
@ -19,15 +19,15 @@ 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/ui.tscn")
dock_filesystem_uncollapsed_paths=PackedStringArray("Favorites", "res://", "res://scripts/resources/", "res://scripts/gameManager/", "res://scenes/", "res://graphics/", "res://graphics/Player Hurt/")
dock_filesystem_selected_paths=PackedStringArray("res://graphics/fonts/PixelOperator8.ttf")
dock_filesystem_uncollapsed_paths=PackedStringArray("Favorites", "res://", "res://scripts/resources/", "res://scripts/gameManager/", "res://graphics/", "res://graphics/fonts/")
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", "res://scenes/ui.tscn")
open_scenes=PackedStringArray("res://scenes/game.tscn", "res://scenes/character.tscn", "res://scenes/badguy.tscn", "res://scenes/coin.tscn")
current_scene="res://scenes/game.tscn"
center_split_offset=-252
selected_default_debugger_tab_idx=0

View File

@ -1,7 +1,7 @@
ea4bc82a6ad023ab7ee23ee620429895
::res://::1724081296
icon.svg::CompressedTexture2D::9114977118871582245::1724024726::1724024726::1::::<><>::
::res://graphics/::1724076966
::res://graphics/::1724092705
coin.png::CompressedTexture2D::7063880403899111552::1724024726::1724024726::1::::<><>::
slime_green.png::CompressedTexture2D::6822447834752212284::1724024726::1724024726::1::::<><>::
Terrain (32x32).png::CompressedTexture2D::8707534964839485024::1724024726::1724024726::1::::<><>::
@ -9,6 +9,9 @@ Terrain (32x32).png::CompressedTexture2D::8707534964839485024::1724024726::17240
Additional Sky.png::CompressedTexture2D::6380466891628860263::1724024726::1724024726::1::::<><>::
Additional Water.png::CompressedTexture2D::2205427413754203696::1724024726::1724024726::1::::<><>::
BG Image.png::CompressedTexture2D::7982657594202931692::1724024726::1724024726::1::::<><>::
::res://graphics/fonts/::1724092715
PixelOperator8-Bold.ttf::FontFile::5301245701011028277::1724092715::1724092715::1::::<><>::
PixelOperator8.ttf::FontFile::8552583736890290834::1724092715::1724092715::1::::<><>::
::res://graphics/items/::1724024726
cannister.png::CompressedTexture2D::7418095402531000042::1724024726::1724024726::1::::<><>::
::res://graphics/Player Death/::1724024726
@ -23,26 +26,28 @@ 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/::1724078633
::res://scenes/::1724088311
area_trigger.tscn::PackedScene::2953141911562060689::1724024726::0::1::::<><>::res://scripts/Trigger.gd
badguy.tscn::PackedScene::8923528729538756339::1724078633::0::1::::<><>::res://scripts/badguy.gd<>uid://c4g3ypigewuuu::::res://graphics/slime_green.png
badguy.tscn::PackedScene::8923528729538756339::1724088311::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::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
character.tscn::PackedScene::451838158579532324::1724088311::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::1724088311::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::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
game.tscn::PackedScene::1738196330916037717::1724088311::0::1::::<><>::res://scripts/gamecontroller.gd<>uid://w7al4r6vnaye::::res://scenes/ui.tscn<>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/::1724077882
ui.tscn::PackedScene::1610235842775481356::1724088311::0::1::::<><>::res://scripts/ui.gd
::res://scripts/::1724088065
badguy.gd::GDScript::-1::1724077297::0::1::::<>Area2D<>::
bullet.gd::GDScript::-1::1724024726::0::1::::<>Area2D<>::
CharacterBody2D.gd::GDScript::-1::1724077882::0::1::::<>CharacterBody2D<>::
coin.gd::GDScript::-1::1724076175::0::1::::<>Area2D<>::
gamecontroller.gd::GDScript::-1::1724077508::0::1::::<>Node<>::
gamecontroller.gd::GDScript::-1::1724088065::0::1::::<>Node<>::
Trigger.gd::GDScript::-1::1724024726::0::1::::<>Area2D<>::
ui.gd::GDScript::-1::1724087791::0::1::::<>Control<>::
::res://scripts/gameManager/::1724073623
gamemanager.gd::GDScript::-1::1724073623::0::1::::<>Node<>::
::res://scripts/resources/::1724073389
character_stats.gd::GDScript::-1::1724028944::0::1::::CharacterStats<>Resource<>::
player_stats.tres::Resource/CharacterStats::3561309685261247282::1724072114::0::1::::<><>::res://scripts/resources/character_stats.gd
slime_stats.tres::Resource/CharacterStats::3009667384297077150::1724073389::0::1::::<><>::res://scripts/resources/character_stats.gd
player_stats.tres::Resource/Resource::3561309685261247282::1724072114::0::1::::<><>::res://scripts/resources/character_stats.gd
slime_stats.tres::Resource/Resource::3009667384297077150::1724073389::0::1::::<><>::res://scripts/resources/character_stats.gd

View File

@ -5,3 +5,5 @@ res://scenes/coin.tscn
res://scenes/ui.tscn
res://scripts/ui.gd
res://scripts/gamecontroller.gd
res://scripts/coin.gd
res://scripts/badguy.gd

View File

@ -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/Game/CanvasLayer/UI")])
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/enemies")])

View File

@ -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("SceneManager"), 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("crates"), NodePath("coins"), NodePath("enemies"), NodePath("BoxTrapTrigger"), NodePath("MovingPlatform"), NodePath("UICanvas")]

View File

@ -3,11 +3,11 @@
state={
"bookmarks": PackedInt32Array(),
"breakpoints": PackedInt32Array(),
"column": 0,
"column": 32,
"folded_lines": Array[int]([]),
"h_scroll_position": 0,
"row": 43,
"scroll_position": 30.0,
"row": 15,
"scroll_position": 3.0,
"selection": false,
"syntax_highlighter": "GDScript"
}
@ -19,9 +19,9 @@ state={
"breakpoints": PackedInt32Array(),
"column": 36,
"folded_lines": Array[int]([]),
"h_scroll_position": 129,
"h_scroll_position": 0,
"row": 40,
"scroll_position": 40.0,
"scroll_position": 0.0,
"selection": false,
"syntax_highlighter": "GDScript"
}
@ -45,10 +45,10 @@ state={
state={
"bookmarks": PackedInt32Array(),
"breakpoints": PackedInt32Array(),
"column": 22,
"column": 16,
"folded_lines": Array[int]([]),
"h_scroll_position": 0,
"row": 8,
"row": 0,
"scroll_position": 0.0,
"selection": false,
"syntax_highlighter": "GDScript"
@ -73,11 +73,11 @@ state={
state={
"bookmarks": PackedInt32Array(),
"breakpoints": PackedInt32Array(),
"column": 21,
"column": 31,
"folded_lines": Array[int]([]),
"h_scroll_position": 0,
"row": 35,
"scroll_position": 22.0,
"row": 0,
"scroll_position": 0.0,
"selection": false,
"syntax_highlighter": "GDScript"
}

View File

@ -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/Game/CanvasLayer/UI")])
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/Control/VBoxContainer/HBoxContainer/MarginContainer2/Health")])

View File

@ -1,5 +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")]
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/MarginContainer2/Health"), PackedStringArray("Theme Overrides", "Theme Overrides/fonts", "Theme Overrides/font_sizes"), NodePath("VBoxContainer/HBoxContainer/MarginContainer"), PackedStringArray("Layout", "Layout/Container Sizing"), NodePath("VBoxContainer/HBoxContainer/MarginContainer/Coins"), PackedStringArray("Theme Overrides", "Theme Overrides/fonts", "Theme Overrides/font_sizes")]
resource_unfolds=[]
nodes_folded=[]

View File

@ -4,4 +4,16 @@ list=Array[Dictionary]([{
"icon": "",
"language": &"GDScript",
"path": "res://scripts/resources/character_stats.gd"
}, {
"base": &"Area2D",
"class": &"Coin",
"icon": "",
"language": &"GDScript",
"path": "res://scripts/coin.gd"
}, {
"base": &"Area2D",
"class": &"Enemy",
"icon": "",
"language": &"GDScript",
"path": "res://scripts/badguy.gd"
}])

View File

@ -0,0 +1,3 @@
source_md5="f256c5ba9f97671d6993b2acb73f6574"
dest_md5="de02e277e1610c39108c7c9bc3b29bc7"

View File

@ -0,0 +1,3 @@
source_md5="67f8f48c9aa9214eb3504a8e773d2da2"
dest_md5="ffc456eef4fdc3ba3702a3a7cb706df1"

View File

@ -0,0 +1,33 @@
[remap]
importer="font_data_dynamic"
type="FontFile"
uid="uid://chr70h7n1vjub"
path="res://.godot/imported/PixelOperator8-Bold.ttf-58471ac3a012822d2b91abf3e5c02684.fontdata"
[deps]
source_file="res://graphics/fonts/PixelOperator8-Bold.ttf"
dest_files=["res://.godot/imported/PixelOperator8-Bold.ttf-58471ac3a012822d2b91abf3e5c02684.fontdata"]
[params]
Rendering=null
antialiasing=1
generate_mipmaps=false
multichannel_signed_distance_field=false
msdf_pixel_range=8
msdf_size=48
allow_system_fallback=true
force_autohinter=false
hinting=1
subpixel_positioning=1
oversampling=0.0
Fallbacks=null
fallbacks=[]
Compress=null
compress=true
preload=[]
language_support={}
script_support={}
opentype_features={}

View File

@ -0,0 +1,33 @@
[remap]
importer="font_data_dynamic"
type="FontFile"
uid="uid://dt362md65hx83"
path="res://.godot/imported/PixelOperator8.ttf-282ed1e255c024b87b9bcb82718e7dda.fontdata"
[deps]
source_file="res://graphics/fonts/PixelOperator8.ttf"
dest_files=["res://.godot/imported/PixelOperator8.ttf-282ed1e255c024b87b9bcb82718e7dda.fontdata"]
[params]
Rendering=null
antialiasing=1
generate_mipmaps=false
multichannel_signed_distance_field=false
msdf_pixel_range=8
msdf_size=48
allow_system_fallback=true
force_autohinter=false
hinting=1
subpixel_positioning=1
oversampling=0.0
Fallbacks=null
fallbacks=[]
Compress=null
compress=true
preload=[]
language_support={}
script_support={}
opentype_features={}

View File

@ -528,10 +528,6 @@ 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
@ -571,13 +567,6 @@ PUSH_FORCE = 550
[node name="Camera2D" type="Camera2D" parent="CharacterBody2D"]
[node name="BoxTrapTrigger" parent="." instance=ExtResource("7_i5ol2")]
position = Vector2(126, -57)
[node name="CollisionShape2D" type="CollisionShape2D" parent="BoxTrapTrigger"]
shape = SubResource("CircleShape2D_j8ltg")
debug_color = Color(0.72549, 0.309804, 0.905882, 0.419608)
[node name="crates" type="Node" parent="."]
[node name="crate1" parent="crates" instance=ExtResource("5_u8rgi")]
@ -586,6 +575,29 @@ position = Vector2(-22, -30)
[node name="boxtrap" type="Node2D" parent="crates"]
position = Vector2(131, -175)
[node name="coins" type="Node" parent="."]
[node name="coin" parent="coins" instance=ExtResource("10_mo30d")]
position = Vector2(79, 88)
[node name="coin2" parent="coins" instance=ExtResource("10_mo30d")]
position = Vector2(177, 87)
[node name="enemies" type="Node" parent="."]
[node name="badguy" parent="enemies" instance=ExtResource("11_ghgxt")]
position = Vector2(-28, 84)
[node name="badguy2" parent="enemies" instance=ExtResource("11_ghgxt")]
position = Vector2(270, -12)
[node name="BoxTrapTrigger" parent="." instance=ExtResource("7_i5ol2")]
position = Vector2(126, -57)
[node name="CollisionShape2D" type="CollisionShape2D" parent="BoxTrapTrigger"]
shape = SubResource("CircleShape2D_j8ltg")
debug_color = Color(0.72549, 0.309804, 0.905882, 0.419608)
[node name="MovingPlatform" parent="." instance=ExtResource("6_bcgm6")]
position = Vector2(472, -21)
@ -595,21 +607,10 @@ libraries = {
}
autoplay = "move"
[node name="coin" parent="." instance=ExtResource("10_mo30d")]
position = Vector2(79, 88)
[node name="UICanvas" type="CanvasLayer" parent="."]
[node name="coin2" parent="." instance=ExtResource("10_mo30d")]
position = Vector2(177, 87)
[node name="badguy" parent="." instance=ExtResource("11_ghgxt")]
position = Vector2(-28, 84)
[node name="badguy2" parent="." instance=ExtResource("11_ghgxt")]
position = Vector2(270, -12)
[node name="UI" parent="UICanvas" instance=ExtResource("1_l1h5o")]
[connection signal="timeout" from="SceneManager/Timer" to="SceneManager" method="_on_timer_timeout"]
[connection signal="playerDead" from="CharacterBody2D" to="SceneManager" method="resetGame"]
[connection signal="areatrigger" from="BoxTrapTrigger" to="SceneManager" method="_on_area_2d_areatrigger"]
[connection signal="coinCollected" from="coin" to="SceneManager" method="coinCollected"]
[connection signal="coinCollected" from="coin2" to="SceneManager" method="coinCollected"]
[connection signal="playerDamage" from="badguy" to="SceneManager" method="_on_badguy_player_damage"]

View File

@ -1,6 +1,7 @@
[gd_scene load_steps=2 format=3 uid="uid://w7al4r6vnaye"]
[gd_scene load_steps=3 format=3 uid="uid://w7al4r6vnaye"]
[ext_resource type="Script" path="res://scripts/ui.gd" id="1_fbdq6"]
[ext_resource type="FontFile" uid="uid://dt362md65hx83" path="res://graphics/fonts/PixelOperator8.ttf" id="2_gopna"]
[node name="Control" type="Control"]
layout_mode = 3
@ -27,6 +28,8 @@ size_flags_horizontal = 3
[node name="Health" type="Label" parent="VBoxContainer/HBoxContainer/MarginContainer2"]
layout_mode = 2
theme_override_fonts/font = ExtResource("2_gopna")
theme_override_font_sizes/font_size = 8
text = "Health : 100"
[node name="MarginContainer" type="MarginContainer" parent="VBoxContainer/HBoxContainer"]
@ -35,6 +38,8 @@ size_flags_horizontal = 3
[node name="Coins" type="Label" parent="VBoxContainer/HBoxContainer/MarginContainer"]
layout_mode = 2
theme_override_fonts/font = ExtResource("2_gopna")
theme_override_font_sizes/font_size = 8
text = "Coins : 0
"
horizontal_alignment = 2

View File

@ -1,4 +1,4 @@
extends Area2D
class_name Enemy extends Area2D
const speed = 60
var direction = 1

View File

@ -1,9 +1,8 @@
extends Area2D
class_name Coin extends Area2D
@onready var game = %SceneManager
#Note: signal created - better to 'signal up' and 'call down'
signal coinCollected
func _on_body_entered(body):
if body.is_in_group("player"):
coinCollected.emit()

View File

@ -11,10 +11,21 @@ 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"
@onready var ui = $"../UICanvas/UI"
@onready var crates = $"../crates"
@onready var coins = $"../coins"
@onready var enemies = $"../enemies"
func _ready():
#Note: since autoloads persist, reset player to full health
GameManager.resetPlayer()
#Note: Add listeners to collectibles
for n in coins.get_children():
if n is Coin:
n.coinCollected.connect(coinCollected)
for n in enemies.get_children():
if n is Enemy:
n.playerDamage.connect(_on_badguy_player_damage)
func _on_area_2d_areatrigger(effect, body):
match effect: