From 3c9189aef050667628612a983b0ba9bcdeca08e0 Mon Sep 17 00:00:00 2001 From: Moonshrike Date: Mon, 15 Nov 2021 12:59:44 +0200 Subject: [PATCH] Almost working buttons instead of bullet flying trajectory changing and hyperbollic line --- .../player_handlers/player_body_handler.gd | 10 +++++----- .../shooting/Hyperbola/Hyperbolic_Barrel.gd | 15 +++++++-------- .../assets/scripts/shooting/Sine/Sine_Barrel.gd | 1 - .../shooting/Sine_Trajectory/Sine_Barrel.tscn | 1 - .../scenes/OVERLAY/elements/Trajectory_Control.gd | 10 +++++++--- 5 files changed, 19 insertions(+), 18 deletions(-) diff --git a/source/assets/scripts/player_handlers/player_body_handler.gd b/source/assets/scripts/player_handlers/player_body_handler.gd index 6e666d0..0163ad8 100644 --- a/source/assets/scripts/player_handlers/player_body_handler.gd +++ b/source/assets/scripts/player_handlers/player_body_handler.gd @@ -334,13 +334,13 @@ func enable_trajectory_line(new_trajectory_line:String): # get_parent().add_child(x) # x.global_position = shoot_point.global_position # x.global_rotation = shoot_point.global_rotation - #for x in get_children(): #if there is gun remove it - #x.queue_free() + for x in get_node('weaponHolder/Player-character-theme-gun/shoot_point').get_children(): #if there is gun remove it + x.queue_free() var x = bullet_trajectory[new_trajectory_line].instance() - get_parent().add_child(x) - x.global_position = shoot_point.global_position - x.global_rotation = shoot_point.global_rotation + print(x) + get_node('weaponHolder/Player-character-theme-gun/shoot_point').add_child(x) + func enable_trajectory(new_trajectory_line:String): diff --git a/source/assets/scripts/shooting/Hyperbola/Hyperbolic_Barrel.gd b/source/assets/scripts/shooting/Hyperbola/Hyperbolic_Barrel.gd index dee6e58..6995a64 100644 --- a/source/assets/scripts/shooting/Hyperbola/Hyperbolic_Barrel.gd +++ b/source/assets/scripts/shooting/Hyperbola/Hyperbolic_Barrel.gd @@ -34,20 +34,19 @@ func _ready(): func trajectory(): - while dot_position.x < 1000: - if pos.x > 0: + if true: add_point(dot_position) velocity.x = 10 velocity.y = a_parameter/(time*b_parameter) dot_position += velocity * speed_hyper * 0.06944 time += 0.06944 - if pos.x < 0: - add_point(dot_position) - velocity.x = 10 - velocity.y = -a_parameter/(time*b_parameter) - dot_position += velocity * speed_hyper * 0.06944 - time += 0.06944 +# if pos.x < 0: +# add_point(dot_position) +# velocity.x = 10 +# velocity.y = -a_parameter/(time*b_parameter) +# dot_position += velocity * speed_hyper * 0.06944 +# time += 0.06944 func _process(_delta): trajectory() diff --git a/source/assets/scripts/shooting/Sine/Sine_Barrel.gd b/source/assets/scripts/shooting/Sine/Sine_Barrel.gd index ecf104a..a37190a 100644 --- a/source/assets/scripts/shooting/Sine/Sine_Barrel.gd +++ b/source/assets/scripts/shooting/Sine/Sine_Barrel.gd @@ -19,7 +19,6 @@ export var frequency = 5 # time += 0.06944 func trajectory(): - clear_points() while dot_position.x < 1000: add_point(dot_position) velocity.y = amplitude * cos(time * frequency) diff --git a/source/entities/shooting/Sine_Trajectory/Sine_Barrel.tscn b/source/entities/shooting/Sine_Trajectory/Sine_Barrel.tscn index 5c2db70..3a0e275 100644 --- a/source/entities/shooting/Sine_Trajectory/Sine_Barrel.tscn +++ b/source/entities/shooting/Sine_Trajectory/Sine_Barrel.tscn @@ -4,5 +4,4 @@ [node name="Sine_Barrel" type="Line2D"] show_behind_parent = true -width = 4.0 script = ExtResource( 1 ) diff --git a/source/scenes/OVERLAY/elements/Trajectory_Control.gd b/source/scenes/OVERLAY/elements/Trajectory_Control.gd index e885de6..5ae7223 100644 --- a/source/scenes/OVERLAY/elements/Trajectory_Control.gd +++ b/source/scenes/OVERLAY/elements/Trajectory_Control.gd @@ -12,19 +12,23 @@ func _ready(): func _on_line_pressed(): Global.get('player').enable_trajectory_line('line') + #Global.get('player').choose_trajectory('line') pass # Replace with function body. func _on_parabol_pressed(): - on_parab_pressed = true + Global.get('player').enable_trajectory_line('parab') + #Global.get('player').choose_trajectory('parab') pass # Replace with function body. func _on_hyperbol_pressed(): - on_hyper_pressed = true + Global.get('player').enable_trajectory_line('hyper') + #Global.get('player').trajectory_line = 'hyper' pass # Replace with function body. func _on_sine_pressed(): - on_sine_pressed = true + Global.get('player').enable_trajectory_line('sine') + #Global.get('player').trajectory_line = 'sine' pass # Replace with function body.