generated from 2ndbeam/bevy-template
feat: lighting system
- Added lamp bundle - Moved door collider to its children - Updated level structure
This commit is contained in:
parent
3cddecf592
commit
08751ff12f
12 changed files with 134 additions and 31 deletions
26
src/layout/light.rs
Normal file
26
src/layout/light.rs
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
use bevy::prelude::*;
|
||||
use bevy_light_2d::prelude::*;
|
||||
|
||||
use crate::meters;
|
||||
|
||||
const LAMP_IMAGE_PATH: &'static str = "sprites/interactive/lamp.png";
|
||||
|
||||
#[derive(Component, Clone, Copy, Default, Reflect, Debug, PartialEq, Eq)]
|
||||
#[reflect(Component, Clone, Default, Debug, PartialEq)]
|
||||
#[require(Transform)]
|
||||
pub struct Lamp;
|
||||
|
||||
pub fn lamp_bundle(asset_server: &Res<AssetServer>, pos: Vec2, intensity: f32, radius: f32) -> impl Bundle {
|
||||
let image = asset_server.load(LAMP_IMAGE_PATH);
|
||||
(
|
||||
SpotLight2d {
|
||||
intensity,
|
||||
radius,
|
||||
source_width: meters(0.5),
|
||||
cast_shadows: true,
|
||||
..default()
|
||||
},
|
||||
Transform::from_xyz(pos.x, pos.y, 0.),
|
||||
Sprite::from_image(image),
|
||||
)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue