29 lines
1.0 KiB
GDScript
29 lines
1.0 KiB
GDScript
@icon("res://assets/icons/court.svg")
|
|
class_name Court
|
|
extends Node2D
|
|
|
|
@onready var key_area: Area2D = %KeyArea
|
|
@onready var two_point_area: Area2D = %TwoPointArea
|
|
|
|
func _ready() -> void:
|
|
key_area.connect("body_entered", on_key_area_entered)
|
|
two_point_area.connect("body_entered", on_two_point_area_entered)
|
|
key_area.connect("body_exited", on_key_area_exited)
|
|
two_point_area.connect("body_exited", on_two_point_area_exited)
|
|
|
|
func on_key_area_entered(body: PhysicsBody2D) -> void:
|
|
if body is Player:
|
|
print_debug(str(body.attributes.player_name) + " has entered the key")
|
|
|
|
func on_two_point_area_entered(body: PhysicsBody2D) -> void:
|
|
if body is Player:
|
|
print_debug(str(body.attributes.player_name) + " has entered the two-point area")
|
|
|
|
func on_key_area_exited(body: PhysicsBody2D) -> void:
|
|
if body is Player:
|
|
print_debug(str(body.attributes.player_name) + " has exited the key")
|
|
|
|
func on_two_point_area_exited(body: PhysicsBody2D) -> void:
|
|
if body is Player:
|
|
print_debug(str(body.attributes.player_name) + " has exited the two-point area")
|