Skip to content

Commit

Permalink
Bevy 0.10, glam 0.23 (#49)
Browse files Browse the repository at this point in the history
  • Loading branch information
ManevilleF authored Mar 8, 2023
1 parent 19f461d commit 83d6a51
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 17 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@

* Deprecated `Hex::to_array3` in favor of `Hex::to_cubic_array`
* Made most modules public but kept the wildcard exports at the crate root
* Bump `bevy` dev dependenvy to `0.10` and updated the examples
* Bump `glam` to `0.23`

## 0.4.2

Expand Down
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ default = []
ser_de = ["serde", "glam/serde"]

[dependencies]
glam = "0.22"
glam = "0.23"
itertools = "0.10"

[dependencies.serde]
Expand All @@ -27,8 +27,8 @@ optional = true

# For lib.rs doctests and examples
[dev-dependencies.bevy]
version = "0.9"
features = ["render", "bevy_asset", "bevy_winit", "x11"]
version = "0.10"
features = ["bevy_render", "bevy_pbr", "bevy_core_pipeline", "bevy_asset", "bevy_winit", "x11"]
default-features = false

[[example]]
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
let world_pos = layout.hex_to_world_pos(hex);
```

## Usage in [Bevy](https://bevyengine.org/) 0.9.x
## Usage in [Bevy](https://bevyengine.org/)

If you want to generate 3D hexagonal mesh and use it in [bevy](bevyengine.org) you may do it this way:

Expand Down
11 changes: 5 additions & 6 deletions examples/3d_columns.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
use bevy::prelude::*;
use bevy::render::mesh::Indices;
use bevy::render::render_resource::PrimitiveTopology;
use bevy::time::FixedTimestep;
use bevy::time::common_conditions::on_timer;
use hexx::shapes;
use hexx::*;
use std::collections::HashMap;
use std::time::Duration;

/// World size of the hexagons (outer radius)
const HEX_SIZE: Vec2 = Vec2::splat(1.0);
/// World space height of hex columns
const COLUMN_HEIGHT: f32 = 10.0;
/// Map radius
const MAP_RADIUS: u32 = 20;
/// Animation time step
const TIME_STEP: Duration = Duration::from_millis(100);

pub fn main() {
App::new()
Expand All @@ -22,11 +25,7 @@ pub fn main() {
.add_plugins(DefaultPlugins)
.add_startup_system(setup_camera)
.add_startup_system(setup_grid)
.add_system_set(
SystemSet::new()
.with_run_criteria(FixedTimestep::step(0.1))
.with_system(animate_rings),
)
.add_system(animate_rings.run_if(on_timer(TIME_STEP)))
.run();
}

Expand Down
12 changes: 6 additions & 6 deletions examples/hex_grid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use std::collections::HashMap;
use bevy::prelude::*;
use bevy::render::mesh::Indices;
use bevy::render::render_resource::PrimitiveTopology;
use bevy::window::PrimaryWindow;
use hexx::shapes;
use hexx::*;

Expand All @@ -16,11 +17,10 @@ pub fn main() {
..default()
})
.add_plugins(DefaultPlugins.set(WindowPlugin {
window: WindowDescriptor {
width: 1_000.0,
height: 1_000.0,
primary_window: Some(Window {
resolution: (1_000.0, 1_000.0).into(),
..default()
},
}),
..default()
}))
.add_startup_system(setup_camera)
Expand Down Expand Up @@ -115,11 +115,11 @@ fn setup_grid(
/// Input interaction
fn handle_input(
mut commands: Commands,
windows: Res<Windows>,
windows: Query<&Window, With<PrimaryWindow>>,
map: Res<Map>,
mut highlighted_hexes: Local<HighlightedHexes>,
) {
let window = windows.primary();
let window = windows.single();
if let Some(pos) = window.cursor_position() {
let pos = Vec2::new(pos.x, window.height() - pos.y)
- Vec2::new(window.width(), window.height()) / 2.0;
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
//! let world_pos = layout.hex_to_world_pos(hex);
//!```
//!
//! ## Usage in [Bevy](https://bevyengine.org/) 0.9.x
//! ## Usage in [Bevy](https://bevyengine.org/)
//!
//! If you want to generate 3D hexagonal mesh and use it in [bevy](bevyengine.org) you may do it this way:
//!
Expand Down

0 comments on commit 83d6a51

Please sign in to comment.