Доработка. Направление антенн задаётся движением правой кнопки мыши
This commit is contained in:
@@ -7,6 +7,5 @@ initial_position = 3
|
||||
size = Vector2i(1600, 1200)
|
||||
mode = 3
|
||||
current_screen = 1
|
||||
borderless = true
|
||||
|
||||
[node name="TabContainer" parent="." instance=ExtResource("1_c76qk")]
|
||||
|
||||
@@ -30,11 +30,11 @@ const RADIO_GROUPE_NAMES = \
|
||||
enum DRAG_FSM { IDLE, DRAG }
|
||||
var radio_groupe: Array
|
||||
var drag_pos_begin: Vector2
|
||||
var drag_pos_end: Vector2
|
||||
var drag_fsm: DRAG_FSM
|
||||
var drag_button: MouseButton
|
||||
var pc0: Vector2
|
||||
var ant_dir_width_begin: float
|
||||
var ant_dir_begin: float
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
@@ -68,14 +68,12 @@ func map_xy_ang(pos0: Vector2, pos: Vector2) -> Vector2:
|
||||
return Vector2(ang, radius)
|
||||
|
||||
|
||||
func set_ant_width(position: Vector2):
|
||||
func get_ant_width(position: Vector2, prev: float) -> float:
|
||||
var radp: Vector2 = map_xy_ang(pc0, position)
|
||||
var ant_dir_width: float = ant_dir_width_begin + (drag_pos_begin.y - position.y) / 5.0
|
||||
if ant_dir_width < 5.0:
|
||||
ant_dir_width = 5.0
|
||||
if ant_dir_width > 90.0:
|
||||
ant_dir_width = 90.0
|
||||
$canvas.material.set('shader_parameter/ap_ant_w', ant_dir_width)
|
||||
var ap_ant_w: float = prev + (drag_pos_begin.y - position.y) / 5.0
|
||||
if ap_ant_w < 5.0: ap_ant_w = 5.0
|
||||
if ap_ant_w > 90.0: ap_ant_w = 90.0
|
||||
return ap_ant_w
|
||||
|
||||
|
||||
func set_ant_dir(position: Vector2):
|
||||
@@ -88,7 +86,8 @@ func _input(event):
|
||||
if event is InputEventMouseMotion:
|
||||
if drag_fsm == DRAG_FSM.DRAG:
|
||||
if drag_button == MOUSE_BUTTON_RIGHT:
|
||||
set_ant_width(event.position)
|
||||
var ap_ant_w: float = get_ant_width(event.position, ant_dir_width_begin)
|
||||
$canvas.material.set('shader_parameter/ap_ant_w', ap_ant_w)
|
||||
elif drag_button == MOUSE_BUTTON_LEFT:
|
||||
set_ant_dir(event.position)
|
||||
if event is InputEventMouseButton:
|
||||
@@ -100,6 +99,6 @@ func _input(event):
|
||||
if drag_button == MOUSE_BUTTON_LEFT:
|
||||
set_ant_dir(event.position)
|
||||
elif drag_button == MOUSE_BUTTON_RIGHT:
|
||||
set_ant_width(event.position)
|
||||
ant_dir_width_begin = $canvas.material.get('shader_parameter/ap_ant_w')
|
||||
else:
|
||||
drag_fsm = DRAG_FSM.IDLE
|
||||
|
||||
Reference in New Issue
Block a user