Add new bullet scene
This commit is contained in:
parent
2e93fd8c33
commit
4689798b38
|
@ -0,0 +1,21 @@
|
|||
extends Area2D
|
||||
|
||||
const SPEED = 1000
|
||||
const RANGE = 1200
|
||||
var travelled_distance = 0
|
||||
|
||||
|
||||
func _physics_process(delta):
|
||||
# Current direction the bullet is facing.
|
||||
var direction = Vector2.RIGHT.rotated(rotation)
|
||||
position += direction * SPEED * delta
|
||||
|
||||
travelled_distance += SPEED * delta
|
||||
if travelled_distance > RANGE:
|
||||
queue_free()
|
||||
|
||||
|
||||
func _on_body_entered(body):
|
||||
queue_free()
|
||||
if body.has_method("take_damage"):
|
||||
body.take_damage()
|
|
@ -0,0 +1,21 @@
|
|||
[gd_scene load_steps=4 format=3 uid="uid://cav38t37qa74k"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://dftkbqwsfd68r" path="res://pistol/projectile.png" id="1_3vtra"]
|
||||
[ext_resource type="Script" path="res://bullet.gd" id="1_6niae"]
|
||||
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_d5m6x"]
|
||||
radius = 16.0
|
||||
|
||||
[node name="Bullet" type="Area2D"]
|
||||
collision_layer = 0
|
||||
collision_mask = 3
|
||||
script = ExtResource("1_6niae")
|
||||
|
||||
[node name="Projectile" type="Sprite2D" parent="."]
|
||||
position = Vector2(-11, 0)
|
||||
texture = ExtResource("1_3vtra")
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
shape = SubResource("CircleShape2D_d5m6x")
|
||||
|
||||
[connection signal="body_entered" from="." to="." method="_on_body_entered"]
|
Loading…
Reference in New Issue