Adding a map creation plugin #57

Merged
CoCo_Sol merged 39 commits from map-generation into main 2024-02-21 20:10:03 +00:00
Owner

closes: #26

closes: #26
CoCo_Sol added this to the Gameplay milestone 2024-02-16 21:43:19 +00:00
CoCo_Sol added the
Kind/Feature
label 2024-02-16 21:43:19 +00:00
CoCo_Sol self-assigned this 2024-02-16 21:43:19 +00:00
CoCo_Sol added 1 commit 2024-02-16 21:43:20 +00:00
save
All checks were successful
Rust Checks / checks (push) Successful in 1m12s
Rust Checks / checks (pull_request) Successful in 1m11s
c8ad4818ab
CoCo_Sol added 1 commit 2024-02-16 21:54:21 +00:00
change doc
Some checks failed
Rust Checks / checks (push) Has been cancelled
Rust Checks / checks (pull_request) Successful in 1m10s
ef693b54d9
CoCo_Sol added 1 commit 2024-02-16 21:55:17 +00:00
chnage disposition
All checks were successful
Rust Checks / checks (push) Successful in 1m11s
Rust Checks / checks (pull_request) Successful in 1m9s
066561ff6c
CoCo_Sol requested review from tipragot 2024-02-16 22:01:01 +00:00
tipragot requested changes 2024-02-16 22:21:04 +00:00
tipragot left a comment
Contributor

The system needs to clean the last generated map, and I think it will be usefull to add an event to tell when the generation is ended.

The system needs to clean the last generated map, and I think it will be usefull to add an event to tell when the generation is ended.
@ -0,0 +28,4 @@
pub radius: usize,
}
/// spawns the tiles if the event is received.
Contributor

Put an UPPERCASE "s"

Put an UPPERCASE "s"
CoCo_Sol marked this conversation as resolved
CoCo_Sol added 1 commit 2024-02-16 22:22:00 +00:00
change doc
All checks were successful
Rust Checks / checks (push) Successful in 1m10s
Rust Checks / checks (pull_request) Successful in 1m12s
32f09423cb
CoCo_Sol added 1 commit 2024-02-17 20:10:48 +00:00
ajout d'un event de fin de map
All checks were successful
Rust Checks / checks (push) Successful in 3m10s
Rust Checks / checks (pull_request) Successful in 1m47s
e3c2bc1ac9
CoCo_Sol added 1 commit 2024-02-17 20:42:45 +00:00
delete the map
Some checks failed
Rust Checks / checks (push) Has been cancelled
Rust Checks / checks (pull_request) Failing after 1m33s
1350b04e29
CoCo_Sol added 1 commit 2024-02-17 20:43:26 +00:00
add doc
All checks were successful
Rust Checks / checks (push) Successful in 1m13s
Rust Checks / checks (pull_request) Successful in 1m11s
0fdc351356
CoCo_Sol requested review from tipragot 2024-02-17 21:50:57 +00:00
CoCo_Sol added 1 commit 2024-02-18 10:17:56 +00:00
update
All checks were successful
Rust Checks / checks (push) Successful in 3m29s
Rust Checks / checks (pull_request) Successful in 1m44s
744d9b646e
tipragot requested changes 2024-02-18 18:06:50 +00:00
@ -0,0 +33,4 @@
/// An event send when the map is generated.
#[derive(Event)]
pub struct EndMapGenerationEvent;
Contributor

You should follow the bevy convention. Events in bevy doen't finish with "Event".

You should follow the bevy convention. Events in bevy doen't finish with "Event".
CoCo_Sol marked this conversation as resolved
CoCo_Sol added 1 commit 2024-02-18 19:59:59 +00:00
update
Some checks failed
Rust Checks / checks (push) Failing after 8s
Rust Checks / checks (pull_request) Failing after 5s
fcd0bdf9ed
CoCo_Sol added 1 commit 2024-02-18 20:00:49 +00:00
update
Some checks failed
Rust Checks / checks (push) Failing after 5s
Rust Checks / checks (pull_request) Failing after 5s
d3c89956a1
CoCo_Sol added 1 commit 2024-02-18 20:02:38 +00:00
update doc
All checks were successful
Rust Checks / checks (push) Successful in 1m47s
Rust Checks / checks (pull_request) Successful in 1m25s
135f1b7347
CoCo_Sol requested review from tipragot 2024-02-18 20:04:51 +00:00
CoCo_Sol added 1 commit 2024-02-18 21:04:09 +00:00
update
All checks were successful
Rust Checks / checks (push) Successful in 3m29s
Rust Checks / checks (pull_request) Successful in 1m46s
f5ffcffb13
tipragot requested changes 2024-02-20 01:32:42 +00:00
@ -0,0 +23,4 @@
/// An event to trigger the generation of the map.
#[derive(Event)]
pub struct MapGeneration {
Contributor

If the End event start with "End" why this don't start with "Start" ?

If the End event start with "End" why this don't start with "Start" ?
CoCo_Sol marked this conversation as resolved
@ -0,0 +41,4 @@
mut end_map_event: EventWriter<EndMapGeneration>,
mut commands: Commands,
mut noise: Local<Option<Perlin>>,
mut map_iterator: Local<Option<HexSpiral<isize>>>,
Contributor

Isize will not be great to use for networking because it's length depend on the system that runs the program.
Also you should use type to alias a specific type for the HexPosition used for the map.

Isize will not be great to use for networking because it's length depend on the system that runs the program. Also you should use `type` to alias a specific type for the HexPosition used for the map.
Author
Owner

I use only one time the hex position, is it really better to create a new type ?

I use only one time the hex position, is it really better to create a new type ?
Contributor

You will use it every time you want to make a Query on the HexPosition

You will use it every time you want to make a Query on the HexPosition
Author
Owner

ok, you've convinced me

ok, you've convinced me
CoCo_Sol marked this conversation as resolved
@ -0,0 +49,4 @@
*map_iterator = Some(HexPosition(0, 0).spiral(event.radius));
}
if let (Some(perlin), Some(spiral)) = (noise.as_ref(), map_iterator.as_mut()) {
Contributor

You can use the let else syntax to remove one level of nesting.

You can use the let else syntax to remove one level of nesting.
Author
Owner

if I use the "else let" keyword, the nesting level is the same

if I use the "else let" keyword, the nesting level is the same
Contributor

No because you do an early return

No because you do an early return
Author
Owner

I have to write an unwrap so ?

I have to write an unwrap so ?
Contributor

No, an let else

No, an let else
CoCo_Sol marked this conversation as resolved
@ -0,0 +62,4 @@
}
/// Returns the type of the tile at the given position with the given noise.
fn get_type_tile(position: (f32, f32), noise: &Perlin) -> Tile {
Contributor

Why don't you use HexPosition here?

Why don't you use HexPosition here?
Author
Owner

because is not a hex position in a hex grid but a position in orthogonal grid

because is not a hex position in a hex grid but a position in orthogonal grid
Contributor

You need to change the name of the function or take an HexPosition and convert it in the function, because it can be confusing that you use "tile" to describe the orthogonal position of an HexPosition

You need to change the name of the function or take an HexPosition and convert it in the function, because it can be confusing that you use "tile" to describe the orthogonal position of an HexPosition
Author
Owner

you are right

you are right
CoCo_Sol marked this conversation as resolved
@ -0,0 +71,4 @@
}
}
/// Despawns the tiles if the event : [EndMapGenerationEvent] is received.
Contributor

This comment is wrong.

