package main import rl "vendor:raylib" import "core:slice" import "core:math/ease" import "core:fmt" Explosion :: struct{ position: vec3, radius: f32, max_radius: f32, time: f32, color: rl.Color, duration: f32, to_free: bool, } explosions_buf : [256]Explosion explosions : [dynamic]Explosion explosions_init :: proc() { explosions = slice.into_dynamic(explosions_buf[:]) } explode :: proc(position: vec3, max_radius: f32, duration: f32, color: rl.Color = rl.YELLOW) { append(&explosions, Explosion { position = position, max_radius = max_radius, duration = duration, color = color }) } explosions_process :: proc(delta: f32) { #reverse for &e, i in explosions { e.time += delta e.radius = ease.back_out(e.time / e.duration) * e.max_radius if e.time > e.duration { unordered_remove(&explosions, i) } } } explosions_draw :: proc() { rl.BeginBlendMode(rl.BlendMode.ADDITIVE) #reverse for &e, i in explosions { color := rl.ColorAlpha(e.color, 1 - ease.exponential_in(e.time / e.duration)) rl.DrawSphere(e.position, e.radius, color) } rl.EndBlendMode() }