diff --git a/.travis.yml b/.travis.yml index 3a89d79..474f519 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,5 @@ language: rust +dist: bionic rust: # MSRV - 1.40.0 @@ -13,7 +14,7 @@ before_script: - rustup component add clippy - rustup component add rustfmt - sudo apt-get update -- sudo apt-get -y install libudev-dev +- sudo apt-get -y install libsdl2-dev script: - cargo clippy --all -- -D warnings diff --git a/Cargo.toml b/Cargo.toml index 7e2cff4..f63a108 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,54 +27,12 @@ thiserror = "1.0.15" wgpu = "0.5.0" futures = "0.3" -# These are only used by the examples, and enabled with features -# See: https://github.com/rust-lang/cargo/issues/1982 -beryllium = { version = "0.2.1", features = [ "extern_crate_raw_window_handle" ], optional = true } -byteorder = { version = "1.3.4", optional = true } -env_logger = { version = "0.7.1", optional = true } -getrandom = { version = "0.1.14", optional = true } -gilrs = { version = "0.7.4", optional = true } -line_drawing = { version = "0.8.0", optional = true } -log = { version = "0.4.8", features = [ "release_max_level_warn" ], optional = true } -randomize = { version = "3.0.1", optional = true } -simple-invaders = { path = "simple-invaders", optional = true } -winit = { version = "0.22.0", optional = true } -winit_input_helper = { version = "0.6.0", optional = true } - [dev-dependencies] pixels-mocks = { path = "pixels-mocks" } winit = "0.22.0" -[[example]] -name = "conway" -required-features = ["conway"] - -[[example]] -name = "invaders" -required-features = ["invaders"] - -[[example]] -name = "minimal-sdl2" -required-features = ["minimal-sdl2"] - -[[example]] -name = "minimal-winit" -required-features = ["minimal-winit"] - -[features] -default = [] -log-deps = ["env_logger", "log"] -random-deps = ["byteorder", "getrandom", "randomize"] -sdl2-deps = ["beryllium"] -winit-deps = ["winit", "winit_input_helper"] - -conway = ["line_drawing", "log-deps", "random-deps", "winit-deps"] -invaders = ["gilrs", "log-deps", "random-deps", "simple-invaders", "winit-deps"] -minimal-sdl2 = ["log-deps", "sdl2-deps"] -minimal-winit = ["log-deps", "winit-deps"] - [workspace] members = [ + "examples/*", "pixels-mocks", - "simple-invaders", ] diff --git a/examples/conway/Cargo.toml b/examples/conway/Cargo.toml new file mode 100644 index 0000000..d79d874 --- /dev/null +++ b/examples/conway/Cargo.toml @@ -0,0 +1,17 @@ +[package] +name = "conway" +version = "0.1.0" +authors = ["Jay Oster "] +edition = "2018" +publish = false + +[dependencies] +byteorder = "1.3.4" +env_logger = "0.7.1" +getrandom = "0.1.14" +line_drawing = "0.8.0" +log = { version = "0.4.8", features = [ "release_max_level_warn" ] } +pixels = { path = "../.." } +randomize = "3.0.1" +winit = "0.22.0" +winit_input_helper = "0.6.0" diff --git a/examples/conway/README.md b/examples/conway/README.md index 779e28f..dd40c77 100644 --- a/examples/conway/README.md +++ b/examples/conway/README.md @@ -5,7 +5,7 @@ ## Running ```bash -cargo run --release --example conway --features conway +cargo run --release --package conway ``` ## Controls diff --git a/examples/conway/main.rs b/examples/conway/src/main.rs similarity index 100% rename from examples/conway/main.rs rename to examples/conway/src/main.rs diff --git a/examples/invaders/Cargo.toml b/examples/invaders/Cargo.toml new file mode 100644 index 0000000..635f5a5 --- /dev/null +++ b/examples/invaders/Cargo.toml @@ -0,0 +1,18 @@ +[package] +name = "invaders" +version = "0.1.0" +authors = ["Jay Oster "] +edition = "2018" +publish = false + +[dependencies] +byteorder = "1.3.4" +env_logger = "0.7.1" +getrandom = "0.1.14" +gilrs = "0.7.4" +log = { version = "0.4.8", features = [ "release_max_level_warn" ] } +pixels = { path = "../.." } +randomize = "3.0.1" +simple-invaders = { path = "simple-invaders" } +winit = "0.22.0" +winit_input_helper = "0.6.0" diff --git a/examples/invaders/README.md b/examples/invaders/README.md index 3b251ed..e17b0cc 100644 --- a/examples/invaders/README.md +++ b/examples/invaders/README.md @@ -7,7 +7,7 @@ The pixels have invaded! ## Running ```bash -cargo run --release --example invaders --features invaders +cargo run --release --package invaders ``` ## Controls diff --git a/simple-invaders/Cargo.toml b/examples/invaders/simple-invaders/Cargo.toml similarity index 100% rename from simple-invaders/Cargo.toml rename to examples/invaders/simple-invaders/Cargo.toml diff --git a/simple-invaders/src/assets/blipjoy1.pcx b/examples/invaders/simple-invaders/src/assets/blipjoy1.pcx similarity index 100% rename from simple-invaders/src/assets/blipjoy1.pcx rename to examples/invaders/simple-invaders/src/assets/blipjoy1.pcx diff --git a/simple-invaders/src/assets/blipjoy2.pcx b/examples/invaders/simple-invaders/src/assets/blipjoy2.pcx similarity index 100% rename from simple-invaders/src/assets/blipjoy2.pcx rename to examples/invaders/simple-invaders/src/assets/blipjoy2.pcx diff --git a/simple-invaders/src/assets/bullet1.pcx b/examples/invaders/simple-invaders/src/assets/bullet1.pcx similarity index 100% rename from simple-invaders/src/assets/bullet1.pcx rename to examples/invaders/simple-invaders/src/assets/bullet1.pcx diff --git a/simple-invaders/src/assets/bullet2.pcx b/examples/invaders/simple-invaders/src/assets/bullet2.pcx similarity index 100% rename from simple-invaders/src/assets/bullet2.pcx rename to examples/invaders/simple-invaders/src/assets/bullet2.pcx diff --git a/simple-invaders/src/assets/bullet3.pcx b/examples/invaders/simple-invaders/src/assets/bullet3.pcx similarity index 100% rename from simple-invaders/src/assets/bullet3.pcx rename to examples/invaders/simple-invaders/src/assets/bullet3.pcx diff --git a/simple-invaders/src/assets/bullet4.pcx b/examples/invaders/simple-invaders/src/assets/bullet4.pcx similarity index 100% rename from simple-invaders/src/assets/bullet4.pcx rename to examples/invaders/simple-invaders/src/assets/bullet4.pcx diff --git a/simple-invaders/src/assets/bullet5.pcx b/examples/invaders/simple-invaders/src/assets/bullet5.pcx similarity index 100% rename from simple-invaders/src/assets/bullet5.pcx rename to examples/invaders/simple-invaders/src/assets/bullet5.pcx diff --git a/simple-invaders/src/assets/cthulhu1.pcx b/examples/invaders/simple-invaders/src/assets/cthulhu1.pcx similarity index 100% rename from simple-invaders/src/assets/cthulhu1.pcx rename to examples/invaders/simple-invaders/src/assets/cthulhu1.pcx diff --git a/simple-invaders/src/assets/cthulhu2.pcx b/examples/invaders/simple-invaders/src/assets/cthulhu2.pcx similarity index 100% rename from simple-invaders/src/assets/cthulhu2.pcx rename to examples/invaders/simple-invaders/src/assets/cthulhu2.pcx diff --git a/simple-invaders/src/assets/ferris1.pcx b/examples/invaders/simple-invaders/src/assets/ferris1.pcx similarity index 100% rename from simple-invaders/src/assets/ferris1.pcx rename to examples/invaders/simple-invaders/src/assets/ferris1.pcx diff --git a/simple-invaders/src/assets/ferris2.pcx b/examples/invaders/simple-invaders/src/assets/ferris2.pcx similarity index 100% rename from simple-invaders/src/assets/ferris2.pcx rename to examples/invaders/simple-invaders/src/assets/ferris2.pcx diff --git a/simple-invaders/src/assets/laser1.pcx b/examples/invaders/simple-invaders/src/assets/laser1.pcx similarity index 100% rename from simple-invaders/src/assets/laser1.pcx rename to examples/invaders/simple-invaders/src/assets/laser1.pcx diff --git a/simple-invaders/src/assets/laser2.pcx b/examples/invaders/simple-invaders/src/assets/laser2.pcx similarity index 100% rename from simple-invaders/src/assets/laser2.pcx rename to examples/invaders/simple-invaders/src/assets/laser2.pcx diff --git a/simple-invaders/src/assets/laser3.pcx b/examples/invaders/simple-invaders/src/assets/laser3.pcx similarity index 100% rename from simple-invaders/src/assets/laser3.pcx rename to examples/invaders/simple-invaders/src/assets/laser3.pcx diff --git a/simple-invaders/src/assets/laser4.pcx b/examples/invaders/simple-invaders/src/assets/laser4.pcx similarity index 100% rename from simple-invaders/src/assets/laser4.pcx rename to examples/invaders/simple-invaders/src/assets/laser4.pcx diff --git a/simple-invaders/src/assets/laser5.pcx b/examples/invaders/simple-invaders/src/assets/laser5.pcx similarity index 100% rename from simple-invaders/src/assets/laser5.pcx rename to examples/invaders/simple-invaders/src/assets/laser5.pcx diff --git a/simple-invaders/src/assets/laser6.pcx b/examples/invaders/simple-invaders/src/assets/laser6.pcx similarity index 100% rename from simple-invaders/src/assets/laser6.pcx rename to examples/invaders/simple-invaders/src/assets/laser6.pcx diff --git a/simple-invaders/src/assets/laser7.pcx b/examples/invaders/simple-invaders/src/assets/laser7.pcx similarity index 100% rename from simple-invaders/src/assets/laser7.pcx rename to examples/invaders/simple-invaders/src/assets/laser7.pcx diff --git a/simple-invaders/src/assets/laser8.pcx b/examples/invaders/simple-invaders/src/assets/laser8.pcx similarity index 100% rename from simple-invaders/src/assets/laser8.pcx rename to examples/invaders/simple-invaders/src/assets/laser8.pcx diff --git a/simple-invaders/src/assets/player1.pcx b/examples/invaders/simple-invaders/src/assets/player1.pcx similarity index 100% rename from simple-invaders/src/assets/player1.pcx rename to examples/invaders/simple-invaders/src/assets/player1.pcx diff --git a/simple-invaders/src/assets/player2.pcx b/examples/invaders/simple-invaders/src/assets/player2.pcx similarity index 100% rename from simple-invaders/src/assets/player2.pcx rename to examples/invaders/simple-invaders/src/assets/player2.pcx diff --git a/simple-invaders/src/assets/shield.pcx b/examples/invaders/simple-invaders/src/assets/shield.pcx similarity index 100% rename from simple-invaders/src/assets/shield.pcx rename to examples/invaders/simple-invaders/src/assets/shield.pcx diff --git a/simple-invaders/src/collision.rs b/examples/invaders/simple-invaders/src/collision.rs similarity index 100% rename from simple-invaders/src/collision.rs rename to examples/invaders/simple-invaders/src/collision.rs diff --git a/simple-invaders/src/controls.rs b/examples/invaders/simple-invaders/src/controls.rs similarity index 100% rename from simple-invaders/src/controls.rs rename to examples/invaders/simple-invaders/src/controls.rs diff --git a/simple-invaders/src/debug.rs b/examples/invaders/simple-invaders/src/debug.rs similarity index 100% rename from simple-invaders/src/debug.rs rename to examples/invaders/simple-invaders/src/debug.rs diff --git a/simple-invaders/src/geo.rs b/examples/invaders/simple-invaders/src/geo.rs similarity index 100% rename from simple-invaders/src/geo.rs rename to examples/invaders/simple-invaders/src/geo.rs diff --git a/simple-invaders/src/lib.rs b/examples/invaders/simple-invaders/src/lib.rs similarity index 100% rename from simple-invaders/src/lib.rs rename to examples/invaders/simple-invaders/src/lib.rs diff --git a/simple-invaders/src/loader.rs b/examples/invaders/simple-invaders/src/loader.rs similarity index 100% rename from simple-invaders/src/loader.rs rename to examples/invaders/simple-invaders/src/loader.rs diff --git a/simple-invaders/src/sprites.rs b/examples/invaders/simple-invaders/src/sprites.rs similarity index 100% rename from simple-invaders/src/sprites.rs rename to examples/invaders/simple-invaders/src/sprites.rs diff --git a/examples/invaders/main.rs b/examples/invaders/src/main.rs similarity index 100% rename from examples/invaders/main.rs rename to examples/invaders/src/main.rs diff --git a/examples/minimal-sdl2/Cargo.toml b/examples/minimal-sdl2/Cargo.toml new file mode 100644 index 0000000..e089d9b --- /dev/null +++ b/examples/minimal-sdl2/Cargo.toml @@ -0,0 +1,12 @@ +[package] +name = "minimal-sdl2" +version = "0.1.0" +authors = ["Jay Oster "] +edition = "2018" +publish = false + +[dependencies] +beryllium = { version = "0.2.1", features = [ "extern_crate_raw_window_handle" ] } +env_logger = "0.7.1" +log = { version = "0.4.8", features = [ "release_max_level_warn" ] } +pixels = { path = "../.." } diff --git a/examples/minimal-sdl2/README.md b/examples/minimal-sdl2/README.md index aac54d4..683fc31 100644 --- a/examples/minimal-sdl2/README.md +++ b/examples/minimal-sdl2/README.md @@ -7,11 +7,9 @@ Minimal example with SDL2 using `beryllium`. ## Running ```bash -cargo run --release --example minimal-sdl2 --features minimal-sdl2 +cargo run --release --package minimal-sdl2 ``` ## About This example demonstrates the absolute minimum for creating an SDL2 window and pixel buffer. It animates a purple box moving on a blue background, just for _something_ interesting to display. - -The example currently does not run on macOS. See [#47](https://github.com/parasyte/pixels/issues/47) for details. diff --git a/examples/minimal-sdl2/main.rs b/examples/minimal-sdl2/src/main.rs similarity index 95% rename from examples/minimal-sdl2/main.rs rename to examples/minimal-sdl2/src/main.rs index 687e236..65f6250 100644 --- a/examples/minimal-sdl2/main.rs +++ b/examples/minimal-sdl2/src/main.rs @@ -72,10 +72,10 @@ impl World { /// Update the `World` internal state; bounce the box around the screen. fn update(&mut self) { - if self.box_x <= 0 || self.box_x + BOX_SIZE - 1 >= WIDTH as i16 { + if self.box_x <= 0 || self.box_x + BOX_SIZE > WIDTH as i16 { self.velocity_x *= -1; } - if self.box_y <= 0 || self.box_y + BOX_SIZE - 1 >= HEIGHT as i16 { + if self.box_y <= 0 || self.box_y + BOX_SIZE > HEIGHT as i16 { self.velocity_y *= -1; } diff --git a/examples/minimal-winit/Cargo.toml b/examples/minimal-winit/Cargo.toml new file mode 100644 index 0000000..8eda3f5 --- /dev/null +++ b/examples/minimal-winit/Cargo.toml @@ -0,0 +1,13 @@ +[package] +name = "minimal-winit" +version = "0.1.0" +authors = ["Jay Oster "] +edition = "2018" +publish = false + +[dependencies] +env_logger = "0.7.1" +log = { version = "0.4.8", features = [ "release_max_level_warn" ] } +pixels = { path = "../.." } +winit = "0.22.0" +winit_input_helper = "0.6.0" diff --git a/examples/minimal-winit/README.md b/examples/minimal-winit/README.md index 003cab3..5ee7c30 100644 --- a/examples/minimal-winit/README.md +++ b/examples/minimal-winit/README.md @@ -7,7 +7,7 @@ Minimal example with `winit`. ## Running ```bash -cargo run --release --example minimal-winit --features minimal-winit +cargo run --release --package minimal-winit ``` ## About diff --git a/examples/minimal-winit/main.rs b/examples/minimal-winit/src/main.rs similarity index 95% rename from examples/minimal-winit/main.rs rename to examples/minimal-winit/src/main.rs index be7c720..94a2080 100644 --- a/examples/minimal-winit/main.rs +++ b/examples/minimal-winit/src/main.rs @@ -87,10 +87,10 @@ impl World { /// Update the `World` internal state; bounce the box around the screen. fn update(&mut self) { - if self.box_x <= 0 || self.box_x + BOX_SIZE - 1 >= WIDTH as i16 { + if self.box_x <= 0 || self.box_x + BOX_SIZE > WIDTH as i16 { self.velocity_x *= -1; } - if self.box_y <= 0 || self.box_y + BOX_SIZE - 1 >= HEIGHT as i16 { + if self.box_y <= 0 || self.box_y + BOX_SIZE > HEIGHT as i16 { self.velocity_y *= -1; } diff --git a/src/lib.rs b/src/lib.rs index dff1b8a..8a0abe7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -487,7 +487,7 @@ impl<'req> PixelsBuilder<'req> { // Create all render passes renderers.extend(self.renderer_factories.iter().map(|f| { - // TODO: Create a texture chain so that each pass recieves the texture drawn by the previous + // TODO: Create a texture chain so that each pass receives the texture drawn by the previous f( device.clone(), queue.clone(),