Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: improve Cell API #5

Merged
merged 1 commit into from
Feb 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ coverage

# VSCode
.vscode
.DS_Store
**/.DS_Store
34 changes: 34 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,40 @@ and this project adheres to [Conventional Commits](https://www.conventionalcommi

## [Unreleased]

## [0.6.1] - 2025-02-11

### Added
- Added `Cell::to_bits` helper API for developer experience returns the `Cell::bits` representation.

### Updated
- Improved examples `bevy_pathfinding` and `bevy_ecs_tilemap` to use `Cell::to_bits` instead of `to_bits_str`.
- Cargo update

### Breaking
- `to_bits_str` now returns `&'static str` whereas `to_bits_string` now returns a `String`.

## [0.6.0] - 2025-02-8

### Added
- Introduced feature `pathfinding` as default feature.
- Added A*Pathfinding for `OrthogonalMaze`.
- Added `Start` and `Goal` components for `OrthogonalMaze`. Support for Pathfinding.
- Added extra functions to `CoordsComponent`:
- `new` creates new `CoordsComponent` from `x` and `y` type usize
- `xy` returns `(usize, usize)` of `CoordsComponent`. Where `(x, y)`
- Added maze `CellSize` Resource as type f32.
- Added examples:
- bevy_ecs_tilemap
- bevy_pathfinding

### Updated
- Implemented `fmt::Display` for `CoordsComponent`.

## [0.5.2] - 2025-02-7

### Updated
- Cargo update

## [0.5.1] - 2025-01-31

### Added
Expand Down
38 changes: 19 additions & 19 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "bevy_knossos"
version = "0.6.0"
version = "0.6.1"
authors = [
"Julia Naomi <[email protected]>",
"unrenamed <[email protected]>",
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ For information on knossos CLI usage, check the original repository [#Cli](https

## Features

| name | description | default|
| ------------- | ----------- | ------ |
| `pathfinding` | Enables bevy to pathfind in the Maze (banner image is a demo) | false |
| name | description | default| dependencies |
| ------------- | ----------- | ------ | ------------ |
| `pathfinding` | Enables bevy to pathfind in the Maze (banner image is a demo) | true | `pathfinding = "4.14"` |

### Examples:

Expand Down
36 changes: 18 additions & 18 deletions examples/bevy_ecs_tilemap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ fn setup(mut commands: Commands, maze: Res<maze::OrthogonalMaze>, asset_server:
let maze_cache: HashMap<(usize, usize), &maze::Cell> = maze.iter().collect();

for ((x, y), cell) in maze.iter() {
let index = cell_to_index(cell.to_bits_str().as_str(), (x, y), &maze_cache);
let index = cell_to_index(cell.to_bits(), (x, y), &maze_cache);

let tile_pos = TilePos {
x: x as u32,
Expand Down Expand Up @@ -132,35 +132,35 @@ fn check_corner(
}

fn cell_to_index(
cell: &str,
cell: u8,
position: (usize, usize),
cache: &HashMap<(usize, usize), &maze::Cell>,
) -> TileTextureIndex {
TileTextureIndex(
// wesn
match cell {
"0000" => 358,
"0001" => 286,
"0010" => 312,
"0011" => 309,
"0100" => 313,
"0101" => {
0b0000 => 358,
0b0001 => 286,
0b0010 => 312,
0b0011 => 309,
0b0100 => 313,
0b0101 => {
let has_ne_corner = check_corner(position, IVec2::new(1, -1), cache);
if has_ne_corner {
307
} else {
314
}
}
"0110" => {
0b0110 => {
let has_se_corner = check_corner(position, IVec2::new(1, 1), cache);
if has_se_corner {
280
} else {
287
}
}
"0111" => {
0b0111 => {
let has_ne_corner = check_corner(position, IVec2::new(1, -1), cache);
let has_se_corner = check_corner(position, IVec2::new(1, 1), cache);
match (has_ne_corner, has_se_corner) {
Expand All @@ -170,24 +170,24 @@ fn cell_to_index(
(false, false) => 338,
}
}
"1000" => 285,
"1001" => {
0b1000 => 285,
0b1001 => {
let has_nw_corner = check_corner(position, IVec2::new(-1, -1), cache);
if has_nw_corner {
308
} else {
315
}
}
"1010" => {
0b1010 => {
let has_sw_corner = check_corner(position, IVec2::new(-1, 1), cache);
if has_sw_corner {
281
} else {
288
}
}
"1011" => {
0b1011 => {
let has_nw_corner = check_corner(position, IVec2::new(-1, -1), cache);
let has_sw_corner = check_corner(position, IVec2::new(-1, 1), cache);
match (has_nw_corner, has_sw_corner) {
Expand All @@ -197,8 +197,8 @@ fn cell_to_index(
(false, false) => 339,
}
}
"1100" => 282,
"1101" => {
0b1100 => 282,
0b1101 => {
let has_ne_corner = check_corner(position, IVec2::new(1, -1), cache);
let has_nw_corner = check_corner(position, IVec2::new(-1, -1), cache);
match (has_ne_corner, has_nw_corner) {
Expand All @@ -208,7 +208,7 @@ fn cell_to_index(
(false, false) => 366,
}
}
"1110" => {
0b1110 => {
let has_se_corner = check_corner(position, IVec2::new(1, 1), cache);
let has_sw_corner = check_corner(position, IVec2::new(-1, 1), cache);
match (has_se_corner, has_sw_corner) {
Expand All @@ -218,7 +218,7 @@ fn cell_to_index(
(false, false) => 365,
}
}
"1111" => {
0b1111 => {
let has_ne_corner = check_corner(position, IVec2::new(1, -1), cache);
let has_nw_corner = check_corner(position, IVec2::new(-1, -1), cache);
let has_se_corner = check_corner(position, IVec2::new(1, 1), cache);
Expand Down
Loading