+73
-9
@@ -14,8 +14,8 @@ const BH_MAX_COUNT := 8
|
||||
const WHITE_HOLE_MAX := 2 # cap white holes so they don't pile up
|
||||
const COMET_SPAWN_MIN := 3.0
|
||||
const COMET_SPAWN_MAX := 10.0
|
||||
const ANTIMATTER_SPAWN_MIN := 180.0
|
||||
const ANTIMATTER_SPAWN_MAX := 360.0
|
||||
const ANTIMATTER_SPAWN_MIN := 300.0
|
||||
const ANTIMATTER_SPAWN_MAX := 600.0
|
||||
const DIFFICULTY_RAMP_SECS := 300.0 # full difficulty at 5 minutes
|
||||
const OBJECT_WIPE_THRESHOLD := 500
|
||||
const PHYS_DT := 1.0 / 60.0
|
||||
@@ -48,6 +48,10 @@ var comet_timer: float = 0.0
|
||||
var comet_next: float = 5.0
|
||||
var antimatter_timer: float = 0.0
|
||||
var antimatter_next: float = 50.0
|
||||
var antimatter_warn_pending: bool = false
|
||||
var antimatter_warn_pos: Vector2 = Vector2.ZERO
|
||||
var antimatter_warn_timer: float = 0.0
|
||||
const ANTIMATTER_WARN_DURATION := 1.5
|
||||
var credit_tick_timer: float = 0.0
|
||||
|
||||
var big_wipe: BigWipe = null
|
||||
@@ -312,12 +316,21 @@ func _tick(dt: float) -> void:
|
||||
c.init(W, H)
|
||||
comets.append(c)
|
||||
antimatter_timer += dt
|
||||
var am_max_interval: float = lerp(float(ANTIMATTER_SPAWN_MAX), float(ANTIMATTER_SPAWN_MIN), difficulty)
|
||||
if antimatter_timer >= antimatter_next:
|
||||
antimatter_timer = 0.0
|
||||
antimatter_next = randf_range(ANTIMATTER_SPAWN_MIN, am_max_interval)
|
||||
_spawn_antimatter_swarm(W * 0.5 + randf_range(-100, 100), H * 0.5 + randf_range(-100, 100))
|
||||
SoundManager.play_sfx("antimatter_swarm")
|
||||
if not antimatter_warn_pending:
|
||||
var am_max_interval: float = lerp(float(ANTIMATTER_SPAWN_MAX), 120.0, difficulty)
|
||||
if antimatter_timer >= antimatter_next:
|
||||
antimatter_timer = 0.0
|
||||
antimatter_next = randf_range(ANTIMATTER_SPAWN_MIN, am_max_interval)
|
||||
antimatter_warn_pos = Vector2(W * 0.5 + randf_range(-100, 100), H * 0.5 + randf_range(-100, 100))
|
||||
antimatter_warn_pending = true
|
||||
antimatter_warn_timer = 0.0
|
||||
SoundManager.play_sfx("antimatter_warn")
|
||||
if antimatter_warn_pending:
|
||||
antimatter_warn_timer += dt
|
||||
if antimatter_warn_timer >= ANTIMATTER_WARN_DURATION:
|
||||
antimatter_warn_pending = false
|
||||
_spawn_antimatter_swarm(antimatter_warn_pos.x, antimatter_warn_pos.y)
|
||||
SoundManager.play_sfx("antimatter_swarm")
|
||||
var all_dead: bool = true
|
||||
for player in players:
|
||||
var sp: Spaceship = player
|
||||
@@ -414,6 +427,11 @@ func _update_objects(delta: float) -> void:
|
||||
for comet in comets:
|
||||
var c: CosmicObjects.Comet = comet
|
||||
c.update(W, H)
|
||||
for comet in comets:
|
||||
var c: CosmicObjects.Comet = comet
|
||||
if c.dead:
|
||||
SoundManager.play_sfx("comet_whistle")
|
||||
_fire_music_event("comet_pass")
|
||||
comets = comets.filter(func(c): return not c.dead)
|
||||
for gal in galaxies:
|
||||
var g: CosmicObjects.Galaxy = gal
|
||||
@@ -426,9 +444,11 @@ func _update_objects(delta: float) -> void:
|
||||
g.consuming_bh = null
|
||||
g.respawning = true
|
||||
g.respawn_timer = randf_range(5.0, 10.0)
|
||||
_fire_music_event("galaxy_consumed")
|
||||
if cbh.consumed >= 12 and not cbh.is_smbh:
|
||||
cbh.become_smbh()
|
||||
SoundManager.play_sfx("smbh_spawn")
|
||||
_fire_music_event("bh_pulse")
|
||||
for qsr in quasars:
|
||||
var q: CosmicObjects.Quasar = qsr
|
||||
q.update(delta)
|
||||
@@ -459,6 +479,7 @@ func _update_objects(delta: float) -> void:
|
||||
if q.boost_sound_cd <= 0.0:
|
||||
q.boost_sound_cd = 1.2
|
||||
SoundManager.play_sfx("quasar_boost")
|
||||
_fire_music_event("quasar_jet")
|
||||
quasars = quasars.filter(func(q): return not q.dead)
|
||||
_merge_quasars()
|
||||
var new_stars_from_wh: Array = []
|
||||
@@ -468,6 +489,8 @@ func _update_objects(delta: float) -> void:
|
||||
var result: Dictionary = wh.update(delta)
|
||||
new_stars_from_wh.append_array(result["stars"])
|
||||
new_planets_from_wh.append_array(result["planets"])
|
||||
if result["stars"].size() > 0 or result["planets"].size() > 0:
|
||||
_fire_music_event("white_hole_eject")
|
||||
for player in players:
|
||||
var p: Spaceship = player
|
||||
if not p.dead:
|
||||
@@ -500,8 +523,11 @@ func _update_objects(delta: float) -> void:
|
||||
for player in players:
|
||||
var p: Spaceship = player
|
||||
if not p.dead:
|
||||
var prev_vx := p.vx; var prev_vy := p.vy
|
||||
var nv: Vector2 = ns.push_if_in_beam(p.x, p.y, p.vx, p.vy)
|
||||
p.vx = nv.x; p.vy = nv.y
|
||||
if nv.x != prev_vx or nv.y != prev_vy:
|
||||
_fire_music_event("neutron_beam")
|
||||
neutron_stars = neutron_stars.filter(func(ns): return not ns.dead)
|
||||
for am_obj in antimatter:
|
||||
var am: CosmicObjects.Antimatter = am_obj
|
||||
@@ -537,6 +563,7 @@ func _update_objects(delta: float) -> void:
|
||||
if b != null:
|
||||
bullets.append(b)
|
||||
SoundManager.play_sfx("enemy_shoot")
|
||||
_update_bh_proximity_audio()
|
||||
|
||||
func _apply_gravity_all(_delta: float) -> void:
|
||||
for bhole in black_holes:
|
||||
@@ -578,6 +605,8 @@ func _apply_gravity_all(_delta: float) -> void:
|
||||
_spawn_spiral_particles(p.x, p.y, bh.x, bh.y, int(p.radius * 3.0), p.color, 5.0)
|
||||
bh.trigger_flash(p.color, 0.8)
|
||||
p.dead = true
|
||||
SoundManager.play_sfx("planet_impact")
|
||||
_fire_music_event("planet_captured")
|
||||
var trigger: bool = bh.on_swallow()
|
||||
if trigger:
|
||||
_trigger_supernova(bh)
|
||||
@@ -1077,7 +1106,7 @@ func _spawn_universe_partial() -> void:
|
||||
planets.append(p)
|
||||
|
||||
func _spawn_antimatter_swarm(cx: float, cy: float) -> void:
|
||||
var count: int = randi_range(6, 12)
|
||||
var count: int = randi_range(3, 5)
|
||||
for _i in count:
|
||||
var a: float = randf() * TAU
|
||||
var spd: float = randf_range(1.0, 3.0)
|
||||
@@ -1086,6 +1115,34 @@ func _spawn_antimatter_swarm(cx: float, cy: float) -> void:
|
||||
antimatter.append(am)
|
||||
|
||||
|
||||
func _fire_music_event(event_name: String) -> void:
|
||||
if main_node and "music_player" in main_node and main_node.music_player:
|
||||
main_node.music_player.play_music_event(event_name)
|
||||
|
||||
func _update_bh_proximity_audio() -> void:
|
||||
var mp: Node = main_node.music_player if main_node and "music_player" in main_node else null
|
||||
if mp == null or not is_playing or players.size() == 0:
|
||||
if mp: mp.set_bh_proximity(0.0, 1.0, false)
|
||||
return
|
||||
var player: Spaceship = players[0]
|
||||
if player.dead:
|
||||
mp.set_bh_proximity(0.0, 1.0, false)
|
||||
return
|
||||
var max_prox := 0.0
|
||||
var max_size := 1.0
|
||||
var any_smbh := false
|
||||
for bhole in black_holes:
|
||||
var bh: BlackHole = bhole
|
||||
if bh.dead or bh.pull_radius <= 0.0: continue
|
||||
var dx := player.x - bh.x
|
||||
var dy := player.y - bh.y
|
||||
var prox: float = clamp(1.0 - sqrt(dx*dx + dy*dy) / bh.pull_radius, 0.0, 1.0)
|
||||
if prox > max_prox:
|
||||
max_prox = prox
|
||||
max_size = bh.radius / 14.0
|
||||
any_smbh = bh.is_smbh
|
||||
mp.set_bh_proximity(max_prox, max_size, any_smbh)
|
||||
|
||||
func _spawn_explosion_particles(cx: float, cy: float, count: int, col: Color) -> void:
|
||||
for _i in count:
|
||||
var a: float = randf() * TAU
|
||||
@@ -1115,6 +1172,13 @@ func _spawn_spiral_particles(cx: float, cy: float, bh_x: float, bh_y: float,
|
||||
|
||||
func _draw() -> void:
|
||||
draw_rect(get_viewport_rect(), Color("#0a0a14"))
|
||||
if antimatter_warn_pending:
|
||||
var warn_t: float = antimatter_warn_timer / ANTIMATTER_WARN_DURATION
|
||||
var pulse_a: float = abs(sin(antimatter_warn_timer * TAU * 3.5))
|
||||
var ring_r: float = 25.0 + 8.0 * warn_t
|
||||
var warn_alpha: float = 0.55 * pulse_a * (1.0 - warn_t * 0.25)
|
||||
draw_arc(antimatter_warn_pos, ring_r, 0.0, TAU, 20, Color(1.0, 0.2, 0.8, warn_alpha), 2.0)
|
||||
draw_arc(antimatter_warn_pos, ring_r - 5.0, 0.0, TAU, 14, Color(0.8, 0.0, 1.0, warn_alpha * 0.5), 1.0)
|
||||
if Settings.nebula_enabled:
|
||||
for neb in nebulae:
|
||||
var n: CosmicObjects.Nebula = neb
|
||||
|
||||
Reference in New Issue
Block a user