Compare commits

..

3 commits

Author SHA1 Message Date
Henry
6431259f7f Modified ship thruster spacing when player banks left and right; added
logic to enable/disable muzzle damage hitbox upon firing.
2026-04-03 14:31:03 +01:00
Henry
8196e664cd Added 2 new hitboxes for muzzle damage and powerup grab radius; reduced
player damage hitbox substantially
2026-04-03 14:29:39 +01:00
Henry
7cca37a881 Adjusted sprite frames for better movement clarity 2026-04-03 14:28:00 +01:00
3 changed files with 38 additions and 4 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 760 B

Before After
Before After

View file

@ -76,8 +76,14 @@ animations = [{
"speed": 15.0 "speed": 15.0
}] }]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_qlg0r"]
size = Vector2(24, 10)
[sub_resource type="RectangleShape2D" id="RectangleShape2D_tuyoq"]
size = Vector2(24, 30)
[sub_resource type="RectangleShape2D" id="RectangleShape2D_dqkch"] [sub_resource type="RectangleShape2D" id="RectangleShape2D_dqkch"]
size = Vector2(10, 11) size = Vector2(6, 5.75)
[node name="Player" type="Area2D" unique_id=652131079] [node name="Player" type="Area2D" unique_id=652131079]
script = ExtResource("1_g2els") script = ExtResource("1_g2els")
@ -103,9 +109,22 @@ sprite_frames = SubResource("SpriteFrames_3v2ag")
animation = &"stock" animation = &"stock"
autoplay = "stock" autoplay = "stock"
[node name="CollisionShape2D" type="CollisionShape2D" parent="." unique_id=485826453] [node name="MuzzleBox" type="CollisionShape2D" parent="." unique_id=1042837273]
position = Vector2(0, -3.5) unique_name_in_owner = true
position = Vector2(0, -17)
shape = SubResource("RectangleShape2D_qlg0r")
disabled = true
debug_color = Color(1, 0.5058824, 0.21960784, 0.41960785)
[node name="HelpBox" type="CollisionShape2D" parent="." unique_id=938667427]
position = Vector2(0, 3)
shape = SubResource("RectangleShape2D_tuyoq")
debug_color = Color(0, 1, 0, 0.41960785)
[node name="HitBox" type="CollisionShape2D" parent="." unique_id=485826453]
position = Vector2(0, 2)
shape = SubResource("RectangleShape2D_dqkch") shape = SubResource("RectangleShape2D_dqkch")
debug_color = Color(0.9843137, 0, 0, 0.80784315)
[node name="WeaponCooldown" type="Timer" parent="." unique_id=269678170] [node name="WeaponCooldown" type="Timer" parent="." unique_id=269678170]

View file

@ -22,6 +22,7 @@ var weapon_timer: float = 0.0
var weapon_spacing: float = 0.1 var weapon_spacing: float = 0.1
@onready var screensize = get_viewport_rect().size @onready var screensize = get_viewport_rect().size
@onready var muzzle_damage = %MuzzleBox
func _process(delta): func _process(delta):
var input = Input.get_vector("left", "right", "up","down") var input = Input.get_vector("left", "right", "up","down")
@ -31,24 +32,32 @@ func _process(delta):
# Sprite feedback based one player input # Sprite feedback based one player input
if input.x > 0: if input.x > 0:
%Ship/Thrusters.position.x = $Ship.position.x+1
%Ship.frame = 2 %Ship.frame = 2
%Ship/Thrusters.flip_h = true %Ship/Thrusters.flip_h = true
%Ship/Thrusters.animation = "banked" %Ship/Thrusters.animation = "banked"
elif input.x < 0: elif input.x < 0:
%Ship/Thrusters.position.x = $Ship.position.x-1
%Ship.frame = 1 %Ship.frame = 1
%Ship/Thrusters.flip_h = false %Ship/Thrusters.flip_h = false
%Ship/Thrusters.animation = "banked" %Ship/Thrusters.animation = "banked"
else: else:
%Ship.frame = 0 %Ship.frame = 0
%Ship/Thrusters.position.x = $Ship.position.x
%Ship/Thrusters.flip_h = false %Ship/Thrusters.flip_h = false
%Ship/Thrusters.animation = "fwd" %Ship/Thrusters.animation = "fwd"
# Get previous positon for equidistant bullet calculation
previous_position = position previous_position = position
# Move the ship based on input within the screen bounds
position += input * speed * delta position += input * speed * delta
position = position.clamp(Vector2(12,12), screensize - Vector2(12,12)) position = position.clamp(Vector2(12,12), screensize - Vector2(12,12))
# Enable muzzle damage hitbox upon firing
if Input.is_action_pressed("shoot"): if Input.is_action_pressed("shoot"):
is_shooting = true is_shooting = true
muzzle_damage.set("disabled", false)
else: else:
is_shooting = false is_shooting = false
@ -58,12 +67,14 @@ func _process(delta):
%MuzzleFlash.show() %MuzzleFlash.show()
%Ship/MuzzleFlash.animation = "stock" %Ship/MuzzleFlash.animation = "stock"
# Adjust bullet spacing before firing
if travel > weapon_spacing: if travel > weapon_spacing:
shoot() shoot()
travel -= weapon_spacing travel -= weapon_spacing
if is_shooting == false: if is_shooting == false:
%MuzzleFlash.hide() %MuzzleFlash.hide()
muzzle_damage.set("disabled", true)
func shield_set(_value: int): func shield_set(_value: int):
return return
@ -80,9 +91,13 @@ func shoot():
var bullet = weapon_current.instantiate() var bullet = weapon_current.instantiate()
get_tree().root.add_child(bullet) get_tree().root.add_child(bullet)
bullet.position = position + Vector2(0,-23) bullet.position = position + Vector2(0,-23)
# Get weapon speed and spacing for equidistant calculations
weapon_rate = bullet.shot_data.rate weapon_rate = bullet.shot_data.rate
weapon_spacing = bullet.shot_data.spacing weapon_spacing = bullet.shot_data.spacing
bullet_speed = abs(bullet.shot_data.speed) 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")