Portals glow in the colour of the master who claimed them
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
739e82b505
commit
aeaa1eba36
1 file changed
+20
-10
+20
-10
@@ -1319,8 +1319,9 @@ impl R3d {
|
||||
let hp = (g.core_hp / CORE_HP).clamp(0.0, 1.0);
|
||||
push(vec3(cx as f32 + 1.5, 1.6, cy as f32 + 1.5), 7.0, vec3(1.0, 0.25, 0.2), 1.1 + 0.2 * (t * 3.0).sin() * (1.5 - hp), 100.0);
|
||||
for (k, &(px, py)) in g.map.portals.iter().enumerate() {
|
||||
let owned = g.map.portal_owner(k) == g.me;
|
||||
push(vec3(px as f32 + 1.5, 0.8, py as f32 + 1.5), 6.0, vec3(0.7, 0.3, 1.0), if owned { 1.0 } else { 0.35 }, 20.0);
|
||||
let tint = portal_tint(g, k);
|
||||
let c = tint.map_or(vec3(0.6, 0.55, 0.7), |c| c * 0.8 + vec3(0.1, 0.05, 0.15));
|
||||
push(vec3(px as f32 + 1.5, 0.8, py as f32 + 1.5), 6.0, c, if tint.is_some() { 1.0 } else { 0.35 }, 20.0);
|
||||
}
|
||||
if g.gate_hp > 0.0 {
|
||||
let (gx, gz) = g.gate_center();
|
||||
@@ -2359,9 +2360,10 @@ fn draw_landmarks_solid(g: &Game, t: f32) {
|
||||
if !g.map.shown(idx(px + 1, py + 1)) {
|
||||
continue;
|
||||
}
|
||||
let owned = g.map.portal_owner(pk) == g.me;
|
||||
let tint = portal_tint(g, pk);
|
||||
let owned = tint.is_some();
|
||||
let pc = vec3(px as f32 + 1.5, 0.0, py as f32 + 1.5);
|
||||
let stone = |k: u8| if owned { Color::from_rgba(46 + k, 30 + k / 2, 58 + k, 255) } else { Color::from_rgba(56 + k, 54 + k, 60 + k, 255) };
|
||||
let stone = |k: u8| if owned { hue_to(tint, Color::from_rgba(46 + k, 30 + k / 2, 58 + k, 255)) } else { Color::from_rgba(56 + k, 54 + k, 60 + k, 255) };
|
||||
let bone = if owned { Color::from_rgba(212, 200, 176, 255) } else { Color::from_rgba(150, 146, 140, 255) };
|
||||
draw_cube(pc + vec3(0.0, 0.05, 0.0), vec3(2.9, 0.1, 2.9), None, stone(0));
|
||||
draw_cube(pc + vec3(0.0, 0.14, 0.0), vec3(2.4, 0.08, 1.4), None, stone(8));
|
||||
@@ -2448,6 +2450,12 @@ pub fn master_rgb(side: u8) -> Vec3 {
|
||||
}
|
||||
}
|
||||
|
||||
// a portal claimed by a master glows in his colour; None: unclaimed (grey and still)
|
||||
fn portal_tint(g: &Game, k: usize) -> Option<Vec3> {
|
||||
let side = g.map.portal_owner(k).side();
|
||||
Owner::MASTER_SIDES.contains(&side).then(|| master_rgb(side))
|
||||
}
|
||||
|
||||
// recolours a red-tinted colour into `tint`: keeps its brightness and whiteness, swaps the hue
|
||||
fn hue_to(tint: Option<Vec3>, c: Color) -> Color {
|
||||
let Some(t) = tint else { return c };
|
||||
@@ -2535,13 +2543,15 @@ fn draw_landmarks_glow(g: &Game, t: f32, cam_r: Vec3) {
|
||||
if !g.map.shown(idx(px + 1, py + 1)) {
|
||||
continue;
|
||||
}
|
||||
let owned = g.map.portal_owner(pk) == g.me;
|
||||
let tint = portal_tint(g, pk);
|
||||
let owned = tint.is_some();
|
||||
let tc = |c: Color| hue_to(tint, c);
|
||||
let pc = vec3(px as f32 + 1.5, 0.0, py as f32 + 1.5);
|
||||
let arm = if owned { Color::new(0.8, 0.35, 1.0, 1.0) } else { Color::new(0.45, 0.42, 0.5, 1.0) };
|
||||
let arm = if owned { tc(Color::new(0.8, 0.35, 1.0, 1.0)) } else { Color::new(0.45, 0.42, 0.5, 1.0) };
|
||||
let mid = pc + vec3(0.0, 1.3, 0.0);
|
||||
let (rx, ry) = (0.95, 1.55);
|
||||
// the dark heart of the vortex: a vertical disc in the arch
|
||||
vdisc(mid, rx, ry, if owned { Color::new(0.16, 0.02, 0.26, 0.92) } else { Color::new(0.08, 0.08, 0.1, 0.85) }, 28);
|
||||
vdisc(mid, rx, ry, if owned { tc(Color::new(0.16, 0.02, 0.26, 0.92)) } else { Color::new(0.08, 0.08, 0.1, 0.85) }, 28);
|
||||
let speed = if owned { 2.0 } else { 0.25 };
|
||||
for armk in 0..3 {
|
||||
for k in 0..22 {
|
||||
@@ -2564,16 +2574,16 @@ fn draw_landmarks_glow(g: &Game, t: f32, cam_r: Vec3) {
|
||||
draw_cube(p, vec3(0.12, 0.14, 0.02), None, Color::new(arm.r, arm.g, arm.b, if owned { 0.35 + 0.65 * glow } else { 0.2 }));
|
||||
}
|
||||
if owned {
|
||||
draw_sphere(mid, 0.35 + 0.05 * (t * 3.0).sin(), None, Color::new(0.95, 0.75, 1.0, 0.5));
|
||||
draw_sphere(mid, 0.35 + 0.05 * (t * 3.0).sin(), None, tc(Color::new(0.95, 0.75, 1.0, 0.5)));
|
||||
// sparks pour out of the vortex and fall to the floor
|
||||
for k in 0..14 {
|
||||
let e = (t * 0.5 + k as f32 * 0.071).fract();
|
||||
let a = k as f32 * 2.4;
|
||||
let dir = if k % 2 == 0 { 1.0 } else { -1.0 };
|
||||
let p = mid + vec3(a.cos() * 0.5 * (1.0 - e), a.sin() * 0.6 + e * 0.4 - e * e * 1.9, dir * e * 1.1);
|
||||
draw_cube(p, Vec3::splat(0.045 * (1.0 - e) + 0.015), None, Color::new(0.95, 0.65, 1.0, 1.0 - e));
|
||||
draw_cube(p, Vec3::splat(0.045 * (1.0 - e) + 0.015), None, tc(Color::new(0.95, 0.65, 1.0, 1.0 - e)));
|
||||
}
|
||||
disc(pc + vec3(0.0, 0.2, 0.0), 1.1, Color::new(0.6, 0.25, 0.9, 0.12 + 0.05 * (t * 2.0).sin()), 24);
|
||||
disc(pc + vec3(0.0, 0.2, 0.0), 1.1, tc(Color::new(0.6, 0.25, 0.9, 0.12 + 0.05 * (t * 2.0).sin())), 24);
|
||||
}
|
||||
}
|
||||
// gate light
|
||||
|
||||
Reference in new issue
Block a user