]> Untitled Git - star-foxy.git/commitdiff
Added stupid bullets
authorClifton Palmer <clifton.james.palmer@protonmail.com>
Mon, 15 Nov 2021 00:32:36 +0000 (18:32 -0600)
committerClifton Palmer <clifton.james.palmer@protonmail.com>
Mon, 15 Nov 2021 03:34:09 +0000 (21:34 -0600)
player/bullet.gd [new file with mode: 0644]
player/bullet.tscn [new file with mode: 0644]
player/player.gd
player/player.tscn

diff --git a/player/bullet.gd b/player/bullet.gd
new file mode 100644 (file)
index 0000000..0509ae2
--- /dev/null
@@ -0,0 +1,17 @@
+extends KinematicBody
+
+
+# Declare member variables here. Examples:
+# var a = 2
+# var b = "text"
+var SPEED = 200
+var direction = Vector3.ZERO
+
+# Called when the node enters the scene tree for the first time.
+func _ready():
+       pass # Replace with function body.
+
+
+# Called every frame. 'delta' is the elapsed time since the previous frame.
+func _process(delta):
+       translation += SPEED * direction * delta
diff --git a/player/bullet.tscn b/player/bullet.tscn
new file mode 100644 (file)
index 0000000..2a8ef2f
--- /dev/null
@@ -0,0 +1,59 @@
+[gd_scene load_steps=6 format=2]
+
+[ext_resource path="res://player/bullet.gd" type="Script" id=1]
+
+[sub_resource type="BoxShape" id=1]
+extents = Vector3( 0.200265, 0.163217, 1.15937 )
+
+[sub_resource type="VisualShaderNodeColorConstant" id=2]
+constant = Color( 0.934058, 0.128752, 0, 1 )
+
+[sub_resource type="VisualShader" id=3]
+code = "shader_type spatial;
+render_mode specular_schlick_ggx, unshaded;
+
+
+
+
+void vertex() {
+// Output:0
+
+}
+
+void fragment() {
+// Color:2
+       vec3 n_out2p0 = vec3(0.934058, 0.128752, 0.000000);
+       float n_out2p1 = 1.000000;
+
+// Output:0
+       ALBEDO = n_out2p0;
+
+}
+
+void light() {
+// Output:0
+
+}
+"
+graph_offset = Vector2( 0, 20.4406 )
+flags/unshaded = true
+nodes/fragment/0/position = Vector2( 1560, 60 )
+nodes/fragment/2/node = SubResource( 2 )
+nodes/fragment/2/position = Vector2( 1040, 100 )
+nodes/fragment/connections = PoolIntArray( 2, 0, 0, 0 )
+
+[sub_resource type="ShaderMaterial" id=4]
+shader = SubResource( 3 )
+
+[node name="bullet" type="KinematicBody"]
+collision_layer = 2
+collision_mask = 0
+script = ExtResource( 1 )
+
+[node name="CollisionShape" type="CollisionShape" parent="."]
+shape = SubResource( 1 )
+
+[node name="CSGSphere" type="CSGSphere" parent="."]
+transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 11, 0, 0, 0 )
+material_override = SubResource( 4 )
+radius = 0.1
index fa2445ffe0e2a39f195475cd12acb3bcc89a517d..2b608dc4e167c3c34dc965cc86b61d4af77dcca5 100644 (file)
@@ -6,6 +6,7 @@ const SPEED_TURN = 120
 const SPEED_AIM = PI / 2
 
 var velocity = Vector3()
 const SPEED_AIM = PI / 2
 
 var velocity = Vector3()
+var scene_bullet = preload("res://player/bullet.tscn")
 
 # Called when the node enters the scene tree for the first time.
 func _ready():
 
 # Called when the node enters the scene tree for the first time.
 func _ready():
@@ -36,6 +37,17 @@ func get_player_input(delta):
        elif Input.is_action_pressed("player_aim_right"):
                rotate(Vector3.UP, -SPEED_AIM * delta)  
                
        elif Input.is_action_pressed("player_aim_right"):
                rotate(Vector3.UP, -SPEED_AIM * delta)  
                
+       # offense
+       if Input.is_action_pressed("player_fire"):
+               print("firing!")
+               fire_bullet()
+               
+func fire_bullet():
+       var bullet = scene_bullet.instance()
+       $"..".add_child(bullet)
+       bullet.translation = translation - transform.basis.x * 2
+       bullet.rotation = rotation
+       bullet.direction = -transform.basis.z
        
 func _process(delta):
        # get velocity changes player asks for
        
 func _process(delta):
        # get velocity changes player asks for
index 7dc0f4c4d5f7b210490df79c5a1049336d12c1eb..c96080cab393f83d7fd989e474c8373745ebce06 100644 (file)
@@ -56,6 +56,7 @@ surfaces/0 = {
 extents = Vector3( 3.72203, 0.878147, 3.13957 )
 
 [node name="arwing" type="KinematicBody"]
 extents = Vector3( 3.72203, 0.878147, 3.13957 )
 
 [node name="arwing" type="KinematicBody"]
+collision_mask = 0
 script = ExtResource( 3 )
 
 [node name="mesh" type="Spatial" parent="."]
 script = ExtResource( 3 )
 
 [node name="mesh" type="Spatial" parent="."]
@@ -80,4 +81,10 @@ shape = SubResource( 5 )
 [node name="camera_pivot" type="Spatial" parent="."]
 
 [node name="Camera" type="Camera" parent="camera_pivot"]
 [node name="camera_pivot" type="Spatial" parent="."]
 
 [node name="Camera" type="Camera" parent="camera_pivot"]
-transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 13.3084 )
+transform = Transform( 1, 0, 0, 0, 0.959634, 0.281253, 0, -0.281253, 0.959634, 0, 9.44245, 11.0721 )
+
+[node name="bullet_origin_r" type="Spatial" parent="."]
+transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, -2 )
+
+[node name="bullet_origin_l" type="Spatial" parent="."]
+transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -1, 0, -2 )