1
Fork 0
mirror of https://github.com/Steffo99/swear-jar.git synced 2024-11-22 07:44:17 +00:00

new branch with experimental valuable e evaluator

This commit is contained in:
Matteo Balugani 2023-10-01 11:37:38 +02:00
parent e71fb90401
commit e02a5edea8
6 changed files with 57 additions and 20 deletions

View file

@ -1,19 +0,0 @@
extends Node2D
var conta_soldi: int = 0
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
pass
func _on_ingresso_body_shape_entered(body_rid, body, body_shape_index, local_shape_index):
body.queue_free()
conta_soldi+=1
if conta_soldi>=10:
conta_soldi=0

View file

@ -1,4 +1,4 @@
[gd_scene load_steps=3 format=3 uid="uid://d34gt53jcq1uw"] [gd_scene load_steps=3 format=3 uid="uid://ei1b0ity3nwg"]
[ext_resource type="Script" path="res://Convertitore.gd" id="1_7de38"] [ext_resource type="Script" path="res://Convertitore.gd" id="1_7de38"]
[ext_resource type="Texture2D" uid="uid://cxsl5yvdhswc7" path="res://icon.png" id="2_8bfs6"] [ext_resource type="Texture2D" uid="uid://cxsl5yvdhswc7" path="res://icon.png" id="2_8bfs6"]

30
value/evaluator.gd Normal file
View file

@ -0,0 +1,30 @@
extends Area2D
class_name Evaluator
## aggiunge al totale i valori dei Valuable che ci body_enterano e sottrae quelli che ci body_exitano
## The current amount of value evaluated.
var total_value: int = 0
## The types of [Collectible]s to value.
##
## The strings will match only if exactly the same.
@export var collecting_types: Array[StringName]
## The collision mask to check colliding body against.
@export_flags_2d_physics var collecting_collision_mask: int
## The evaluator has added the value of an object.
signal added(what: PhysicsBody2D)
## The evaluator has removed the value of an object.
signal removed(what: PhysicsBody2D)
func _on_body_entered(body: Node2D):
pass

10
value/evaluator.tscn Normal file
View file

@ -0,0 +1,10 @@
[gd_scene load_steps=2 format=3 uid="uid://beg758fa6o0cs"]
[ext_resource type="Script" path="res://value/evaluator.gd" id="1_sjx78"]
[node name="Evaluator" type="Node2D"]
script = ExtResource("1_sjx78")
[node name="Area2D" type="Area2D" parent="."]
[connection signal="body_entered" from="Area2D" to="." method="_on_area_2d_body_entered"]

10
value/valuable.gd Normal file
View file

@ -0,0 +1,10 @@
extends Node
class_name Valuable
@export var value: int
#signal object_value
#
#
#func collect():
# emit_signal("collected")

6
value/valuable.tscn Normal file
View file

@ -0,0 +1,6 @@
[gd_scene load_steps=2 format=3 uid="uid://ujpra0s1kpqi"]
[ext_resource type="Script" path="res://value/valuable.gd" id="1_mr62g"]
[node name="Valuable" type="Node2D"]
script = ExtResource("1_mr62g")