-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update to bevy 0.12.0 and split up files
- Loading branch information
Showing
8 changed files
with
239 additions
and
230 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,15 @@ | ||
[package] | ||
name = "bevy_smooth_pixel_camera" | ||
version = "0.1.0" | ||
version = "0.12.0" | ||
edition = "2021" | ||
authors = ["Doonv"] | ||
description = "Smooth pixel-perfect camera for Bevy" | ||
repository = "https://github.com/doonv/bevy_smooth_pixel_camera" | ||
exclude = ["assets/"] | ||
exclude = ["assets/", ".github/"] | ||
keywords = ["game", "gamedev", "graphics", "bevy", "pixel", "pixel-perfect"] | ||
license = "MIT OR Apache-2.0" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
bevy = "0.11.3" | ||
|
||
# Enable a small amount of optimization in debug mode | ||
[profile.dev] | ||
opt-level = 1 | ||
|
||
# Enable high optimizations for dependencies (incl. Bevy), but not for our code: | ||
[profile.dev.package."*"] | ||
opt-level = 3 | ||
bevy = "0.12.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
use bevy::{prelude::*, render::view::RenderLayers}; | ||
|
||
/// The pixelated camera component. | ||
/// | ||
/// Add this component to a [`Camera2dBundle`] in order to turn it into a | ||
/// pixelated camera. | ||
/// | ||
/// **Warning:** In order to move the camera please use the `subpixel_pos` | ||
/// attribute instead of the [`Transform`] component (the transform is a truncated version of subpixel_pos) | ||
#[derive(Component)] | ||
pub struct PixelCamera { | ||
/// The level of upscaling to use for pixels. | ||
/// | ||
/// For example: A scaling of `4` which cause every world pixel to be 4x4 in size on the screen. | ||
pub scaling: u8, | ||
/// The subpixel position of the [`PixelCamera`], use this instead of the camera's [`Transform`]. | ||
pub subpixel_pos: Vec2, | ||
/// The order in which the viewport camera renders. | ||
/// Cameras with a higher order are rendered later, and thus on top of lower order cameras. | ||
/// | ||
/// Because we want the world camera to render before the viewport camera, set this value to a positive number. | ||
pub viewport_order: isize, | ||
/// The rendering layer the viewport is on. | ||
pub viewport_layer: RenderLayers, | ||
} | ||
|
||
impl Default for PixelCamera { | ||
fn default() -> Self { | ||
Self { | ||
viewport_order: 1, | ||
scaling: 2, | ||
viewport_layer: RenderLayers::layer(1), | ||
subpixel_pos: Vec2::ZERO, | ||
} | ||
} | ||
} | ||
|
||
impl PixelCamera { | ||
/// Creates a new pixel camera with the `scaling` of choice. | ||
pub fn from_scaling(scaling: u8) -> Self { | ||
Self { | ||
scaling, | ||
..default() | ||
} | ||
} | ||
} | ||
|
||
|
||
#[derive(Component)] | ||
pub struct PixelViewport(pub Entity); | ||
#[derive(Component)] | ||
pub struct PixelViewportMarker; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
//! `use bevy_smooth_pixel_camera::prelude::*;` to import the [`PixelCamera`] and [`PixelCameraPlugin`]. | ||
pub use super::{PixelCameraPlugin, components::PixelCamera}; |
Oops, something went wrong.