Skip to content
Snippets Groups Projects
parallax.rs 514 B
Newer Older
Louis's avatar
Louis committed
use crate::entities::EntitySpawner;
use crate::system::window_bounds;
use bevy::prelude::{Component, Vec2};

#[derive(Component)]
pub struct Background;

// TODO: No Magic Numbers!
const BACKGROUND_WIDTH: f32 = 2110.0;

pub fn spawn_backgrounds(mut spawner: EntitySpawner) {
	let bounds = window_bounds();
	spawner.spawn_background_at(Vec2::new(BACKGROUND_WIDTH / 2.0, bounds.height() / 2.0));

	spawner.spawn_background_at(Vec2::new(
		(BACKGROUND_WIDTH / 2.0) + BACKGROUND_WIDTH,
		bounds.height() / 2.0,
	));
}