{"id":27012694,"url":"https://github.com/Rabbival/bevy_play_card","last_synced_at":"2025-04-04T12:04:12.349Z","repository":{"id":284015565,"uuid":"953191734","full_name":"Rabbival/bevy_play_card","owner":"Rabbival","description":"A card crate for the Bevy game engine","archived":false,"fork":false,"pushed_at":"2025-03-31T17:57:32.000Z","size":179,"stargazers_count":18,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-31T18:44:22.017Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Rabbival.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-03-22T19:24:56.000Z","updated_at":"2025-03-28T05:33:30.000Z","dependencies_parsed_at":"2025-03-24T18:42:44.711Z","dependency_job_id":null,"html_url":"https://github.com/Rabbival/bevy_play_card","commit_stats":null,"previous_names":["rabbival/bevy_card","rabbival/bevy_play_card"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rabbival%2Fbevy_play_card","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rabbival%2Fbevy_play_card/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rabbival%2Fbevy_play_card/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rabbival%2Fbevy_play_card/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Rabbival","download_url":"https://codeload.github.com/Rabbival/bevy_play_card/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247174413,"owners_count":20896078,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-04-04T12:02:06.586Z","updated_at":"2025-04-04T12:04:12.329Z","avatar_url":"https://github.com/Rabbival.png","language":"Rust","funding_links":[],"categories":["Misc"],"sub_categories":[],"readme":"# bevy_play_card\n### A card crate for the [`Bevy`](https://bevyengine.org/) game engine\n\n![bevy_card_showcase - Trim](https://github.com/user-attachments/assets/bf92b236-76ce-4beb-b929-eec4c85ce166)\n\n## How to Use\n### Registering the [Plugin](src/bevy_card_plugin.rs)\nFirst, you should add [`BevyCardPlugin`](src/bevy_card_plugin.rs), it has a `::default()` implementation but can be reconfigured, for example:\n  ```rust\n  app.add_plugins(\n    BevyCardPlugin {\n      card_hover_height: 40.0,\n      ..default()\n    },\n  );\n  ```\n\n### Spawning [Cards](src/cards/card.rs)\nThe basic functionality derived from Bevy Picking is added to Cards automatically. \nIt's recommended to instantiate a card using [card bundle](src/cards/card_bundle.rs)s:\n  ```rust\n  commands.spawn((\n    CardBundle::new(Transform::default()),\n    Sprite {\n        image: asset_server.load(\"your card sprite path here\"),\n        ..default ()\n    },\n  ));\n  ```\nCards are named automatically by the [card_namer](src/cards/card_namer.rs).\n\n### Spawning [Card Lines](src/cards/card_lines/card_line.rs)\nCards can live on a card line, that'll allow you to reorder them and keep them neatly organized. \nAll you need to instantiate a card line is:\n  ```rust\n  commands\n    .spawn(CardLineBundle::from_transform(Transform::default()));\n```\nOr more specifically using [`from_card_line`](src/cards/card_lines/card_line_bundle.rs):\n  ```rust\n  commands\n    .spawn(CardLineBundle::from_card_line(\n        CardLine::default()\n          .with_origin(\n            Transform::from_translation(location.into())\n                .with_rotation(Quat::from_rotation_z(rotation)),\n          )\n          .with_max_cards(MAX_CARDS)\n          .with_card_origin_gap(60.0),\n    ));\n  ```\n\n### Using [Card Line Requests](src/cards/card_lines/event.rs)\nAlthough you could interact with the entities directly, you can spare yourself some boilerplate\nby firing events using `EventWriter\u003cCardLineRequest\u003e`, already listened to by the plugin.\nEach [`CardLineRequest`](src/cards/card_lines/event.rs) contains the entity of the line to which it'll be applied and a request type with relevant additional data if there's any.\nThe variants of `CardLineRequestType` are as follows:\n\n| Variant              | Role                                                  |\n|----------------------|-------------------------------------------------------|\n| `RaiseCardLine`      | Raises the card line to it's relative up              |\n| `LowerCardLine`      | Lowers the card line back to place after being raised |\n| `AddToCardLine`      | Inserts the card to the line if possible              |\n| `RemoveCardFromLine` | Removes the card from the line if it was there        |\n\n### Hovered And Dragged [Tags](src/cards/tags.rs)\nCards are being tagged for easier queries when they're hovered and dragged (the tags are removed when the action is done).\nThis way you can, for example, get all hovered card with queries like:\n`\n  Query\u003c\u0026Card, With\u003cHovered\u003e\u003e\n`\nFor use examples, see [using_hovered_and_dragged_cards.rs](examples/using_hovered_and_dragged_cards.rs)\n\n### Workflow Example\nLet's spawn a line and add a few cards to it, \nsee [cards_on_a_line.rs](examples/cards_on_a_line.rs) for another example of that scenario.\n\nFirst, let's spawn a defaultly-configured line in the middle of the screen.\n  ```rust\n  let line_entity = commands\n    .spawn(CardLineBundle::from_transform(Transfrom::default())).id();\n  ```\n\nNow, let's spawn three cards, sending a request to add each to a line. \nSending the requests separately ensures the line stays within capacity, leaving out the last cards to be spawned if any.\nThe shape of the loop is as follows:\n  ```rust\n  for _ in 0..3 {\n    let card_entity = commands.spawn(( ... )).id();\n    card_line_request_writer.send(CardLineRequest { ... });\n  }\n  ```\n\nAn example for card spawning would be:\n  ```rust\n  let card_entity = commands\n    .spawn((\n        Sprite {\n          image: asset_server.load(\"path to your card sprite here\"),\n          ..default()\n        },\n        CardBundle::new(Transform::default()),\n      )).id();\n```\nWith the appropriate addition request:\n```rust\n  card_line_request_writer.send(CardLineRequest {\n    line: line_entity,\n    request_type: CardLineRequestType::AddToCardLine { card_entity },\n  });\n  ```\n\nEnding up with:\n  ```rust\n  let line_entity = commands\n    .spawn(CardLineBundle::from_transform(Transfrom::default())).id();\n  for _ in 0..3 {\n    let card_entity = commands\n        .spawn((\n          Sprite {\n            image: asset_server.load(\"path to your card sprite here\"),\n            ..default()\n          },\n          CardBundle::new(Transform::default()),\n        )).id();\n    card_line_request_writer.send(CardLineRequest {\n      line: line_entity,\n      request_type: CardLineRequestType::AddToCardLine { card_entity },\n    });\n  }\n  ```\n\n## Bevy Version Support\n| `bevy` | `bevy_tween` |\n|--------|--------------|\n| 0.15   | 0.1          |\n\n## Credits\n- [`bevy_tween`](https://github.com/Multirious/bevy_tween)\n  The crate this one is built upon. Thanks to it I was able to set bevy_card up rather quickly and easily.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FRabbival%2Fbevy_play_card","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FRabbival%2Fbevy_play_card","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FRabbival%2Fbevy_play_card/lists"}