This comment is wrong.
CoCo_Sol marked this conversation as resolved
CoCo_Sol added 3 commits 2024-02-20 10:31:23 +00:00
change doc
All checks were successful
Rust Checks / checks (push) Successful in 3m51s
Rust Checks / checks (pull_request) Successful in 1m46s
07ffb9e45c
CoCo_Sol added 2 commits 2024-02-21 10:21:03 +00:00
update
Some checks failed
Rust Checks / checks (push) Failing after 19s
Rust Checks / checks (pull_request) Failing after 5s
915d5ba5a4
CoCo_Sol added 1 commit 2024-02-21 10:35:16 +00:00
add let else
Some checks failed
Rust Checks / checks (push) Failing after 4s
Rust Checks / checks (pull_request) Failing after 4s
74d81721c7
CoCo_Sol added 1 commit 2024-02-21 10:38:54 +00:00
Update crates/border-wars/src/map/generation.rs
Some checks failed
Rust Checks / checks (push) Failing after 5s
Rust Checks / checks (pull_request) Failing after 4s
3ebe60d6cd
CoCo_Sol added 2 commits 2024-02-21 10:42:39 +00:00
Merge branch 'map-generation' of https://git.tipragot.fr/corentin/border-wars into map-generation
Some checks failed
Rust Checks / checks (push) Failing after 3m39s
Rust Checks / checks (pull_request) Failing after 1m53s
c80d8191be
CoCo_Sol added 1 commit 2024-02-21 10:51:01 +00:00
fix clippy
Some checks failed
Rust Checks / checks (push) Failing after 1m39s
Rust Checks / checks (pull_request) Failing after 1m16s
2f0875d60e
CoCo_Sol added 1 commit 2024-02-21 10:54:51 +00:00
fix clippy
All checks were successful
Rust Checks / checks (push) Successful in 1m12s
Rust Checks / checks (pull_request) Successful in 1m14s
83c36c704d
CoCo_Sol added 2 commits 2024-02-21 16:42:28 +00:00
update
Some checks failed
Rust Checks / checks (push) Failing after 1m40s
Rust Checks / checks (pull_request) Failing after 1m39s
3cf5d76d00
CoCo_Sol added 1 commit 2024-02-21 16:45:29 +00:00
update
Some checks failed
Rust Checks / checks (push) Failing after 5s
Rust Checks / checks (pull_request) Failing after 5s
d64d0bb258
CoCo_Sol added 1 commit 2024-02-21 16:48:06 +00:00
update
Some checks failed
Rust Checks / checks (push) Failing after 5s
Rust Checks / checks (pull_request) Failing after 4s
4633db9609
CoCo_Sol added 1 commit 2024-02-21 16:49:25 +00:00
fix fmt
All checks were successful
Rust Checks / checks (push) Successful in 1m28s
Rust Checks / checks (pull_request) Successful in 1m15s
4b1f7008fd
CoCo_Sol added 1 commit 2024-02-21 16:57:51 +00:00
save
All checks were successful
Rust Checks / checks (push) Successful in 1m15s
Rust Checks / checks (pull_request) Successful in 1m11s
9e9eec3914
CoCo_Sol requested review from tipragot 2024-02-21 16:58:54 +00:00
tipragot requested changes 2024-02-21 17:15:25 +00:00
@ -0,0 +62,4 @@
// If the map is generated, we send [EndMapGeneration] and set the local
// variables to None.
if let Some(position) = spiral.next() {
let pixel_position = position.to_pixel_coordinates() * 0.2;
Contributor

This should be in the get_type function and the value shouldn't be hard coded

This should be in the get_type function and the value shouldn't be hard coded
CoCo_Sol marked this conversation as resolved
@ -0,0 +72,4 @@
}
/// Returns the type of the position with the given noise.
fn get_type(position: Vec2, noise: &Perlin) -> Tile {
Contributor

I still think you should take an HexPosition, this will be simpler and will make this function simpler to use.

I still think you should take an HexPosition, this will be simpler and will make this function simpler to use.
CoCo_Sol marked this conversation as resolved
@ -0,0 +81,4 @@
}
}
/// Despawns the tiles if the event : [StartMapGeneration] is received.
Contributor

What this ":" doing here ?

