mirror of
https://github.com/Steffo99/swear-jar.git
synced 2024-11-21 15:24:18 +00:00
adddded debug scoreboard and changes collector.gd
This commit is contained in:
parent
b84c1781c1
commit
aa2cf6612b
7 changed files with 307 additions and 4 deletions
6
Game.gd
Normal file
6
Game.gd
Normal file
|
@ -0,0 +1,6 @@
|
|||
extends Node2D
|
||||
|
||||
|
||||
func _process(delta):
|
||||
print($Evaluator.total_value)
|
||||
|
129
roo767B.tmp
Normal file
129
roo767B.tmp
Normal file
|
@ -0,0 +1,129 @@
|
|||
[gd_scene load_steps=10 format=3 uid="uid://cbccs6kwwf265"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://bllsprv8orpn4" path="res://bottle/bottle.tscn" id="1_4fmd3"]
|
||||
[ext_resource type="Script" path="res://Game.gd" id="1_sabvy"]
|
||||
[ext_resource type="PackedScene" uid="uid://c3kitncwpi42j" path="res://entity/coin_copper.tscn" id="2_dv01l"]
|
||||
[ext_resource type="PackedScene" uid="uid://d05b8jy3xmpcb" path="res://bottle/gravity_from_gyro.tscn" id="2_m7p4p"]
|
||||
[ext_resource type="PackedScene" uid="uid://c67lfbk4gf1ga" path="res://spawner/spawner.tscn" id="3_pubxn"]
|
||||
[ext_resource type="PackedScene" uid="uid://c5w3b55aiui6c" path="res://collector/collector.tscn" id="5_c2ruc"]
|
||||
[ext_resource type="PackedScene" uid="uid://beg758fa6o0cs" path="res://value/evaluator.tscn" id="6_u0y6l"]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_5xpy2"]
|
||||
size = Vector2(72, 38)
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_5mxpe"]
|
||||
size = Vector2(222, 43)
|
||||
|
||||
[node name="Root" type="Node"]
|
||||
|
||||
[node name="UI" type="Control" parent="."]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
size_flags_vertical = 8
|
||||
|
||||
[node name="GameContainer" type="Control" parent="UI"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 7
|
||||
anchor_left = 0.5
|
||||
anchor_top = 1.0
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 0
|
||||
|
||||
[node name="Game" type="Node2D" parent="UI/GameContainer"]
|
||||
texture_filter = 1
|
||||
script = ExtResource("1_sabvy")
|
||||
|
||||
[node name="Bottle" parent="UI/GameContainer/Game" instance=ExtResource("1_4fmd3")]
|
||||
|
||||
[node name="GravityFromGyro" parent="UI/GameContainer/Game/Bottle" instance=ExtResource("2_m7p4p")]
|
||||
|
||||
[node name="TimeSpawner" parent="UI/GameContainer/Game" instance=ExtResource("3_pubxn")]
|
||||
position = Vector2(0, -480)
|
||||
scene = ExtResource("2_dv01l")
|
||||
buffer_cap = 1
|
||||
spawn_position_range_x = 32.0
|
||||
spawn_rotation_range = 15.0
|
||||
overlapping_bodies_collision_mask = 4
|
||||
overlapping_body_count_limit = 4
|
||||
|
||||
[node name="Timer" type="Timer" parent="UI/GameContainer/Game/TimeSpawner"]
|
||||
wait_time = 0.03
|
||||
autostart = true
|
||||
|
||||
[node name="ButtonSpawner" parent="UI/GameContainer/Game" instance=ExtResource("3_pubxn")]
|
||||
position = Vector2(0, -480)
|
||||
scene = ExtResource("2_dv01l")
|
||||
buffer_cap = 50
|
||||
spawn_position_range_x = 32.0
|
||||
spawn_rotation_range = 15.0
|
||||
overlapping_bodies_collision_mask = 4
|
||||
overlapping_body_count_limit = 4
|
||||
|
||||
[node name="Collector" parent="UI/GameContainer/Game" instance=ExtResource("5_c2ruc")]
|
||||
position = Vector2(-92, -257)
|
||||
collecting_types = Array[StringName]([&"Copper"])
|
||||
|
||||
[node name="CollisionShape2D2" type="CollisionShape2D" parent="UI/GameContainer/Game/Collector"]
|
||||
position = Vector2(26, 9)
|
||||
shape = SubResource("RectangleShape2D_5xpy2")
|
||||
|
||||
[node name="Evaluator" parent="UI/GameContainer/Game" instance=ExtResource("6_u0y6l")]
|
||||
collecting_collision_mask = 4
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="UI/GameContainer/Game/Evaluator"]
|
||||
position = Vector2(0, -38.5)
|
||||
shape = SubResource("RectangleShape2D_5mxpe")
|
||||
|
||||
[node name="Rows" type="VBoxContainer" parent="UI"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
||||
[node name="NotchSpacer" type="PanelContainer" parent="UI/Rows"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="UpperButtons" type="HBoxContainer" parent="UI/Rows"]
|
||||
custom_minimum_size = Vector2(0, 54)
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 8
|
||||
|
||||
[node name="MoneyButton" type="Button" parent="UI/Rows/UpperButtons"]
|
||||
custom_minimum_size = Vector2(54, 0)
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 8
|
||||
text = "$0"
|
||||
alignment = 0
|
||||
|
||||
[node name="UpperButtonsSpacerLeft" type="PanelContainer" parent="UI/Rows/UpperButtons"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="SpawnButton" type="Button" parent="UI/Rows/UpperButtons"]
|
||||
custom_minimum_size = Vector2(54, 0)
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 8
|
||||
text = "Drop"
|
||||
|
||||
[node name="UpperButtonsSpacerRight" type="PanelContainer" parent="UI/Rows/UpperButtons"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="ShopButton" type="Button" parent="UI/Rows/UpperButtons"]
|
||||
custom_minimum_size = Vector2(54, 0)
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 8
|
||||
text = "Shop"
|
||||
alignment = 2
|
||||
|
||||
[connection signal="timeout" from="UI/GameContainer/Game/TimeSpawner/Timer" to="UI/GameContainer/Game/TimeSpawner" method="spawn"]
|
||||
[connection signal="pressed" from="UI/Rows/UpperButtons/SpawnButton" to="UI/GameContainer/Game/ButtonSpawner" method="spawn"]
|
129
roo84C2.tmp
Normal file
129
roo84C2.tmp
Normal file
|
@ -0,0 +1,129 @@
|
|||
[gd_scene load_steps=10 format=3 uid="uid://cbccs6kwwf265"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://bllsprv8orpn4" path="res://bottle/bottle.tscn" id="1_4fmd3"]
|
||||
[ext_resource type="Script" path="res://Game.gd" id="1_sabvy"]
|
||||
[ext_resource type="PackedScene" uid="uid://c3kitncwpi42j" path="res://entity/coin_copper.tscn" id="2_dv01l"]
|
||||
[ext_resource type="PackedScene" uid="uid://d05b8jy3xmpcb" path="res://bottle/gravity_from_gyro.tscn" id="2_m7p4p"]
|
||||
[ext_resource type="PackedScene" uid="uid://c67lfbk4gf1ga" path="res://spawner/spawner.tscn" id="3_pubxn"]
|
||||
[ext_resource type="PackedScene" uid="uid://c5w3b55aiui6c" path="res://collector/collector.tscn" id="5_c2ruc"]
|
||||
[ext_resource type="PackedScene" uid="uid://beg758fa6o0cs" path="res://value/evaluator.tscn" id="6_u0y6l"]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_5xpy2"]
|
||||
size = Vector2(72, 38)
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_5mxpe"]
|
||||
size = Vector2(222, 43)
|
||||
|
||||
[node name="Root" type="Node"]
|
||||
|
||||
[node name="UI" type="Control" parent="."]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
size_flags_vertical = 8
|
||||
|
||||
[node name="GameContainer" type="Control" parent="UI"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 7
|
||||
anchor_left = 0.5
|
||||
anchor_top = 1.0
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 0
|
||||
|
||||
[node name="Game" type="Node2D" parent="UI/GameContainer"]
|
||||
texture_filter = 1
|
||||
script = ExtResource("1_sabvy")
|
||||
|
||||
[node name="Bottle" parent="UI/GameContainer/Game" instance=ExtResource("1_4fmd3")]
|
||||
|
||||
[node name="GravityFromGyro" parent="UI/GameContainer/Game/Bottle" instance=ExtResource("2_m7p4p")]
|
||||
|
||||
[node name="TimeSpawner" parent="UI/GameContainer/Game" instance=ExtResource("3_pubxn")]
|
||||
position = Vector2(0, -480)
|
||||
scene = ExtResource("2_dv01l")
|
||||
buffer_cap = 1
|
||||
spawn_position_range_x = 32.0
|
||||
spawn_rotation_range = 15.0
|
||||
overlapping_bodies_collision_mask = 4
|
||||
overlapping_body_count_limit = 4
|
||||
|
||||
[node name="Timer" type="Timer" parent="UI/GameContainer/Game/TimeSpawner"]
|
||||
wait_time = 0.03
|
||||
autostart = true
|
||||
|
||||
[node name="ButtonSpawner" parent="UI/GameContainer/Game" instance=ExtResource("3_pubxn")]
|
||||
position = Vector2(0, -480)
|
||||
scene = ExtResource("2_dv01l")
|
||||
buffer_cap = 50
|
||||
spawn_position_range_x = 32.0
|
||||
spawn_rotation_range = 15.0
|
||||
overlapping_bodies_collision_mask = 4
|
||||
overlapping_body_count_limit = 4
|
||||
|
||||
[node name="Collector" parent="UI/GameContainer/Game" instance=ExtResource("5_c2ruc")]
|
||||
position = Vector2(-92, -257)
|
||||
collecting_types = Array[StringName]([&"Copper"])
|
||||
|
||||
[node name="CollisionShape2D2" type="CollisionShape2D" parent="UI/GameContainer/Game/Collector"]
|
||||
position = Vector2(26, 9)
|
||||
shape = SubResource("RectangleShape2D_5xpy2")
|
||||
|
||||
[node name="Evaluator" parent="UI/GameContainer/Game" instance=ExtResource("6_u0y6l")]
|
||||
collecting_collision_mask = 4
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="UI/GameContainer/Game/Evaluator"]
|
||||
position = Vector2(0, -38.5)
|
||||
shape = SubResource("RectangleShape2D_5mxpe")
|
||||
|
||||
[node name="Rows" type="VBoxContainer" parent="UI"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
||||
[node name="NotchSpacer" type="PanelContainer" parent="UI/Rows"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="UpperButtons" type="HBoxContainer" parent="UI/Rows"]
|
||||
custom_minimum_size = Vector2(0, 54)
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 8
|
||||
|
||||
[node name="MoneyButton" type="Button" parent="UI/Rows/UpperButtons"]
|
||||
custom_minimum_size = Vector2(54, 0)
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 8
|
||||
text = "$0"
|
||||
alignment = 0
|
||||
|
||||
[node name="UpperButtonsSpacerLeft" type="PanelContainer" parent="UI/Rows/UpperButtons"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="SpawnButton" type="Button" parent="UI/Rows/UpperButtons"]
|
||||
custom_minimum_size = Vector2(54, 0)
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 8
|
||||
text = "Drop"
|
||||
|
||||
[node name="UpperButtonsSpacerRight" type="PanelContainer" parent="UI/Rows/UpperButtons"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="ShopButton" type="Button" parent="UI/Rows/UpperButtons"]
|
||||
custom_minimum_size = Vector2(54, 0)
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 8
|
||||
text = "Shop"
|
||||
alignment = 2
|
||||
|
||||
[connection signal="timeout" from="UI/GameContainer/Game/TimeSpawner/Timer" to="UI/GameContainer/Game/TimeSpawner" method="spawn"]
|
||||
[connection signal="pressed" from="UI/Rows/UpperButtons/SpawnButton" to="UI/GameContainer/Game/ButtonSpawner" method="spawn"]
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=9 format=3 uid="uid://cbccs6kwwf265"]
|
||||
[gd_scene load_steps=11 format=3 uid="uid://cbccs6kwwf265"]
|
||||
|
||||
[ext_resource type="Script" path="res://root.gd" id="1_8jrhk"]
|
||||
[ext_resource type="Theme" uid="uid://ba5utvfhnxa5i" path="res://interface/interface_theme.tres" id="1_h26ax"]
|
||||
|
|
14
score/scoreboard.gd
Normal file
14
score/scoreboard.gd
Normal file
|
@ -0,0 +1,14 @@
|
|||
extends Control
|
||||
|
||||
class_name ScoreBoard
|
||||
|
||||
@export var score: int = 0
|
||||
|
||||
func _ready():
|
||||
$Label.text = "Score: " + str(score)
|
||||
|
||||
func _process(delta):
|
||||
pass
|
||||
|
||||
func _on_evaluator_score_changed(total_value):
|
||||
$Label.text = "Score: " + str(total_value)
|
23
score/scoreboard.tscn
Normal file
23
score/scoreboard.tscn
Normal file
|
@ -0,0 +1,23 @@
|
|||
[gd_scene load_steps=2 format=3 uid="uid://bokcnc0q0qqj3"]
|
||||
|
||||
[ext_resource type="Script" path="res://score/scoreboard.gd" id="1_of77n"]
|
||||
|
||||
[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_of77n")
|
||||
|
||||
[node name="Label" type="Label" parent="."]
|
||||
layout_mode = 0
|
||||
offset_right = 40.0
|
||||
offset_bottom = 23.0
|
||||
text = "SCORE: "
|
||||
|
||||
[node name="VSlider" type="VSlider" parent="."]
|
||||
layout_mode = 0
|
||||
offset_right = 16.0
|
||||
offset_bottom = 8.0
|
|
@ -15,10 +15,12 @@ var total_value: int = 0
|
|||
@export_flags_2d_physics var collecting_collision_mask: int
|
||||
|
||||
## The evaluator has added the value of an object to the total.
|
||||
signal added(what: PhysicsBody2D)
|
||||
signal added(what: PhysicsBody2D, total_value: int)
|
||||
## The evaluator has removed the value of an object to the total.
|
||||
signal removed(what: PhysicsBody2D)
|
||||
|
||||
signal score_changed(total_value: int)
|
||||
|
||||
func _on_body_entered(body):
|
||||
if body is PhysicsBody2D:
|
||||
if body.collision_layer & collecting_collision_mask:
|
||||
|
@ -26,7 +28,7 @@ func _on_body_entered(body):
|
|||
print("sommato")
|
||||
total_value += evaluable.value
|
||||
evaluable.evaluate()
|
||||
added.emit(body)
|
||||
score_changed.emit(total_value)
|
||||
print("totale= "+str(total_value))
|
||||
|
||||
func _on_body_exited(body):
|
||||
|
@ -36,6 +38,6 @@ func _on_body_exited(body):
|
|||
print("sottratto")
|
||||
total_value -= evaluable.value
|
||||
evaluable.evaluate()
|
||||
added.emit(body)
|
||||
score_changed.emit(total_value)
|
||||
print("totale= "+str(total_value))
|
||||
|
||||
|
|
Loading…
Reference in a new issue