]> Untitled Git - star-foxy.git/commitdiff
Added alternating bullets
authorClifton Palmer <clifton.james.palmer@protonmail.com>
Mon, 15 Nov 2021 03:49:49 +0000 (21:49 -0600)
committerClifton Palmer <clifton.james.palmer@protonmail.com>
Mon, 15 Nov 2021 03:49:49 +0000 (21:49 -0600)
player/player.gd
player/player.tscn

index 2b608dc4e167c3c34dc965cc86b61d4af77dcca5..018f6694bc23ba003487e072c61e66c6bfc4d694 100644 (file)
@@ -5,6 +5,7 @@ const SPEED_MAX = 20
 const SPEED_TURN = 120
 const SPEED_AIM = PI / 2
 
 const SPEED_TURN = 120
 const SPEED_AIM = PI / 2
 
+var bullet_alterating = 0
 var velocity = Vector3()
 var scene_bullet = preload("res://player/bullet.tscn")
 
 var velocity = Vector3()
 var scene_bullet = preload("res://player/bullet.tscn")
 
@@ -39,16 +40,20 @@ func get_player_input(delta):
                
        # offense
        if Input.is_action_pressed("player_fire"):
                
        # offense
        if Input.is_action_pressed("player_fire"):
-               print("firing!")
-               fire_bullet()
+               if $bullet_timer.time_left == 0:
+                       fire_bullet()
                
 func fire_bullet():
        var bullet = scene_bullet.instance()
        $"..".add_child(bullet)
                
 func fire_bullet():
        var bullet = scene_bullet.instance()
        $"..".add_child(bullet)
-       bullet.translation = translation - transform.basis.x * 2
+       
+       bullet_alterating = (bullet_alterating + 1) % 2
+       bullet.translation = translation - transform.basis.x * (4 * bullet_alterating - 2)
        bullet.rotation = rotation
        bullet.direction = -transform.basis.z
        
        bullet.rotation = rotation
        bullet.direction = -transform.basis.z
        
+       $bullet_timer.start()
+       
 func _process(delta):
        # get velocity changes player asks for
        get_player_input(delta)
 func _process(delta):
        # get velocity changes player asks for
        get_player_input(delta)
index c96080cab393f83d7fd989e474c8373745ebce06..238fc4f4f9f71b9238a4f2d6914757f7f2f2bc70 100644 (file)
@@ -83,8 +83,6 @@ shape = SubResource( 5 )
 [node name="Camera" type="Camera" parent="camera_pivot"]
 transform = Transform( 1, 0, 0, 0, 0.959634, 0.281253, 0, -0.281253, 0.959634, 0, 9.44245, 11.0721 )
 
 [node name="Camera" type="Camera" parent="camera_pivot"]
 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 )
+[node name="bullet_timer" type="Timer" parent="."]
+wait_time = 0.1
+one_shot = true