summaryrefslogtreecommitdiff
path: root/pages/GameTable.tscn
diff options
context:
space:
mode:
Diffstat (limited to 'pages/GameTable.tscn')
-rw-r--r--pages/GameTable.tscn60
1 files changed, 51 insertions, 9 deletions
diff --git a/pages/GameTable.tscn b/pages/GameTable.tscn
index 25a4c16..efd6540 100644
--- a/pages/GameTable.tscn
+++ b/pages/GameTable.tscn
@@ -1,8 +1,8 @@
-[gd_scene load_steps=7 format=2]
+[gd_scene load_steps=8 format=2]
[ext_resource path="res://scripts/GameTable.gd" type="Script" id=1]
[ext_resource path="res://textures/wood_board_knotty.png" type="Texture" id=2]
-[ext_resource path="res://objects/Plane.tscn" type="PackedScene" id=3]
+[ext_resource path="res://scripts/Board.gd" type="Script" id=3]
[sub_resource type="Environment" id=1]
background_mode = 1
@@ -22,10 +22,52 @@ albedo_texture = ExtResource( 2 )
material = SubResource( 2 )
size = Vector2( 30, 30 )
+[sub_resource type="GDScript" id=4]
+resource_name = "testing_camera"
+script/source = "extends Camera
+
+const max_scroll_distance : float = 10.0
+const min_scroll_distance : float = 2.0
+onready var scroll_distance : float = transform.origin.z
+const scroll_step : float = 0.2
+
+var mouse_clicked : bool = false
+const max_pitch : float = -15.0 # deg
+const min_pitch : float = -90.0
+const pan_factor : float = 0.5
+
+onready var yaw = get_node(\"../..\")
+onready var pitch = get_node(\"..\")
+
+func _ready():
+ pass
+
+func _input(event):
+ if event is InputEventMouseButton:
+ if event.button_index == BUTTON_LEFT:
+ mouse_clicked = event.pressed
+ if event.button_index == BUTTON_WHEEL_UP and event.pressed:
+ if scroll_distance > min_scroll_distance:
+ scroll_distance -= scroll_step
+ if event.button_index == BUTTON_WHEEL_DOWN and event.pressed:
+ if scroll_distance < max_scroll_distance:
+ scroll_distance += scroll_step
+ transform.origin.z = scroll_distance
+ if event is InputEventMouseMotion and mouse_clicked:
+ var mouse_dir : Vector2 = event.get_relative()
+ yaw.rotation_degrees.y -= mouse_dir.x * pan_factor
+
+ var new_pitch = pitch.rotation_degrees.x - mouse_dir.y * pan_factor*2
+ if new_pitch < max_pitch and new_pitch > min_pitch:
+ transform.origin.y = -2 * (1 - (new_pitch - max_pitch) / (min_pitch - max_pitch))
+ pitch.rotation_degrees.x = new_pitch
+"
+
[node name="GameTable" type="Spatial"]
script = ExtResource( 1 )
[node name="Board" type="Spatial" parent="."]
+script = ExtResource( 3 )
[node name="ActivePieces" type="Spatial" parent="."]
@@ -40,15 +82,15 @@ spot_range = 45.4139
[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
environment = SubResource( 1 )
-[node name="Camera" type="Camera" parent="."]
-transform = Transform( 1, 0, 0, 0, 0.965939, 0.258768, 0, -0.258768, 0.965939, 0, 3.30213, 10.1497 )
-
[node name="Tabletop" type="MeshInstance" parent="."]
transform = Transform( 1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, 0, 0, 0 )
mesh = SubResource( 3 )
-[node name="Plane" parent="." instance=ExtResource( 3 )]
-transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0.625405, 1.50965, -2.27158 )
+[node name="CameraHingeYaw" type="Spatial" parent="."]
+
+[node name="CameraHingePitch" type="Spatial" parent="CameraHingeYaw"]
+transform = Transform( 1, 0, 0, 0, 0.965926, 0.258819, 0, -0.258819, 0.965926, 0, 0, 0 )
-[node name="Plane2" parent="." instance=ExtResource( 3 )]
-transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -0.92594, 0.711815, -1.28117 )
+[node name="Camera" type="Camera" parent="CameraHingeYaw/CameraHingePitch"]
+transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 7 )
+script = SubResource( 4 )