online multiplayer chess game (note server currently down)
Diffstat (limited to 'Square.gd')
-rw-r--r--Square.gd19
1 files changed, 19 insertions, 0 deletions
diff --git a/Square.gd b/Square.gd
new file mode 100644
index 0000000..b2b7b4c
--- /dev/null
+++ b/Square.gd
@@ -0,0 +1,19 @@
+extends ColorRect
+
+var realname = "Square"
+var real_position = Vector2()
+
+onready var area = $Squarea
+onready var areacollisionshape = $Squarea/CollisionShape2D
+
+signal clicked(real_position)
+
+
+func _ready():
+ areacollisionshape.global_position += Globals.piece_size / 2
+ areacollisionshape.shape.extents = Vector2(rect_size.x / 2, rect_size.y / 2)
+
+
+func _on_Squarea_input_event(_viewport: Node, event: InputEvent, _shape_idx: int):
+ if event is InputEventMouseButton:
+ emit_signal("clicked", real_position)