From 4f025868e6c444430f6d2648298d673a6c8661a8 Mon Sep 17 00:00:00 2001 From: Melon Bread Date: Thu, 16 May 2024 14:05:08 -0400 Subject: [PATCH] Invader's bullets no longer wrap --- scripts/bullet.gd | 8 +++++--- scripts/invader.gd | 1 + 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/scripts/bullet.gd b/scripts/bullet.gd index 7717984..c7845c5 100644 --- a/scripts/bullet.gd +++ b/scripts/bullet.gd @@ -3,6 +3,7 @@ extends Area2D @export var speed := 1400.00 var direction := Vector2.UP var life_span = 0.5 +var screen_wrap = true func _ready() -> void: $LifeTimer.wait_time = life_span @@ -14,9 +15,10 @@ func _physics_process(delta: float) -> void: print(rotation) # Screenwrap - 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) + if screen_wrap: + 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/invader.gd b/scripts/invader.gd index 8a05aa7..56b00a5 100644 --- a/scripts/invader.gd +++ b/scripts/invader.gd @@ -55,6 +55,7 @@ func shoot(pos : Vector2, rot : float) -> void: bullet.position = pos bullet.rotation = rot bullet.life_span = 0.3 + bullet.screen_wrap = false $Projectiles.add_child(bullet) $ShootSound.play() can_shoot = false