Modified ship thruster spacing when player banks left and right; added
logic to enable/disable muzzle damage hitbox upon firing.
This commit is contained in:
parent
8196e664cd
commit
6431259f7f
1 changed files with 16 additions and 1 deletions
|
|
@ -22,6 +22,7 @@ var weapon_timer: float = 0.0
|
|||
var weapon_spacing: float = 0.1
|
||||
|
||||
@onready var screensize = get_viewport_rect().size
|
||||
@onready var muzzle_damage = %MuzzleBox
|
||||
|
||||
func _process(delta):
|
||||
var input = Input.get_vector("left", "right", "up","down")
|
||||
|
|
@ -31,24 +32,32 @@ func _process(delta):
|
|||
|
||||
# Sprite feedback based one player input
|
||||
if input.x > 0:
|
||||
%Ship/Thrusters.position.x = $Ship.position.x+1
|
||||
%Ship.frame = 2
|
||||
%Ship/Thrusters.flip_h = true
|
||||
%Ship/Thrusters.animation = "banked"
|
||||
elif input.x < 0:
|
||||
%Ship/Thrusters.position.x = $Ship.position.x-1
|
||||
%Ship.frame = 1
|
||||
%Ship/Thrusters.flip_h = false
|
||||
%Ship/Thrusters.animation = "banked"
|
||||
else:
|
||||
%Ship.frame = 0
|
||||
%Ship/Thrusters.position.x = $Ship.position.x
|
||||
%Ship/Thrusters.flip_h = false
|
||||
%Ship/Thrusters.animation = "fwd"
|
||||
|
||||
# Get previous positon for equidistant bullet calculation
|
||||
previous_position = position
|
||||
|
||||
# Move the ship based on input within the screen bounds
|
||||
position += input * speed * delta
|
||||
position = position.clamp(Vector2(12,12), screensize - Vector2(12,12))
|
||||
|
||||
# Enable muzzle damage hitbox upon firing
|
||||
if Input.is_action_pressed("shoot"):
|
||||
is_shooting = true
|
||||
muzzle_damage.set("disabled", false)
|
||||
|
||||
else:
|
||||
is_shooting = false
|
||||
|
|
@ -58,12 +67,14 @@ func _process(delta):
|
|||
%MuzzleFlash.show()
|
||||
%Ship/MuzzleFlash.animation = "stock"
|
||||
|
||||
# Adjust bullet spacing before firing
|
||||
if travel > weapon_spacing:
|
||||
shoot()
|
||||
travel -= weapon_spacing
|
||||
|
||||
if is_shooting == false:
|
||||
%MuzzleFlash.hide()
|
||||
muzzle_damage.set("disabled", true)
|
||||
|
||||
func shield_set(_value: int):
|
||||
return
|
||||
|
|
@ -80,9 +91,13 @@ func shoot():
|
|||
var bullet = weapon_current.instantiate()
|
||||
get_tree().root.add_child(bullet)
|
||||
bullet.position = position + Vector2(0,-23)
|
||||
|
||||
# Get weapon speed and spacing for equidistant calculations
|
||||
weapon_rate = bullet.shot_data.rate
|
||||
weapon_spacing = bullet.shot_data.spacing
|
||||
bullet_speed = abs(bullet.shot_data.speed)
|
||||
prints(bullet.shot_data.shot_name, "weapon fired") #Print which weapon is firing
|
||||
|
||||
# Print which weapon is firing
|
||||
prints(bullet.shot_data.shot_name, "weapon fired")
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue