proper background rendering with scale
This commit is contained in:
parent
0c4928b892
commit
f67b654088
@ -116,16 +116,46 @@ impl InGameScreen {
|
|||||||
.clamp(0.0, 1.0)))
|
.clamp(0.0, 1.0)))
|
||||||
.max(min_radius);
|
.max(min_radius);
|
||||||
|
|
||||||
|
// Determine width and height scales
|
||||||
|
let width_scale = 5.0;
|
||||||
|
let height_scale = 5.0;
|
||||||
|
|
||||||
|
// Get the base sizes of everything
|
||||||
|
let texture_width = game_core.resources.darkness_overlay.width as f32;
|
||||||
|
let texture_height = game_core.resources.darkness_overlay.height as f32;
|
||||||
|
let texture_width_scaled = texture_width * width_scale;
|
||||||
|
let texture_height_scaled = texture_height * height_scale;
|
||||||
|
|
||||||
// Render the overlay
|
// Render the overlay
|
||||||
draw_handle.draw_ring(
|
draw_handle.draw_texture_pro(
|
||||||
window_center,
|
&game_core.resources.darkness_overlay,
|
||||||
radius,
|
Rectangle {
|
||||||
win_width as f32,
|
x: 0.0,
|
||||||
0,
|
y: 0.0,
|
||||||
360,
|
width:texture_width,
|
||||||
128,
|
height: texture_height,
|
||||||
Color::BLACK,
|
},
|
||||||
|
Rectangle {
|
||||||
|
x: (win_width as f32 - texture_width_scaled) / 2.0,
|
||||||
|
y: (win_height as f32 - texture_height_scaled) / 2.0,
|
||||||
|
width: texture_width_scaled,
|
||||||
|
height: texture_height_scaled,
|
||||||
|
},
|
||||||
|
Vector2 { x: 0.0, y: 0.0 },
|
||||||
|
0.0,
|
||||||
|
Color::WHITE,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Render the overlay
|
||||||
|
// draw_handle.draw_ring(
|
||||||
|
// window_center,
|
||||||
|
// radius,
|
||||||
|
// win_width as f32,
|
||||||
|
// 0,
|
||||||
|
// 360,
|
||||||
|
// 128,
|
||||||
|
// Color::BLACK,
|
||||||
|
// );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,6 +24,9 @@ pub struct GlobalResources {
|
|||||||
// Enemies
|
// Enemies
|
||||||
pub jellyfish_animation_regular: FrameAnimationWrapper,
|
pub jellyfish_animation_regular: FrameAnimationWrapper,
|
||||||
pub jellyfish_animation_attack: FrameAnimationWrapper,
|
pub jellyfish_animation_attack: FrameAnimationWrapper,
|
||||||
|
|
||||||
|
// Darkness layer
|
||||||
|
pub darkness_overlay: Texture2D
|
||||||
}
|
}
|
||||||
|
|
||||||
impl GlobalResources {
|
impl GlobalResources {
|
||||||
@ -95,6 +98,10 @@ impl GlobalResources {
|
|||||||
15,
|
15,
|
||||||
4,
|
4,
|
||||||
),
|
),
|
||||||
|
darkness_overlay: raylib.load_texture_from_image(
|
||||||
|
&thread,
|
||||||
|
&Image::load_image("./assets/img/map/darkness.png")?,
|
||||||
|
)?,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user