init tiles, table/camera/environment placeholder
This commit is contained in:
parent
78cc4be844
commit
b47ecbf45a
6 changed files with 172 additions and 1 deletions
31
src/gui/mod.rs
Normal file
31
src/gui/mod.rs
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
use bevy::{color::palettes::css::GREEN, prelude::*};
|
||||
|
||||
pub(crate) mod tiles;
|
||||
|
||||
pub(crate) fn init_environment(mut commands: Commands) {
|
||||
commands.spawn((
|
||||
DirectionalLight {
|
||||
shadows_enabled: true,
|
||||
..default()
|
||||
},
|
||||
// Transform::from_xyz(),
|
||||
));
|
||||
commands.spawn((
|
||||
Camera3d::default(),
|
||||
Transform::from_xyz(-200.5, 100., 0.).looking_at(Vec3::ZERO, Vec3::Y),
|
||||
));
|
||||
}
|
||||
|
||||
pub(crate) fn init_table(
|
||||
mut commands: Commands,
|
||||
mut meshes: ResMut<Assets<Mesh>>,
|
||||
mut materials: ResMut<Assets<StandardMaterial>>,
|
||||
) {
|
||||
let green: Color = GREEN.into();
|
||||
let table = Cuboid::new(1000., 5., 1000.);
|
||||
|
||||
commands.spawn((
|
||||
Mesh3d(meshes.add(table)),
|
||||
MeshMaterial3d(materials.add(green)),
|
||||
));
|
||||
}
|
||||
99
src/gui/tiles.rs
Normal file
99
src/gui/tiles.rs
Normal file
|
|
@ -0,0 +1,99 @@
|
|||
use bevy::{color::palettes::css::GREY, prelude::*};
|
||||
use strum::FromRepr;
|
||||
|
||||
#[derive(Component)]
|
||||
pub(crate) enum Tile {
|
||||
Pin(Number),
|
||||
Sou(Number),
|
||||
Man(Number),
|
||||
Wind(Wind),
|
||||
Dragon(Dragon),
|
||||
}
|
||||
|
||||
#[derive(FromRepr)]
|
||||
pub(crate) enum Number {
|
||||
One = 1,
|
||||
Two,
|
||||
Three,
|
||||
Four,
|
||||
Five,
|
||||
Six,
|
||||
Seven,
|
||||
Eight,
|
||||
Nine,
|
||||
}
|
||||
|
||||
#[derive(FromRepr)]
|
||||
pub(crate) enum Wind {
|
||||
Ton,
|
||||
Nan,
|
||||
Shaa,
|
||||
Pei,
|
||||
}
|
||||
|
||||
#[derive(FromRepr)]
|
||||
pub(crate) enum Dragon {
|
||||
Haku,
|
||||
Hatsu,
|
||||
Chun,
|
||||
}
|
||||
|
||||
#[derive(Component)]
|
||||
struct Dora;
|
||||
|
||||
pub fn init_tileset(
|
||||
mut commands: Commands,
|
||||
mut meshes: ResMut<Assets<Mesh>>,
|
||||
mut materials: ResMut<Assets<StandardMaterial>>,
|
||||
) {
|
||||
let cuboid = Cuboid::new(25., 20., 16.);
|
||||
|
||||
for _ in 0..4 {
|
||||
for i in 1..=9 {
|
||||
commands.spawn((
|
||||
(
|
||||
Mesh3d(meshes.add(cuboid)),
|
||||
Transform::from_xyz(30., 0., 0.),
|
||||
MeshMaterial3d(materials.add(std::convert::Into::<Color>::into(GREY))),
|
||||
),
|
||||
Tile::Pin(Number::from_repr(i).unwrap()),
|
||||
));
|
||||
commands.spawn((
|
||||
(
|
||||
Mesh3d(meshes.add(cuboid)),
|
||||
Transform::from_xyz(30., 0., 0.),
|
||||
MeshMaterial3d(materials.add(std::convert::Into::<Color>::into(GREY))),
|
||||
),
|
||||
Tile::Sou(Number::from_repr(i).unwrap()),
|
||||
));
|
||||
commands.spawn((
|
||||
(
|
||||
Mesh3d(meshes.add(cuboid)),
|
||||
Transform::from_xyz(30., 0., 0.),
|
||||
MeshMaterial3d(materials.add(std::convert::Into::<Color>::into(GREY))),
|
||||
),
|
||||
Tile::Man(Number::from_repr(i).unwrap()),
|
||||
));
|
||||
}
|
||||
for i in 0..4 {
|
||||
commands.spawn((
|
||||
(
|
||||
Mesh3d(meshes.add(cuboid)),
|
||||
Transform::from_xyz(30., 0., 0.),
|
||||
MeshMaterial3d(materials.add(std::convert::Into::<Color>::into(GREY))),
|
||||
),
|
||||
Tile::Wind(Wind::from_repr(i).unwrap()),
|
||||
));
|
||||
}
|
||||
for i in 0..3 {
|
||||
commands.spawn((
|
||||
(
|
||||
Mesh3d(meshes.add(cuboid)),
|
||||
Transform::from_xyz(30., 0., 0.),
|
||||
MeshMaterial3d(materials.add(std::convert::Into::<Color>::into(GREY))),
|
||||
),
|
||||
Tile::Dragon(Dragon::from_repr(i).unwrap()),
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
14
src/main.rs
14
src/main.rs
|
|
@ -1,3 +1,15 @@
|
|||
use bevy::prelude::*;
|
||||
|
||||
use crate::gui::{tiles::*, *};
|
||||
|
||||
mod gui;
|
||||
mod tui;
|
||||
|
||||
fn main() {
|
||||
println!("Hello, world!");
|
||||
App::new()
|
||||
// .add_plugins(DefaultPlugins)
|
||||
.add_systems(Startup, init_table)
|
||||
.add_systems(Startup, init_tileset)
|
||||
.add_systems(Startup, init_environment)
|
||||
.run();
|
||||
}
|
||||
|
|
|
|||
0
src/tui.rs
Normal file
0
src/tui.rs
Normal file
Loading…
Add table
Add a link
Reference in a new issue