diff --git a/.gitignore b/.gitignore index 25adc3b..c2f485e 100644 --- a/.gitignore +++ b/.gitignore @@ -16,4 +16,4 @@ data_*/ test/ build/* builds/* -*.zip \ No newline at end of file +*.zip diff --git a/Pavels/bullet_trajectory/Bullet.gd b/Pavels/bullet_trajectory/Bullet.gd deleted file mode 100644 index 04f9c92..0000000 --- a/Pavels/bullet_trajectory/Bullet.gd +++ /dev/null @@ -1,67 +0,0 @@ -extends Area2D - -export var speed = 100 -var velocity = Vector2() -var rot = Vector2() - -var time = 0 -export var amplitude = 4 -export var frequency = 5 -var gravitile = 5 - - -func follow_line_trajectory(): - velocity = Vector2(1, 0) #Vector2(cos(self.global_rotation), sin(self.global_rotation)) - pass - -func follow_sine_trajectory(): - velocity.y = amplitude * cos(time * frequency) - velocity.x = 5 - pass - -func follow_parabolic_trajectory(): - velocity.x = 5 - velocity.y = 1 * time * gravitile - - -func follow_n_parabolic_trajectory(): - velocity.x = 5 - velocity.y = -1 * time * gravitile - - -func follow_hyperbolic_trajectory(): - velocity.x = gravitile * time - velocity.y = 1 - -func follow_n_hyperbolic_trajectory(): - velocity.x = gravitile * time - velocity.y = -1 - - -func chosen_trajectory(): - if Input.is_action_just_pressed("line"): - follow_line_trajectory() - elif Input.is_action_just_pressed("parab"): - follow_parabolic_trajectory() - elif Input.is_action_just_pressed("n_parab"): - follow_n_parabolic_trajectory() - elif Input.is_action_just_pressed("hyper"): - follow_hyperbolic_trajectory() - elif Input.is_action_just_pressed("n_hyper"): - follow_n_hyperbolic_trajectory() - elif Input.is_action_just_pressed("sine"): - follow_sine_trajectory() - else: - follow_line_trajectory() - - -func _process(delta): - follow_sine_trajectory() - time += delta - position += velocity * speed * delta - - -func _on_Bullet_body_entered(body): - if body.is_in_group("mobs"): - body.queue_free() - queue_free() diff --git a/Pavels/bullet_trajectory/Env.gd b/Pavels/bullet_trajectory/Env.gd deleted file mode 100644 index 1d470f0..0000000 --- a/Pavels/bullet_trajectory/Env.gd +++ /dev/null @@ -1,15 +0,0 @@ -extends Node2D - -onready var bullet = preload("res://Bullet.tscn") -var time = 0 - - -func trigger(): - var b = bullet.instance() - add_child(b) - - -func _process(delta): - time += delta - if time > 17: - queue_free() diff --git a/Pavels/bullet_trajectory/Env.tscn b/Pavels/bullet_trajectory/Env.tscn deleted file mode 100644 index c037d8f..0000000 --- a/Pavels/bullet_trajectory/Env.tscn +++ /dev/null @@ -1,10 +0,0 @@ -[gd_scene load_steps=3 format=2] - -[ext_resource path="res://Env.gd" type="Script" id=1] -[ext_resource path="res://Bullet.tscn" type="PackedScene" id=2] - -[node name="Env" type="Node2D"] -position = Vector2( 437.266, 290.109 ) -script = ExtResource( 1 ) - -[node name="Bullet" parent="." instance=ExtResource( 2 )] diff --git a/Pavels/bullet_trajectory/Gun.gd b/Pavels/bullet_trajectory/Gun.gd deleted file mode 100644 index 727d10a..0000000 --- a/Pavels/bullet_trajectory/Gun.gd +++ /dev/null @@ -1,4 +0,0 @@ -extends Position2D - -func _process(delta): - look_at(get_global_mouse_position()) diff --git a/Pavels/bullet_trajectory/Hyperbolic_Trajectory/Hyperbolic_Barrel.tscn b/Pavels/bullet_trajectory/Hyperbolic_Trajectory/Hyperbolic_Barrel.tscn new file mode 100644 index 0000000..9e1a160 --- /dev/null +++ b/Pavels/bullet_trajectory/Hyperbolic_Trajectory/Hyperbolic_Barrel.tscn @@ -0,0 +1,22 @@ +[gd_scene load_steps=4 format=2] + +[ext_resource path="res://icon.png" type="Texture" id=1] +[ext_resource path="res://script/Hyperbola/Hyperbolic_Barrel.gd" type="Script" id=2] + +[sub_resource type="RectangleShape2D" id=1] +extents = Vector2( 22.5946, 3.60519 ) + +[node name="Hyperbolic_Barrel" type="StaticBody2D"] +script = ExtResource( 2 ) + +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +position = Vector2( 30.4661, 0.749161 ) +shape = SubResource( 1 ) + +[node name="icon" type="Sprite" parent="."] +position = Vector2( 42.4007, 0.196289 ) +scale = Vector2( 1.31624, 0.140625 ) +texture = ExtResource( 1 ) + +[node name="Position2D" type="Position2D" parent="."] +position = Vector2( 97.6552, 0.0842819 ) diff --git a/Pavels/bullet_trajectory/Hyperbolic_Trajectory/Hyperbolic_Bullet.tscn b/Pavels/bullet_trajectory/Hyperbolic_Trajectory/Hyperbolic_Bullet.tscn new file mode 100644 index 0000000..cd9ffd6 --- /dev/null +++ b/Pavels/bullet_trajectory/Hyperbolic_Trajectory/Hyperbolic_Bullet.tscn @@ -0,0 +1,22 @@ +[gd_scene load_steps=4 format=2] + +[ext_resource path="res://pixil-frame-0 (1).png" type="Texture" id=1] +[ext_resource path="res://script/Hyperbola/Hyperbolic_Bullet.gd" type="Script" id=2] + +[sub_resource type="CapsuleShape2D" id=1] +radius = 5.4212 +height = 7.62897 + +[node name="Bullet" type="Area2D"] +script = ExtResource( 2 ) + +[node name="Sprite" type="Sprite" parent="."] +position = Vector2( 2, -19 ) +scale = Vector2( 0.199834, 0.199834 ) +texture = ExtResource( 1 ) + +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +rotation = 1.5708 +shape = SubResource( 1 ) + +[connection signal="body_entered" from="." to="." method="_on_Bullet_body_entered"] diff --git a/Pavels/bullet_trajectory/Hyperbolic_Trajectory/Hyperbolic_Env.tscn b/Pavels/bullet_trajectory/Hyperbolic_Trajectory/Hyperbolic_Env.tscn new file mode 100644 index 0000000..6dd98e1 --- /dev/null +++ b/Pavels/bullet_trajectory/Hyperbolic_Trajectory/Hyperbolic_Env.tscn @@ -0,0 +1,12 @@ +[gd_scene load_steps=4 format=2] + +[ext_resource path="res://Line_Trajectory/Line_Bullet.tscn" type="PackedScene" id=1] +[ext_resource path="res://script/Hyperbola/Hyperbolic_Env.gd" type="Script" id=2] +[ext_resource path="res://script/Hyperbola/Hyperbolic_Bullet.gd" type="Script" id=3] + +[node name="Env" type="Node2D"] +script = ExtResource( 2 ) + +[node name="Bullet" parent="." instance=ExtResource( 1 )] +position = Vector2( 0, -0.222725 ) +script = ExtResource( 3 ) diff --git a/Pavels/bullet_trajectory/Line_Trajectory/Line_Barrel.tscn b/Pavels/bullet_trajectory/Line_Trajectory/Line_Barrel.tscn new file mode 100644 index 0000000..1b2e3c9 --- /dev/null +++ b/Pavels/bullet_trajectory/Line_Trajectory/Line_Barrel.tscn @@ -0,0 +1,22 @@ +[gd_scene load_steps=4 format=2] + +[ext_resource path="res://icon.png" type="Texture" id=1] +[ext_resource path="res://script/Line/Line_Barrel.gd" type="Script" id=2] + +[sub_resource type="RectangleShape2D" id=1] +extents = Vector2( 22.5946, 3.60519 ) + +[node name="Line_Barrel" type="StaticBody2D"] +script = ExtResource( 2 ) + +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +position = Vector2( 30.4661, 0.749161 ) +shape = SubResource( 1 ) + +[node name="icon" type="Sprite" parent="."] +position = Vector2( 32.281, 0.196289 ) +scale = Vector2( 1, 0.140625 ) +texture = ExtResource( 1 ) + +[node name="Position2D" type="Position2D" parent="."] +position = Vector2( 64.7166, 0.0842819 ) diff --git a/Pavels/bullet_trajectory/Bullet.tscn b/Pavels/bullet_trajectory/Line_Trajectory/Line_Bullet.tscn similarity index 84% rename from Pavels/bullet_trajectory/Bullet.tscn rename to Pavels/bullet_trajectory/Line_Trajectory/Line_Bullet.tscn index 3519648..b342e67 100644 --- a/Pavels/bullet_trajectory/Bullet.tscn +++ b/Pavels/bullet_trajectory/Line_Trajectory/Line_Bullet.tscn @@ -1,7 +1,7 @@ [gd_scene load_steps=4 format=2] [ext_resource path="res://pixil-frame-0 (1).png" type="Texture" id=1] -[ext_resource path="res://Bullet.gd" type="Script" id=2] +[ext_resource path="res://script/Line/Line_Bullet.gd" type="Script" id=2] [sub_resource type="CapsuleShape2D" id=1] radius = 5.4212 @@ -11,7 +11,7 @@ height = 7.62897 script = ExtResource( 2 ) [node name="Sprite" type="Sprite" parent="."] -position = Vector2( -1.5874, -18.2551 ) +position = Vector2( 2, -19 ) scale = Vector2( 0.199834, 0.199834 ) texture = ExtResource( 1 ) diff --git a/Pavels/bullet_trajectory/Line_Trajectory/Line_Env.tscn b/Pavels/bullet_trajectory/Line_Trajectory/Line_Env.tscn new file mode 100644 index 0000000..0640b7e --- /dev/null +++ b/Pavels/bullet_trajectory/Line_Trajectory/Line_Env.tscn @@ -0,0 +1,10 @@ +[gd_scene load_steps=3 format=2] + +[ext_resource path="res://Line_Trajectory/Line_Bullet.tscn" type="PackedScene" id=1] +[ext_resource path="res://script/Line/Line_Env.gd" type="Script" id=2] + +[node name="Env" type="Node2D"] +script = ExtResource( 2 ) + +[node name="Bullet" parent="." instance=ExtResource( 1 )] +position = Vector2( 0, -0.222725 ) diff --git a/Pavels/bullet_trajectory/Parabolic_Trajectory/Parabolic_Barrel.tscn b/Pavels/bullet_trajectory/Parabolic_Trajectory/Parabolic_Barrel.tscn new file mode 100644 index 0000000..d7e228d --- /dev/null +++ b/Pavels/bullet_trajectory/Parabolic_Trajectory/Parabolic_Barrel.tscn @@ -0,0 +1,22 @@ +[gd_scene load_steps=4 format=2] + +[ext_resource path="res://icon.png" type="Texture" id=1] +[ext_resource path="res://script/Parabola/Parabolic_Barrel.gd" type="Script" id=2] + +[sub_resource type="RectangleShape2D" id=1] +extents = Vector2( 8.79762, 3.60519 ) + +[node name="Parabolic_Barrel" type="StaticBody2D"] +script = ExtResource( 2 ) + +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +position = Vector2( 13.539, 2.08551 ) +shape = SubResource( 1 ) + +[node name="icon" type="Sprite" parent="."] +position = Vector2( 16.2448, 0.641744 ) +scale = Vector2( 0.387507, 0.251987 ) +texture = ExtResource( 1 ) + +[node name="Position2D" type="Position2D" parent="."] +position = Vector2( 34.426, 0.975182 ) diff --git a/Pavels/bullet_trajectory/Parabolic_Trajectory/Parabolic_Bullet.tscn b/Pavels/bullet_trajectory/Parabolic_Trajectory/Parabolic_Bullet.tscn new file mode 100644 index 0000000..b342e67 --- /dev/null +++ b/Pavels/bullet_trajectory/Parabolic_Trajectory/Parabolic_Bullet.tscn @@ -0,0 +1,22 @@ +[gd_scene load_steps=4 format=2] + +[ext_resource path="res://pixil-frame-0 (1).png" type="Texture" id=1] +[ext_resource path="res://script/Line/Line_Bullet.gd" type="Script" id=2] + +[sub_resource type="CapsuleShape2D" id=1] +radius = 5.4212 +height = 7.62897 + +[node name="Bullet" type="Area2D"] +script = ExtResource( 2 ) + +[node name="Sprite" type="Sprite" parent="."] +position = Vector2( 2, -19 ) +scale = Vector2( 0.199834, 0.199834 ) +texture = ExtResource( 1 ) + +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +rotation = 1.5708 +shape = SubResource( 1 ) + +[connection signal="body_entered" from="." to="." method="_on_Bullet_body_entered"] diff --git a/Pavels/bullet_trajectory/Parabolic_Trajectory/Parabolic_Env.tscn b/Pavels/bullet_trajectory/Parabolic_Trajectory/Parabolic_Env.tscn new file mode 100644 index 0000000..07cfd7f --- /dev/null +++ b/Pavels/bullet_trajectory/Parabolic_Trajectory/Parabolic_Env.tscn @@ -0,0 +1,12 @@ +[gd_scene load_steps=4 format=2] + +[ext_resource path="res://Line_Trajectory/Line_Bullet.tscn" type="PackedScene" id=1] +[ext_resource path="res://script/Parabola/Parabolic_Env.gd" type="Script" id=2] +[ext_resource path="res://script/Parabola/Parabolic_Bullet.gd" type="Script" id=3] + +[node name="Env" type="Node2D"] +script = ExtResource( 2 ) + +[node name="Bullet" parent="." instance=ExtResource( 1 )] +position = Vector2( 0, -0.222725 ) +script = ExtResource( 3 ) diff --git a/Pavels/bullet_trajectory/Player.tscn b/Pavels/bullet_trajectory/Player.tscn index 2d46f1a..2daf1ef 100644 --- a/Pavels/bullet_trajectory/Player.tscn +++ b/Pavels/bullet_trajectory/Player.tscn @@ -1,7 +1,7 @@ [gd_scene load_steps=4 format=2] [ext_resource path="res://pixilart-drawing.png" type="Texture" id=1] -[ext_resource path="res://KinematicBody2D.gd" type="Script" id=2] +[ext_resource path="res://script/KinematicBody2D.gd" type="Script" id=2] [sub_resource type="RectangleShape2D" id=1] extents = Vector2( 22.279, 10 ) diff --git a/Pavels/bullet_trajectory/Sine_Trajectory/Sine_Barrel.tscn b/Pavels/bullet_trajectory/Sine_Trajectory/Sine_Barrel.tscn new file mode 100644 index 0000000..690b1ca --- /dev/null +++ b/Pavels/bullet_trajectory/Sine_Trajectory/Sine_Barrel.tscn @@ -0,0 +1,22 @@ +[gd_scene load_steps=4 format=2] + +[ext_resource path="res://icon.png" type="Texture" id=1] +[ext_resource path="res://script/Sine/Sine_Barrel.gd" type="Script" id=2] + +[sub_resource type="RectangleShape2D" id=1] +extents = Vector2( 21.0351, 6.99966 ) + +[node name="Sine_Barrel" type="StaticBody2D"] +script = ExtResource( 2 ) + +[node name="Sprite" type="Sprite" parent="."] +position = Vector2( 32.0917, 0.471939 ) +scale = Vector2( 1, 0.336339 ) +texture = ExtResource( 1 ) + +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +position = Vector2( 30.8681, 0 ) +shape = SubResource( 1 ) + +[node name="Position2D" type="Position2D" parent="."] +position = Vector2( 64.7166, 0.0842819 ) diff --git a/Pavels/bullet_trajectory/Sine_Trajectory/Sine_Bullet.tscn b/Pavels/bullet_trajectory/Sine_Trajectory/Sine_Bullet.tscn new file mode 100644 index 0000000..b342e67 --- /dev/null +++ b/Pavels/bullet_trajectory/Sine_Trajectory/Sine_Bullet.tscn @@ -0,0 +1,22 @@ +[gd_scene load_steps=4 format=2] + +[ext_resource path="res://pixil-frame-0 (1).png" type="Texture" id=1] +[ext_resource path="res://script/Line/Line_Bullet.gd" type="Script" id=2] + +[sub_resource type="CapsuleShape2D" id=1] +radius = 5.4212 +height = 7.62897 + +[node name="Bullet" type="Area2D"] +script = ExtResource( 2 ) + +[node name="Sprite" type="Sprite" parent="."] +position = Vector2( 2, -19 ) +scale = Vector2( 0.199834, 0.199834 ) +texture = ExtResource( 1 ) + +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +rotation = 1.5708 +shape = SubResource( 1 ) + +[connection signal="body_entered" from="." to="." method="_on_Bullet_body_entered"] diff --git a/Pavels/bullet_trajectory/Sine_Trajectory/Sine_Env.tscn b/Pavels/bullet_trajectory/Sine_Trajectory/Sine_Env.tscn new file mode 100644 index 0000000..f0c77d5 --- /dev/null +++ b/Pavels/bullet_trajectory/Sine_Trajectory/Sine_Env.tscn @@ -0,0 +1,12 @@ +[gd_scene load_steps=4 format=2] + +[ext_resource path="res://Line_Trajectory/Line_Bullet.tscn" type="PackedScene" id=1] +[ext_resource path="res://script/Sine/Sine_Env.gd" type="Script" id=2] +[ext_resource path="res://script/Sine/Sine_Bullet.gd" type="Script" id=3] + +[node name="Env" type="Node2D"] +script = ExtResource( 2 ) + +[node name="Bullet" parent="." instance=ExtResource( 1 )] +position = Vector2( 0, -0.222725 ) +script = ExtResource( 3 ) diff --git a/Pavels/bullet_trajectory/game.tscn b/Pavels/bullet_trajectory/game.tscn index 025f87f..109ab9e 100644 --- a/Pavels/bullet_trajectory/game.tscn +++ b/Pavels/bullet_trajectory/game.tscn @@ -2,8 +2,8 @@ [ext_resource path="res://Player.tscn" type="PackedScene" id=1] [ext_resource path="res://icon.png" type="Texture" id=3] -[ext_resource path="res://Gun.gd" type="Script" id=4] -[ext_resource path="res://Mob.gd" type="Script" id=5] +[ext_resource path="res://script/Gun.gd" type="Script" id=4] +[ext_resource path="res://script/Mob.gd" type="Script" id=5] [sub_resource type="RectangleShape2D" id=1] extents = Vector2( 31.7698, 29.9446 ) @@ -27,11 +27,6 @@ one_way_collision_margin = 0.0 [node name="Player" parent="." instance=ExtResource( 1 )] -[node name="Gun" type="Position2D" parent="Player"] +[node name="Gun_Position" type="Position2D" parent="Player"] position = Vector2( 37.1728, -6.00076 ) script = ExtResource( 4 ) - -[node name="Sprite" type="Sprite" parent="Player/Gun"] -position = Vector2( 35, 1 ) -scale = Vector2( 1, 0.109375 ) -texture = ExtResource( 3 ) diff --git a/Pavels/bullet_trajectory/project.godot b/Pavels/bullet_trajectory/project.godot index 47baf24..671b2cb 100644 --- a/Pavels/bullet_trajectory/project.godot +++ b/Pavels/bullet_trajectory/project.godot @@ -65,24 +65,14 @@ parab={ "events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777352,"unicode":0,"echo":false,"script":null) ] } -n_parab={ -"deadzone": 0.5, -"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777353,"unicode":0,"echo":false,"script":null) - ] -} hyper={ "deadzone": 0.5, "events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777354,"unicode":0,"echo":false,"script":null) ] } -n_hyper={ -"deadzone": 0.5, -"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777355,"unicode":0,"echo":false,"script":null) - ] -} sine={ "deadzone": 0.5, -"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777356,"unicode":0,"echo":false,"script":null) +"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777353,"unicode":0,"echo":false,"script":null) ] } diff --git a/Pavels/bullet_trajectory/script/Gun.gd b/Pavels/bullet_trajectory/script/Gun.gd new file mode 100644 index 0000000..88a20a3 --- /dev/null +++ b/Pavels/bullet_trajectory/script/Gun.gd @@ -0,0 +1,30 @@ +extends Position2D + +var trajectories = { + 'line' : preload("res://Line_Trajectory/Line_Barrel.tscn"), + 'sine' : preload("res://Sine_Trajectory/Sine_Barrel.tscn"), + 'parab' : preload("res://Parabolic_Trajectory/Parabolic_Barrel.tscn"), + 'hyper' : preload("res://Hyperbolic_Trajectory/Hyperbolic_Barrel.tscn") +} + + +func equip_gun(gun_type:String): + for gun in get_children(): #if there is gun remove it + gun.queue_free() + + var gun = trajectories[gun_type].instance() + add_child(gun) + + + +func _process(delta): + look_at(get_global_mouse_position()) + if Input.is_action_just_pressed("line"): + equip_gun('line') + if Input.is_action_just_pressed("sine"): + equip_gun('sine') + if Input.is_action_just_pressed("parab"): + equip_gun('parab') + if Input.is_action_just_pressed("hyper"): + equip_gun('hyper') + pass diff --git a/Pavels/bullet_trajectory/script/Hyperbola/Hyperbolic_Barrel.gd b/Pavels/bullet_trajectory/script/Hyperbola/Hyperbolic_Barrel.gd new file mode 100644 index 0000000..fc808d6 --- /dev/null +++ b/Pavels/bullet_trajectory/script/Hyperbola/Hyperbolic_Barrel.gd @@ -0,0 +1,16 @@ +extends StaticBody2D # Y = aX + +onready var bullet = preload("res://Hyperbolic_Trajectory/Hyperbolic_Env.tscn") + + +func shoot(): + var b = bullet.instance() + get_parent().get_parent().get_parent().add_child(b) + b.global_position = $Position2D.global_position + b.global_rotation = $Position2D.global_rotation + + + +func _process(delta): + if Input.is_action_just_pressed("shoot"): + shoot() diff --git a/Pavels/bullet_trajectory/script/Hyperbola/Hyperbolic_Bullet.gd b/Pavels/bullet_trajectory/script/Hyperbola/Hyperbolic_Bullet.gd new file mode 100644 index 0000000..69f7b2e --- /dev/null +++ b/Pavels/bullet_trajectory/script/Hyperbola/Hyperbolic_Bullet.gd @@ -0,0 +1,24 @@ +extends Area2D + +var velocity = Vector2() +var speed = 1 +var time = 0.5 +var gravitile = 5 + + + +func follow_hyperbolic_trajectory(): + velocity.x = gravitile * time + velocity.y = 1/time + + +func _process(delta): + follow_hyperbolic_trajectory() + time += delta + position += velocity * speed * delta + + +func _on_Bullet_body_entered(body): + if body.is_in_group("mobs"): + body.queue_free() + queue_free() diff --git a/Pavels/bullet_trajectory/script/Hyperbola/Hyperbolic_Env.gd b/Pavels/bullet_trajectory/script/Hyperbola/Hyperbolic_Env.gd new file mode 100644 index 0000000..344a757 --- /dev/null +++ b/Pavels/bullet_trajectory/script/Hyperbola/Hyperbolic_Env.gd @@ -0,0 +1,10 @@ +extends Node2D + + +var time = 0 + + +func _process(delta): + time += delta + if time > 17: + queue_free() diff --git a/Pavels/bullet_trajectory/KinematicBody2D.gd b/Pavels/bullet_trajectory/script/KinematicBody2D.gd similarity index 69% rename from Pavels/bullet_trajectory/KinematicBody2D.gd rename to Pavels/bullet_trajectory/script/KinematicBody2D.gd index 3f902fe..1aa9367 100644 --- a/Pavels/bullet_trajectory/KinematicBody2D.gd +++ b/Pavels/bullet_trajectory/script/KinematicBody2D.gd @@ -1,13 +1,12 @@ extends KinematicBody2D -onready var env = preload("res://Env.tscn") export var speed = 400 var movement = Vector2(0, 0) -func shoot(): - var b = env.instance() - get_parent().add_child(b) - b.global_transform = $Gun.global_transform +#func shoot(): + #var b = env.instance() + #get_parent().add_child(b) + #b.global_transform = $Gun.global_transform func get_input(): movement = Vector2() @@ -19,8 +18,8 @@ func get_input(): movement.y += 10 if Input.is_action_pressed("ui_up"): movement.y -= 10 - if Input.is_action_pressed("shoot"): - shoot() + #if Input.is_action_just_pressed("shoot"): + #shoot() func _physics_process(delta): get_input() diff --git a/Pavels/bullet_trajectory/script/Line/Line_Barrel.gd b/Pavels/bullet_trajectory/script/Line/Line_Barrel.gd new file mode 100644 index 0000000..4ba9307 --- /dev/null +++ b/Pavels/bullet_trajectory/script/Line/Line_Barrel.gd @@ -0,0 +1,16 @@ +extends StaticBody2D # Y = aX + +onready var bullet = preload("res://Line_Trajectory/Line_Env.tscn") + + +func shoot(): + var b = bullet.instance() + get_parent().get_parent().get_parent().add_child(b) + b.global_position = $Position2D.global_position + b.global_rotation = $Position2D.global_rotation + + + +func _process(delta): + if Input.is_action_just_pressed("shoot"): + shoot() diff --git a/Pavels/bullet_trajectory/script/Line/Line_Bullet.gd b/Pavels/bullet_trajectory/script/Line/Line_Bullet.gd new file mode 100644 index 0000000..3c958c0 --- /dev/null +++ b/Pavels/bullet_trajectory/script/Line/Line_Bullet.gd @@ -0,0 +1,43 @@ +extends Area2D + +export var speed = 100 +var velocity = Vector2() + +var time = 0 +export var amplitude = 4 +export var frequency = 5 +var gravitile = 5 + + +func follow_line_trajectory(): + velocity = Vector2(10, 0) + +#func follow_parabolic_trajectory(): + #velocity.x = 5 + #velocity.y = 1 * time * gravitile + #return velocity + +#func follow_hyperbolic_trajectory(): + #velocity.x = gravitile * time + #velocity.y = 1 + #return velocity + +#func input(): + #if Input.is_action_just_pressed("line"): + #return follow_sine_trajectory() + #elif Input.is_action_just_pressed("sine"): + #return follow_line_trajectory() + #else: + #print('Trajectory is not selected') + #queue_free() + +func _process(delta): + follow_line_trajectory() + time += delta + position += velocity * speed * delta + + +func _on_Bullet_body_entered(body): + if body.is_in_group("mobs"): + body.queue_free() + queue_free() diff --git a/Pavels/bullet_trajectory/script/Line/Line_Env.gd b/Pavels/bullet_trajectory/script/Line/Line_Env.gd new file mode 100644 index 0000000..3a7645d --- /dev/null +++ b/Pavels/bullet_trajectory/script/Line/Line_Env.gd @@ -0,0 +1,9 @@ +extends Node2D + +var time = 0 + + +func _process(delta): + time += delta + if time > 17: + queue_free() diff --git a/Pavels/bullet_trajectory/Mob.gd b/Pavels/bullet_trajectory/script/Mob.gd similarity index 100% rename from Pavels/bullet_trajectory/Mob.gd rename to Pavels/bullet_trajectory/script/Mob.gd diff --git a/Pavels/bullet_trajectory/script/Parabola/Parabolic_Barrel.gd b/Pavels/bullet_trajectory/script/Parabola/Parabolic_Barrel.gd new file mode 100644 index 0000000..d020184 --- /dev/null +++ b/Pavels/bullet_trajectory/script/Parabola/Parabolic_Barrel.gd @@ -0,0 +1,16 @@ +extends StaticBody2D # Y = aX + +onready var bullet = preload("res://Parabolic_Trajectory/Parabolic_Env.tscn") + + +func shoot(): + var b = bullet.instance() + get_parent().get_parent().get_parent().add_child(b) + b.global_position = $Position2D.global_position + b.global_rotation = $Position2D.global_rotation + + + +func _process(delta): + if Input.is_action_just_pressed("shoot"): + shoot() diff --git a/Pavels/bullet_trajectory/script/Parabola/Parabolic_Bullet.gd b/Pavels/bullet_trajectory/script/Parabola/Parabolic_Bullet.gd new file mode 100644 index 0000000..beee2de --- /dev/null +++ b/Pavels/bullet_trajectory/script/Parabola/Parabolic_Bullet.gd @@ -0,0 +1,24 @@ +extends Area2D + +export var speed = 100 +var velocity = Vector2() + +var time = 0 +var gravitile = 5 + + +func follow_parabolic_trajectory(): + velocity.x = 5 + velocity.y = 1 * time * gravitile + + +func _process(delta): + follow_parabolic_trajectory() + time += delta + position += velocity * speed * delta + + +func _on_Bullet_body_entered(body): + if body.is_in_group("mobs"): + body.queue_free() + queue_free() diff --git a/Pavels/bullet_trajectory/script/Parabola/Parabolic_Env.gd b/Pavels/bullet_trajectory/script/Parabola/Parabolic_Env.gd new file mode 100644 index 0000000..3a7645d --- /dev/null +++ b/Pavels/bullet_trajectory/script/Parabola/Parabolic_Env.gd @@ -0,0 +1,9 @@ +extends Node2D + +var time = 0 + + +func _process(delta): + time += delta + if time > 17: + queue_free() diff --git a/Pavels/bullet_trajectory/script/Sine/Sine_Barrel.gd b/Pavels/bullet_trajectory/script/Sine/Sine_Barrel.gd new file mode 100644 index 0000000..79ce4e8 --- /dev/null +++ b/Pavels/bullet_trajectory/script/Sine/Sine_Barrel.gd @@ -0,0 +1,20 @@ +extends StaticBody2D + +onready var bullet = preload("res://Sine_Trajectory/Sine_Env.tscn") + +var velocity = Vector2(1, 0) +var shooting_speed = 200 + + + +func shoot(): + var b = bullet.instance() + get_parent().get_parent().get_parent().add_child(b) + b.global_position = $Position2D.global_position + b.global_rotation = $Position2D.global_rotation + pass + + +func _process(delta): + if Input.is_action_just_pressed("shoot"): + shoot() diff --git a/Pavels/bullet_trajectory/script/Sine/Sine_Bullet.gd b/Pavels/bullet_trajectory/script/Sine/Sine_Bullet.gd new file mode 100644 index 0000000..1196b54 --- /dev/null +++ b/Pavels/bullet_trajectory/script/Sine/Sine_Bullet.gd @@ -0,0 +1,25 @@ +extends Area2D + +export var speed = 100 +var velocity = Vector2() + +var time = 0 +export var amplitude = 4 +export var frequency = 5 +var gravitile = 5 + + +func follow_sine_trajectory(): + velocity.y = amplitude * cos(time * frequency) + velocity.x = 5 + +func _process(delta): + follow_sine_trajectory() + time += delta + position += velocity * speed * delta + + +func _on_Bullet_body_entered(body): + if body.is_in_group("mobs"): + body.queue_free() + queue_free() diff --git a/Pavels/bullet_trajectory/script/Sine/Sine_Env.gd b/Pavels/bullet_trajectory/script/Sine/Sine_Env.gd new file mode 100644 index 0000000..3a7645d --- /dev/null +++ b/Pavels/bullet_trajectory/script/Sine/Sine_Env.gd @@ -0,0 +1,9 @@ +extends Node2D + +var time = 0 + + +func _process(delta): + time += delta + if time > 17: + queue_free()