generated from tipragot/rust
Add a rendering system using temporary images #61
BIN
crates/border-wars/assets/tiles/forest.png
Normal file
BIN
crates/border-wars/assets/tiles/forest.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 715 KiB |
Binary file not shown.
After Width: | Height: | Size: 832 KiB |
|
@ -9,7 +9,7 @@ use border_wars::scenes::ScenesPlugin;
|
||||||
fn setup(mut writer: EventWriter<StartMapGeneration>) {
|
fn setup(mut writer: EventWriter<StartMapGeneration>) {
|
||||||
writer.send(StartMapGeneration {
|
writer.send(StartMapGeneration {
|
||||||
seed: 7128,
|
seed: 7128,
|
||||||
radius: 50,
|
radius: 500,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@ impl Tile {
|
||||||
fn get_texture(&self, asset_server: &AssetServer) -> Handle<Image> {
|
fn get_texture(&self, asset_server: &AssetServer) -> Handle<Image> {
|
||||||
match self {
|
match self {
|
||||||
Self::Grass => asset_server.load("tiles/grass.png"),
|
Self::Grass => asset_server.load("tiles/grass.png"),
|
||||||
Self::Forest => asset_server.load("tiles/grass.png"),
|
Self::Forest => asset_server.load("tiles/forest.png"),
|
||||||
Self::Hill => asset_server.load("tiles/hill.png"),
|
Self::Hill => asset_server.load("tiles/hill.png"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,7 @@ impl Tile {
|
||||||
x: 1250.0,
|
x: 1250.0,
|
||||||
y: 1000.0,
|
y: 1000.0,
|
||||||
},
|
},
|
||||||
Self::Hill => Vec2 { x: 337.0, y: 740.0 },
|
Self::Hill => Vec2 { x: 1250.0, y: 1300.0 },
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -77,7 +77,9 @@ fn render_map(
|
||||||
);
|
);
|
||||||
|
|
||||||
let scale_2d = tiles_size.0 / tile.get_image_size();
|
let scale_2d = tiles_size.0 / tile.get_image_size();
|
||||||
let scale = Vec3::new(scale_2d.x, scale_2d.y, 1.0);
|
|
||||||
|
// the y scale is the same as the x scale to keep the aspect ratio.
|
||||||
|
let scale = Vec3::new(scale_2d.x, scale_2d.x, 1.0);
|
||||||
|
|
||||||
commands.entity(entity).insert(SpriteBundle {
|
commands.entity(entity).insert(SpriteBundle {
|
||||||
sprite: Sprite {
|
sprite: Sprite {
|
||||||
|
@ -98,5 +100,5 @@ fn render_map(
|
||||||
/// A simple sigmoid function to convert y position to z position.
|
/// A simple sigmoid function to convert y position to z position.
|
||||||
/// The return value is between 0 and 1.
|
/// The return value is between 0 and 1.
|
||||||
fn z_position_from_y(y: f32) -> f32 {
|
fn z_position_from_y(y: f32) -> f32 {
|
||||||
-1.0 / (1.0 + (-y * 110_f64.powi(-5) as f32).exp())
|
-1.0 / (1.0 + (-y * 110_f64.powi(-3) as f32).exp())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue