@@ 8,6 8,7 @@
use bevy::prelude::*;
use bevy_rapier3d::prelude::*;
+use bevy_text_mesh::prelude::*;
use crate::game_status::Card;
@@ 90,6 91,9 @@ impl Default for VisualCardBundle {
#[derive(Resource)]
pub struct VisualCardData {
+ font_normal: Handle<TextMeshFont>,
+ font_medium: Handle<TextMeshFont>,
+ font_bold: Handle<TextMeshFont>,
mesh: Handle<Mesh>,
card_background: Handle<StandardMaterial>,
}
@@ 109,6 113,9 @@ impl FromWorld for VisualCardData {
};
Self {
+ font_normal: asset_server.load("fonts/FiraMono-Regular.ttf#mesh"),
+ font_medium: asset_server.load("fonts/FiraMono-Medium.ttf#mesh"),
+ font_bold: asset_server.load("fonts/FiraMono-Bold.ttf#mesh"),
mesh: meshes.add(
shape::Quad {
size: Vec2::new(VisualCard::ASPECT_RATIO / 2., VisualCard::ASPECT_RATIO),
@@ 137,6 144,38 @@ fn on_spawn_card(
},
..Default::default()
});
+
+ // card name
+ parent.spawn(TextMeshBundle {
+ text_mesh: TextMesh {
+ text: card.card.name.clone(),
+ style: TextMeshStyle {
+ font: card_data.font_medium.clone(),
+ font_size: SizeUnit::NonStandard(5.),
+ color: Color::rgb(0.2, 0.2, 0.2),
+ ..Default::default()
+ },
+ ..Default::default()
+ },
+ transform: Transform::from_xyz(-0.3, 0.2, 0.),
+ ..Default::default()
+ });
+
+ // card cost
+ parent.spawn(TextMeshBundle {
+ text_mesh: TextMesh {
+ text: card.card.cost.to_string(),
+ style: TextMeshStyle {
+ font: card_data.font_bold.clone(),
+ font_size: SizeUnit::NonStandard(7.),
+ color: Color::rgb(1., 1., 1.),
+ ..Default::default()
+ },
+ ..Default::default()
+ },
+ transform: Transform::from_xyz(0.2, -0.575, 0.),
+ ..Default::default()
+ });
});
}
}