Created
June 23, 2025 17:45
-
-
Save piedoom/e4f31bb9be93f1d50f9319867cef9eae 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, | |
Projection::Orthographic(OrthographicProjection { | |
scaling_mode: bevy::render::camera::ScalingMode::FixedVertical { | |
viewport_height: 2000., | |
}, | |
..OrthographicProjection::default_2d() | |
}), | |
)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment