Trying to synchronize bullet with fake calculated ship velocity.

This commit is contained in:
Henry 2026-03-22 18:27:15 +00:00
parent 6856dcb172
commit 030304dc48
8 changed files with 75 additions and 6 deletions

View file

@ -8,7 +8,8 @@ var shield: int = 0: set = shield_set
var can_shoot: bool = true
var is_shooting: bool = false
var weapon_current = load("res://scenes/stock_weapon.tscn")
@export var weapon_current : PackedScene
#var weapon_current = load("res://scenes/stock_weapon.tscn")
var weapon_cooldown = Timer
var weapon_rate: float = 0.1
var weapon_timer: float = 0.0
@ -32,6 +33,21 @@ func _process(delta):
position += input * speed * delta
position = position.clamp(Vector2(12,12), screensize - Vector2(12,12))
# Update velocity based on input
var direction = Vector2.ZERO
if Input.is_action_pressed("down"):
direction.y += 1
if Input.is_action_pressed("up"):
direction.y -= 1
# Normalize direction and apply speed
if direction.length() > 0:
velocity = direction.normalized() * speed
# Update velocity
velocity += velocity * delta
if Input.is_action_pressed("shoot"):
print("Spacebar pressed!")
is_shooting = true