diff --git a/scenes/bullet.tscn b/scenes/bullet.tscn index 8721165..13bdfd4 100644 --- a/scenes/bullet.tscn +++ b/scenes/bullet.tscn @@ -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"] diff --git a/scenes/ship.tscn b/scenes/ship.tscn index 6a36c6a..5961273 100644 --- a/scenes/ship.tscn +++ b/scenes/ship.tscn @@ -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 diff --git a/scripts/bullet.gd b/scripts/bullet.gd index 317ab57..d7162ac 100644 --- a/scripts/bullet.gd +++ b/scripts/bullet.gd @@ -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() diff --git a/scripts/ship.gd b/scripts/ship.gd index 8d2de39..8cb3ce4 100644 --- a/scripts/ship.gd +++ b/scripts/ship.gd @@ -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