Almost working buttons

instead of bullet flying trajectory changing and hyperbollic line
This commit is contained in:
Moonshrike 2021-11-15 12:59:44 +02:00
parent 0706f73970
commit 3c9189aef0
5 changed files with 19 additions and 18 deletions

View File

@ -334,13 +334,13 @@ func enable_trajectory_line(new_trajectory_line:String):
# get_parent().add_child(x) # get_parent().add_child(x)
# x.global_position = shoot_point.global_position # x.global_position = shoot_point.global_position
# x.global_rotation = shoot_point.global_rotation # x.global_rotation = shoot_point.global_rotation
#for x in get_children(): #if there is gun remove it for x in get_node('weaponHolder/Player-character-theme-gun/shoot_point').get_children(): #if there is gun remove it
#x.queue_free() x.queue_free()
var x = bullet_trajectory[new_trajectory_line].instance() var x = bullet_trajectory[new_trajectory_line].instance()
get_parent().add_child(x) print(x)
x.global_position = shoot_point.global_position get_node('weaponHolder/Player-character-theme-gun/shoot_point').add_child(x)
x.global_rotation = shoot_point.global_rotation
func enable_trajectory(new_trajectory_line:String): func enable_trajectory(new_trajectory_line:String):

View File

@ -34,20 +34,19 @@ func _ready():
func trajectory(): func trajectory():
while dot_position.x < 1000: while dot_position.x < 1000:
if pos.x > 0: if true:
add_point(dot_position) add_point(dot_position)
velocity.x = 10 velocity.x = 10
velocity.y = a_parameter/(time*b_parameter) velocity.y = a_parameter/(time*b_parameter)
dot_position += velocity * speed_hyper * 0.06944 dot_position += velocity * speed_hyper * 0.06944
time += 0.06944 time += 0.06944
if pos.x < 0: # if pos.x < 0:
add_point(dot_position) # add_point(dot_position)
velocity.x = 10 # velocity.x = 10
velocity.y = -a_parameter/(time*b_parameter) # velocity.y = -a_parameter/(time*b_parameter)
dot_position += velocity * speed_hyper * 0.06944 # dot_position += velocity * speed_hyper * 0.06944
time += 0.06944 # time += 0.06944
func _process(_delta): func _process(_delta):
trajectory() trajectory()

View File

@ -19,7 +19,6 @@ export var frequency = 5
# time += 0.06944 # time += 0.06944
func trajectory(): func trajectory():
clear_points()
while dot_position.x < 1000: while dot_position.x < 1000:
add_point(dot_position) add_point(dot_position)
velocity.y = amplitude * cos(time * frequency) velocity.y = amplitude * cos(time * frequency)

View File

@ -4,5 +4,4 @@
[node name="Sine_Barrel" type="Line2D"] [node name="Sine_Barrel" type="Line2D"]
show_behind_parent = true show_behind_parent = true
width = 4.0
script = ExtResource( 1 ) script = ExtResource( 1 )

View File

@ -12,19 +12,23 @@ func _ready():
func _on_line_pressed(): func _on_line_pressed():
Global.get('player').enable_trajectory_line('line') Global.get('player').enable_trajectory_line('line')
#Global.get('player').choose_trajectory('line')
pass # Replace with function body. pass # Replace with function body.
func _on_parabol_pressed(): 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. pass # Replace with function body.
func _on_hyperbol_pressed(): 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. pass # Replace with function body.
func _on_sine_pressed(): 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. pass # Replace with function body.