Give the walls some thickness

This commit is contained in:
Emi Simpson 2021-11-21 11:29:05 -05:00
parent 07ddec501a
commit 261392ee3d
Signed by: Emi
GPG key ID: A12F2C2FFDC3D847

View file

@ -35,6 +35,7 @@ const FG: Color = Color::new(0.7686, 0.7216, 0.4078, 1.0);
const SPEED: f64 = 0.1;
const BOING_RADIUS: f64 = 30.0;
const LIGHT_RADIUS: f32 = 128.;
const WALL_THICKNESS: f32 = 5.;
#[macroquad::main("BasicShapes")]
async fn main() {
@ -90,7 +91,18 @@ async fn main() {
let w1 = w1.as_f32();
let w2 = w2.as_f32();
if shadows::wall_needs_to_be_drawn(w1, w2, mouse_position, LIGHT_RADIUS) {
shadows::draw_wall(w1, w2, mouse_position, LIGHT_RADIUS);
let perpendicular = (w1 - w2).perp();
let shift = perpendicular / perpendicular.length() * WALL_THICKNESS;
let points = [
w1 + shift,
w1 - shift,
w2 + shift,
w2 - shift,
];
shadows::draw_wall(points[0], points[1], mouse_position, LIGHT_RADIUS);
shadows::draw_wall(points[1], points[2], mouse_position, LIGHT_RADIUS);
shadows::draw_wall(points[2], points[3], mouse_position, LIGHT_RADIUS);
shadows::draw_wall(points[3], points[0], mouse_position, LIGHT_RADIUS);
}
}