Merge branch 'develop' into feature/Prototype_R_LEVEL

# Conflicts:
#	godot/levels/Prototype.tscn
This commit is contained in:
Martin Araneda 2022-09-01 22:04:21 -04:00
commit 346af5dd44
4 changed files with 38 additions and 28 deletions

View File

@ -1,7 +1,7 @@
[gd_scene load_steps=8 format=2] [gd_scene load_steps=8 format=2]
[ext_resource path="res://assets/coin.png" type="Texture" id=1] [ext_resource path="res://assets/coin.png" type="Texture" id=1]
[ext_resource path="res://hud/coin/Counter.gdns" type="Script" id=2] [ext_resource path="res://hud/coin/CoinCounter.gdns" type="Script" id=2]
[ext_resource path="res://hud/CoinHUD.gd" type="Script" id=3] [ext_resource path="res://hud/CoinHUD.gd" type="Script" id=3]
[sub_resource type="StyleBoxFlat" id=1] [sub_resource type="StyleBoxFlat" id=1]
@ -28,31 +28,34 @@ pause_mode = 2
script = ExtResource( 3 ) script = ExtResource( 3 )
[node name="Panel" type="Panel" parent="."] [node name="Panel" type="Panel" parent="."]
margin_left = 144.0 anchor_left = 0.5
margin_top = 18.0 anchor_right = 0.5
margin_right = 288.0 margin_left = -44.5
margin_bottom = 54.0 margin_top = 5.0
margin_right = 44.5
margin_bottom = 25.0
custom_styles/panel = SubResource( 1 ) custom_styles/panel = SubResource( 1 )
[node name="Label" type="Label" parent="."] [node name="X" type="Label" parent="Panel"]
margin_left = 180.0 margin_left = 40.0
margin_top = 18.0 margin_top = 4.0
margin_right = 220.0 margin_right = 53.0
margin_bottom = 36.0 margin_bottom = 24.0
text = "X" text = "X"
[node name="Coins" type="Label" parent="."] [node name="Coins" type="Label" parent="Panel"]
margin_left = 198.0 anchor_left = 0.5
margin_top = 18.0 anchor_right = 0.5
margin_right = 238.0 margin_left = 13.5
margin_bottom = 32.0 margin_top = 4.0
margin_right = 36.0
margin_bottom = 18.0
text = "##" text = "##"
script = ExtResource( 2 ) script = ExtResource( 2 )
[node name="AnimatedSprite" type="AnimatedSprite" parent="."] [node name="AnimatedSprite" type="AnimatedSprite" parent="Panel"]
position = Vector2( 162, 18 ) position = Vector2( 12, 1 )
frames = SubResource( 4 ) frames = SubResource( 4 )
animation = "spin" animation = "spin"
frame = 1
playing = true playing = true
centered = false centered = false

View File

@ -15,6 +15,7 @@
collision_layer = 5 collision_layer = 5
[node name="Camera2D" type="Camera2D" parent="Player"] [node name="Camera2D" type="Camera2D" parent="Player"]
current = true
limit_left = 0 limit_left = 0
limit_top = 0 limit_top = 0
limit_right = 512 limit_right = 512
@ -51,9 +52,6 @@ script = ExtResource( 1 )
[node name="coin" parent="Coins" instance=ExtResource( 5 )] [node name="coin" parent="Coins" instance=ExtResource( 5 )]
position = Vector2( 72, 450 ) position = Vector2( 72, 450 )
[node name="AnimatedSprite" parent="Coins/coin" index="1"]
frame = 0
[node name="coin2" parent="Coins" instance=ExtResource( 5 )] [node name="coin2" parent="Coins" instance=ExtResource( 5 )]
position = Vector2( 234, 450 ) position = Vector2( 234, 450 )

View File

@ -23,15 +23,24 @@ void alai::CoinCounter::_init()
coins = 0; coins = 0;
} }
void alai::CoinCounter::_on_coin_collected(int amount)
{
coins = coins + amount;
set_text(godot::String::num(coins));
}
void alai::CoinCounter::_ready() void alai::CoinCounter::_ready()
{ {
set_text("0"); set_text("00");
auto event = get_node<alai::Event>("/root/Event"); auto event = get_node<alai::Event>("/root/Event");
event->connect("coin_collected", this, "_on_coin_collected"); event->connect("coin_collected", this, "_on_coin_collected");
} }
void alai::CoinCounter::_on_coin_collected(int amount)
{
coins = coins + amount;
godot::String coin_string = godot::String();
if (coins <= 9)
{
coin_string = "0" + godot::String::num(coins);
}
else{
coin_string = godot::String::num(coins);
}
set_text(coin_string);
}