Reorganize dependencies (#46)

* Reorganize dependencies

* Enable logging in the minimal-winit example

* Fix a very minor bug in the minimal-winit example
This commit is contained in:
Jay Oster 2019-11-19 19:37:36 -08:00 committed by GitHub
parent cb14f2d977
commit 8061ce0ea4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 41 additions and 14 deletions

View file

@ -25,18 +25,44 @@ maintenance = { status = "actively-developed" }
[dependencies] [dependencies]
wgpu = "0.4" wgpu = "0.4"
# These are only used by the examples, and enabled with features
# See: https://github.com/rust-lang/cargo/issues/1982
byteorder = { version = "1.3", optional = true }
env_logger = { version = "0.7", optional = true }
getrandom = { version = "0.1", optional = true }
gilrs = { version = "0.7", optional = true }
line_drawing = { version = "0.8", optional = true }
log = { version = "0.4", features = ["release_max_level_warn"], optional = true }
randomize = { version = "3.0", optional = true }
simple-invaders = { path = "simple-invaders", optional = true }
winit = { version = "0.20.0-alpha4", optional = true }
winit_input_helper = { version = "0.4.0-alpha4", optional = true }
[dev-dependencies] [dev-dependencies]
byteorder = "1.3"
env_logger = "0.7"
getrandom = "0.1"
gilrs = "0.7"
line_drawing = "0.8"
log = { version = "0.4", features = ["release_max_level_warn"] }
pixels-mocks = { path = "pixels-mocks" } pixels-mocks = { path = "pixels-mocks" }
randomize = "3.0"
simple-invaders = { path = "simple-invaders" }
winit = "0.20.0-alpha4" winit = "0.20.0-alpha4"
winit_input_helper = "0.4.0-alpha4"
[[example]]
name = "conway"
required-features = ["conway"]
[[example]]
name = "invaders"
required-features = ["invaders"]
[[example]]
name = "minimal-winit"
required-features = ["minimal-winit"]
[features]
default = []
log-deps = ["env_logger", "log"]
random-deps = ["byteorder", "getrandom", "randomize"]
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-winit = ["log-deps", "winit-deps"]
[workspace] [workspace]
members = [ members = [

View file

@ -5,7 +5,7 @@
## Running ## Running
```bash ```bash
cargo run --release --example conway cargo run --release --example conway --features conway
``` ```
## Controls ## Controls

View file

@ -7,7 +7,7 @@ The pixels have invaded!
## Running ## Running
```bash ```bash
cargo run --release --example invaders cargo run --release --example invaders --features invaders
``` ```
## Controls ## Controls

View file

@ -7,7 +7,7 @@ Minimal example with `winit`.
## Running ## Running
```bash ```bash
cargo run --release --example minimal-winit cargo run --release --example minimal-winit --features minimal-winit
``` ```
## About ## About

View file

@ -21,6 +21,7 @@ struct World {
} }
fn main() -> Result<(), Error> { fn main() -> Result<(), Error> {
env_logger::init();
let event_loop = EventLoop::new(); let event_loop = EventLoop::new();
let mut input = WinitInputHelper::new(); let mut input = WinitInputHelper::new();
let window = { let window = {
@ -94,10 +95,10 @@ impl World {
/// Update the `World` internal state; bounce the box around the screen. /// Update the `World` internal state; bounce the box around the screen.
fn update(&mut self) { fn update(&mut self) {
if self.box_x < 0 || self.box_x + BOX_SIZE >= WIDTH as i16 { if self.box_x <= 0 || self.box_x + BOX_SIZE - 1 >= WIDTH as i16 {
self.velocity_x *= -1; self.velocity_x *= -1;
} }
if self.box_y < 0 || self.box_y + BOX_SIZE >= HEIGHT as i16 { if self.box_y <= 0 || self.box_y + BOX_SIZE - 1 >= HEIGHT as i16 {
self.velocity_y *= -1; self.velocity_y *= -1;
} }