Skip to content

Commit

Permalink
First commit
Browse files Browse the repository at this point in the history
  • Loading branch information
tguichaoua committed Aug 11, 2023
0 parents commit 79ad89a
Show file tree
Hide file tree
Showing 11 changed files with 1,029 additions and 0 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: CI

on:
push:
pull_request:
workflow_dispatch:

permissions:
contents: read

env:
RUSTFLAGS: -Dwarnings

jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
- name: No features
run: cargo check --no-default-features
- name: All features
run: cargo check --features 2d,3d
- name: Examples
run: cargo check --examples

test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
- run: cargo test --all-features

fmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
- run: cargo fmt --all -- --check

clippy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
- run: cargo clippy --all-features -- -D warnings

doc:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
- run: cargo doc --all-features --no-deps --document-private-items
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/target
/Cargo.lock
.vscode
55 changes: 55 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
[package]
name = "bevy_cursor"
version = "0.1.0"
edition = "2021"
authors = ["Tristan Guichaoua <[email protected]>"]
description = "A bevy plugin to track informations about the cursor"
repository = "github.com/tguichaoua/bevy_cursor"
license = "MIT OR Apache-2.0"
keywords = ["bevy", "cursor", "window", "camera"]
categories = ["game-engines"]


# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[features]
default = ["2d"]
2d = []
3d = []


[dependencies]
bevy = { version = "0.11.0", default-features = false, features = [
"bevy_render",
] }
smallvec = { version = "1.11.0", features = ["union"] }

[dev-dependencies]
bevy = { version = "0.11.0", default-features = false, features = [
"bevy_ui",
"bevy_winit",
"default_font",
"png",
] }
# bevy_ecs_tilemap = "0.11.0"
bevy_ecs_tilemap = { git = "https://github.com/StarArawn/bevy_ecs_tilemap.git", rev = "fbda80c735bf7faaa2cc4d79524cfbf016044a0f" }
bevy_pancam = "0.9.0"

[package.metadata.docs.rs]
# To build locally:
# RUSTDOCFLAGS="--cfg docsrs" cargo +nightly doc --all-features --no-deps --open
all-features = true
# enable unstable features in the documentation
rustdoc-args = ["--cfg", "docsrs"]

[[example]]
name = "basic"
required-features = ["2d"]

[[example]]
name = "multiple_windows"
required-features = ["2d"]

[[example]]
name = "tilemap"
required-features = ["2d"]
49 changes: 49 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Bevy Cursor

[![Latest Version]][crates.io] [![Bevy Tracking]][bevy tracking doc] [![Doc Status]][docs] [![Build Status]][actions]

[Latest Version]: https://img.shields.io/crates/v/bevy_cursor.svg
[crates.io]: https://crates.io/crates/bevy_cursor
[Bevy Tracking]: https://img.shields.io/badge/Bevy%20tracking-released%20version-lightblue?labelColor=555555&logo=bevy
[bevy tracking doc]: https://github.com/bevyengine/bevy/blob/main/docs/plugins_guidelines.md#main-branch-tracking
[Doc Status]: https://docs.rs/bevy_cursor/badge.svg
[docs]: https://docs.rs/bevy_cursor
[Build Status]: https://github.com/tguichaoua/bevy-cursor/actions/workflows/ci.yml/badge.svg?branch=main
[actions]: https://github.com/tguichaoua/bevy-cursor/actions/workflows/ci.yml

**Bevy Cursor is a [`bevy`](https://github.com/bevyengine/bevy) plugin to track informations about the cursor.**

---

## Example

```rust
use bevy::prelude::*;
use bevy_cursor::prelude::*;


fn main() {
App::new()
//
.add_plugins(DefaultPlugins)
.add_plugins(CursorInfoPlugin) // Add the plugin
//
.add_systems(Update, print_cursor_info)
.run();
}

fn print_cursor_info(cursor: Res<CursorInfo>) {
if let Some(position) = cursor.position() {
info!("Cursor position: {position:?}");
} else {
info!("The cursor is not in any window");
}
}

```

## Bevy compatible version

| bevy | bevy_cursor |
| ---- | ----------- |
| 0.11 | 0.1 |
Binary file added assets/isometric-sheet.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions examples/basic.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
use bevy::prelude::*;
use bevy_cursor::prelude::*;

fn main() {
App::new()
.add_plugins((DefaultPlugins, CursorInfoPlugin))
.add_systems(Update, print_cursor_position)
.run();
}

fn print_cursor_position(cursor: Res<CursorInfo>) {
if let Some(position) = cursor.position() {
info!("Cursor position: {position:?}");
} else {
info!("The cursor is not in any window");
}
}
Loading

0 comments on commit 79ad89a

Please sign in to comment.