Naprawa strzelania dzialkiem

This commit is contained in:
Tomasz Boruc 2026-10-15 18:57:18 +02:00
parent 4d4403d6d1
commit bcde93eca9
3 changed files with 25 additions and 9 deletions

View File

@ -1,7 +1,7 @@
extends Node2D
var _age := 0.0
const DURATION := 0.075
const DURATION := 0.065
func _ready() -> void:
z_index = 25
@ -14,8 +14,23 @@ func _process(delta: float) -> void:
queue_redraw()
func _draw() -> void:
var fade := 1.0 - _age / DURATION
draw_circle(Vector2.ZERO, 12 * fade, Color(1.0, 0.48, 0.08, 0.18 * fade))
draw_colored_polygon(PackedVector2Array([Vector2(-2, -3), Vector2(8, -2), Vector2(19, 0), Vector2(8, 2), Vector2(-2, 3)]), Color(1.0, 0.7, 0.18, fade))
draw_line(Vector2(-2, 0), Vector2(13 * fade, 0), Color(1.0, 0.97, 0.8, fade), 2, true)
draw_line(Vector2(1, -7 * fade), Vector2(1, 7 * fade), Color(1.0, 0.78, 0.3, fade * 0.7), 1, true)
var fade := clampf(1.0 - _age / DURATION, 0.0, 1.0)
var length_scale := 0.45 + fade * 0.55
# Compact flame lobes instead of thin crossing lines that flicker at subpixels.
draw_set_transform(Vector2.ZERO, 0.0, Vector2(length_scale, 0.65 + fade * 0.35))
for index in range(4, 0, -1):
draw_circle(Vector2(4.0, 0.0), float(index) * 2.4, Color(1.0, 0.32, 0.035, 0.025 * fade), true, -1, true)
var flame := PackedVector2Array([
Vector2(-1, -2), Vector2(3, -4), Vector2(7, -2.5),
Vector2(10, -3.5), Vector2(8.5, -1), Vector2(16, 0),
Vector2(9, 1.6), Vector2(10.5, 3), Vector2(6, 2.5),
Vector2(3, 4), Vector2(-1, 2),
])
draw_colored_polygon(flame, Color(1.0, 0.35, 0.045, fade * 0.85))
draw_polyline(flame, Color(1.0, 0.5, 0.07, fade * 0.35), 1.0, true)
draw_colored_polygon(PackedVector2Array([
Vector2(0, -1.5), Vector2(4, -2), Vector2(11, 0),
Vector2(4, 2), Vector2(0, 1.5),
]), Color(1.0, 0.78, 0.22, fade))
draw_line(Vector2.ZERO, Vector2(6, 0), Color(1.0, 0.97, 0.76, fade), 2.2, true)
draw_set_transform(Vector2.ZERO)

View File

@ -71,4 +71,3 @@ func _make_stars(layer_name: String, speed: float, count: int, seed_offset: int)
func _draw() -> void:
# The map boundary remains in world space.
draw_rect(Rect2(-WORLD_SIZE * 0.5, WORLD_SIZE), Color(0.12, 0.52, 0.68, 0.48), false, 3.0)

View File

@ -147,15 +147,17 @@ func _fire_projectile(item: ItemInstance) -> void:
bool(hit["critical"])
)
ship.get_parent().add_child(projectile)
projectile.reset_physics_interpolation()
projectile.set("missile_homing", definition.missile_homing)
WEAPON_AUDIO_SCRIPT.play(ship.get_parent(), muzzle_position, definition.weapon_kind)
if definition.weapon_kind == ItemDefinition.WeaponKind.MACHINE_GUN:
var flash := Node2D.new()
flash.set_script(preload("res://scripts/game/muzzle_flash.gd"))
# Keep the short flash attached to the muzzle while the ship moves.
flash.position = ship.to_local(muzzle_position)
flash.rotation = direction.angle() - ship.global_rotation
ship.add_child(flash)
flash.global_position = muzzle_position
flash.global_rotation = direction.angle()
flash.reset_physics_interpolation()
func _exit_tree() -> void:
for beam in _laser_lines: