Created
June 23, 2025 17:52
-
-
Save piedoom/3bf1af9389e0b21e6a62b3ff70914be4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use bevy_play_card::prelude::*; | |
fn main() { | |
App::new() | |
.add_plugins((DefaultPlugins, BevyCardPlugin::default())) | |
.add_systems(Startup, (setup, spawn_cards_on_a_line).chain()) | |
.run(); | |
} | |
fn spawn_cards_on_a_line( | |
mut card_line_request_writer: EventWriter<CardLineRequest>, | |
asset_server: Res<AssetServer>, | |
mut commands: Commands, | |
) { | |
let cards_count = 12; | |
let line = commands | |
.spawn(CardLineBundle::from_card_line( | |
CardLine::default() | |
.with_max_cards(cards_count) | |
.with_card_origin_gap(100.0) | |
.with_picked_cards_capacity(3) | |
.with_origin(Transform::from_scale(Vec3::splat(0.4))), | |
)) | |
.id(); | |
let mut card_entities = vec![]; | |
for _ in 0..cards_count { | |
card_entities.push( | |
commands | |
.spawn(( | |
Sprite { | |
image: asset_server.load("PlaceholderCard.png"), | |
..default() | |
}, | |
CardBundle::new(Transform::default()), | |
)) | |
.id(), | |
); | |
} | |
card_line_request_writer.write(CardLineRequest { | |
line, | |
request_type: CardLineRequestType::BatchAddToLine { card_entities }, | |
}); | |
} | |
fn setup(mut commands: Commands) { | |
commands.spawn(( | |
Camera2d, | |
)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment