Set up groups, layers, and bullet wrap around

This commit is contained in:
Rain Clark 2024-05-09 23:04:36 -04:00
parent a5e7731b47
commit c13e23cdd3
4 changed files with 10 additions and 5 deletions

View File

@ -6,7 +6,8 @@
[sub_resource type="RectangleShape2D" id="RectangleShape2D_5nukh"]
size = Vector2(4, 16)
[node name="Bullet" type="Area2D"]
[node name="Bullet" type="Area2D" groups=["projectile"]]
collision_layer = 2
script = ExtResource("1_jyq7a")
[node name="Sprite2D" type="Sprite2D" parent="."]
@ -20,6 +21,4 @@ shape = SubResource("RectangleShape2D_5nukh")
one_shot = true
autostart = true
[node name="Camera2D" type="Camera2D" parent="."]
[connection signal="timeout" from="LifeTimer" to="." method="_on_life_timer_timeout"]

View File

@ -5,7 +5,7 @@
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_hwy8o"]
[node name="Ship" type="Area2D"]
[node name="Ship" type="Area2D" groups=["ship"]]
script = ExtResource("1_japvq")
max_speed = null
steering_factor = null

View File

@ -1,8 +1,13 @@
extends Area2D
@export var max_speed := 1400.00
var direction := Vector2.ZERO
func _process(delta: float) -> void:
pass
var viewport_size := get_viewport_rect().size
position.x = wrap(position.x, 0, viewport_size.x)
position.y = wrap(position.y, 0,viewport_size.y)
func _on_life_timer_timeout() -> void:
queue_free()

View File

@ -17,6 +17,7 @@ func _process(delta: float) -> void:
position += velocity * delta
if velocity.length() > 0.0:
# TODO: Have the CollisionShape toate with the sprite
$Sprite2D.rotation = velocity.angle()
var viewport_size := get_viewport_rect().size