What this ":" doing here ?
CoCo_Sol marked this conversation as resolved
CoCo_Sol added 1 commit 2024-02-21 17:37:53 +00:00
save
Some checks failed
Rust Checks / checks (push) Has been cancelled
Rust Checks / checks (pull_request) Failing after 1m22s
c11a797d38
CoCo_Sol added 1 commit 2024-02-21 17:38:47 +00:00
add doc
Some checks failed
Rust Checks / checks (push) Has been cancelled
Rust Checks / checks (pull_request) Successful in 1m11s
62eacf2c84
CoCo_Sol added 1 commit 2024-02-21 17:40:26 +00:00
change doc
Some checks failed
Rust Checks / checks (push) Has been cancelled
Rust Checks / checks (pull_request) Successful in 1m14s
f184c93804
CoCo_Sol added 1 commit 2024-02-21 17:41:54 +00:00
update
All checks were successful
Rust Checks / checks (push) Successful in 1m11s
Rust Checks / checks (pull_request) Successful in 1m13s
7f255d081c
CoCo_Sol requested review from tipragot 2024-02-21 17:42:46 +00:00
CoCo_Sol added 1 commit 2024-02-21 17:47:34 +00:00
change doc
All checks were successful
Rust Checks / checks (push) Successful in 1m11s
Rust Checks / checks (pull_request) Successful in 1m15s
65e81d493b
tipragot requested changes 2024-02-21 17:48:57 +00:00
@ -0,0 +40,4 @@
/// Generate each tiles of the map if the [StartMapGeneration] is received.
///
/// The map is generated using the [Perlin] noise function and the [HexSpiral].
Contributor

Perlin isn't a function

Perlin isn't a function
CoCo_Sol marked this conversation as resolved
@ -0,0 +74,4 @@
}
/// Returns the type of the [HexPosition] with the given noise.
fn get_type_tile(position: HexPosition<i32>, noise: &Perlin) -> Tile {
Contributor

get_tile_type

get_tile_type
CoCo_Sol marked this conversation as resolved
CoCo_Sol added 1 commit 2024-02-21 17:49:51 +00:00
change doc
Some checks failed
Rust Checks / checks (push) Failing after 23s
Rust Checks / checks (pull_request) Failing after 22s
0caf97d9b8
CoCo_Sol added 1 commit 2024-02-21 17:51:04 +00:00
save
All checks were successful
Rust Checks / checks (push) Successful in 1m14s
Rust Checks / checks (pull_request) Successful in 1m12s
b77061fed2
CoCo_Sol requested review from tipragot 2024-02-21 17:52:17 +00:00
CoCo_Sol added 1 commit 2024-02-21 17:53:08 +00:00
Delete crates/border-wars/src/map/renderer.rs
All checks were successful
Rust Checks / checks (push) Successful in 1m12s
Rust Checks / checks (pull_request) Successful in 1m11s
c34fc16753
tipragot requested changes 2024-02-21 17:57:51 +00:00
@ -0,0 +75,4 @@
/// Returns the type of the [HexPosition] with the given noise.
fn get_tile_type(position: HexPosition<i32>, noise: &Perlin) -> Tile {
let pixel_position = position.to_pixel_coordinates() / MAP_GENERATION_ZOOM;
Contributor

This is not a Zoom, it is a Scale

This is not a Zoom, it is a Scale
CoCo_Sol marked this conversation as resolved
CoCo_Sol added 1 commit 2024-02-21 17:59:45 +00:00
change name variable
All checks were successful
Rust Checks / checks (push) Successful in 1m12s
Rust Checks / checks (pull_request) Successful in 1m11s
34557956e4
CoCo_Sol requested review from tipragot 2024-02-21 18:00:52 +00:00
CoCo_Sol added 1 commit 2024-02-21 18:03:50 +00:00
Merge branch 'main' into map-generation
All checks were successful
Rust Checks / checks (push) Successful in 1m14s
Rust Checks / checks (pull_request) Successful in 1m13s
e4cabd8a1b
tipragot approved these changes 2024-02-21 18:04:45 +00:00
CoCo_Sol merged commit 92d3484d03 into main 2024-02-21 20:10:03 +00:00
CoCo_Sol referenced this pull request from a commit 2024-02-21 20:10:05 +00:00
CoCo_Sol deleted branch map-generation 2024-02-21 20:10:07 +00:00
Sign in to join this conversation.
No description provided.