Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2D top-down camera example #12720

Merged

Conversation

theredfish
Copy link
Contributor

@theredfish theredfish commented Mar 26, 2024

Objective

This PR addresses the 2D part of #12658. I plan to separate the examples and make one PR per camera example.

Solution

Added a new top-down example composed of:

  • Player keyboard movements
  • UI for keyboard instructions
  • Colors and bloom effect to see the movement of the player
  • Camera smooth movement towards the player (lerp)

Testing

cargo run --features="wayland,bevy/dynamic_linking" --example 2d_top_down_camera
example-2d-top-down.mp4

Copy link
Contributor

Welcome, new contributor!

Please make sure you've read our contributing guide and we look forward to reviewing your pull request shortly ✨

@theredfish theredfish changed the title Player movement and camera smooth-damp effect 2D top-down camera example Mar 26, 2024
Copy link
Contributor

The generated examples/README.md is out of sync with the example metadata in Cargo.toml or the example readme template. Please run cargo run -p build-templated-pages -- update examples to update it, and commit the file change.

@ItsDoot ItsDoot added A-Rendering Drawing game state to the screen C-Examples An addition or correction to our examples labels Mar 26, 2024
@theredfish theredfish force-pushed the examples/bevy-2d-top-down-camera branch from 3218652 to fc4f85b Compare May 14, 2024 21:45
Copy link
Contributor

The generated examples/README.md is out of sync with the example metadata in Cargo.toml or the example readme template. Please run cargo run -p build-templated-pages -- update examples to update it, and commit the file change.

@theredfish theredfish force-pushed the examples/bevy-2d-top-down-camera branch from fc4f85b to 79e246f Compare May 16, 2024 17:38
Copy link
Contributor

The generated examples/README.md is out of sync with the example metadata in Cargo.toml or the example readme template. Please run cargo run -p build-templated-pages -- update examples to update it, and commit the file change.

@theredfish theredfish force-pushed the examples/bevy-2d-top-down-camera branch from 79e246f to c3ebe18 Compare May 16, 2024 22:32
@theredfish theredfish marked this pull request as ready for review May 16, 2024 22:36
@theredfish
Copy link
Contributor Author

theredfish commented May 17, 2024

@alice-i-cecile I decided to go with different PRs for the different examples. But if you prefer multiple ones in the same PR let me know.

I kept a simple scope for this one - should be straightforward. I wanted to add more like bounded camera but I don't think it would serve the purpose of the example. If you think it's valuable here I can add it.

@alice-i-cecile
Copy link
Member

Multiple small examples is perfect, thank you!

@alice-i-cecile alice-i-cecile added the S-Needs-Review Needs reviewer attention (from anyone!) to move forward label May 17, 2024
@theredfish theredfish force-pushed the examples/bevy-2d-top-down-camera branch from c3ebe18 to de08756 Compare May 20, 2024 18:10
Copy link
Contributor

@mgi388 mgi388 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To help other reviewers, you might also consider including a video of the example in the PR description. Check the latest PR template, it has a "Testing" section.

examples/camera/2d_top_down_camera.rs Outdated Show resolved Hide resolved
examples/camera/2d_top_down_camera.rs Outdated Show resolved Hide resolved
examples/camera/2d_top_down_camera.rs Outdated Show resolved Hide resolved
examples/camera/2d_top_down_camera.rs Outdated Show resolved Hide resolved
examples/camera/2d_top_down_camera.rs Outdated Show resolved Hide resolved
examples/camera/2d_top_down_camera.rs Outdated Show resolved Hide resolved
examples/camera/2d_top_down_camera.rs Outdated Show resolved Hide resolved
examples/camera/2d_top_down_camera.rs Outdated Show resolved Hide resolved
@theredfish
Copy link
Contributor Author

theredfish commented Jun 7, 2024

To help other reviewers, you might also consider including a video of the example in the PR description. Check the latest PR template, it has a "Testing" section.

Thanks for the review!

Regarding the video, I don't think it's easy for contributors to maintain the video through changes and it can be outdated at some point. Also it adds extra steps, you need tools to capture gif etc... maybe not ideal for everyone. Also I tried to add a gif but the file needs to be less than 10MB. My file is more than the max, I decided to not attach the gif. I added the cargo run command.

I'll send code changes soon.

@theredfish theredfish force-pushed the examples/bevy-2d-top-down-camera branch from de08756 to aa080d7 Compare June 7, 2024 22:13
@theredfish theredfish force-pushed the examples/bevy-2d-top-down-camera branch from 7c77fc5 to f07b159 Compare June 9, 2024 12:16
@theredfish
Copy link
Contributor Author

theredfish commented Jun 9, 2024

Ok finally found a way to make lighter mp4 records - I attached the record to the PR. If it can provide a good example for other contributions. I think I've addressed all the comments from last review. Should I squash my commits into one? I also rebased on main

@alice-i-cecile
Copy link
Member

Don't worry about squashing, and thanks for the video! I'm happy with this, barring the complaints about the debug statements. Once those are removed you'll have my approval (and then we just need to find a second reviewer).

@rparrett rparrett self-requested a review June 9, 2024 15:06
examples/camera/2d_top_down_camera.rs Outdated Show resolved Hide resolved
examples/camera/2d_top_down_camera.rs Outdated Show resolved Hide resolved
examples/camera/2d_top_down_camera.rs Outdated Show resolved Hide resolved
examples/camera/2d_top_down_camera.rs Outdated Show resolved Hide resolved
examples/camera/2d_top_down_camera.rs Outdated Show resolved Hide resolved
examples/camera/2d_top_down_camera.rs Outdated Show resolved Hide resolved
Copy link

@jonathaningram jonathaningram left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ran it locally, looks good to me. Only nitpick I'd make is that you can move outside of the pretend "bounds" of the example, but I don't think it's a big deal to worry about for this example.

@alice-i-cecile alice-i-cecile added S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it and removed S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Jun 10, 2024
@alice-i-cecile alice-i-cecile added this to the 0.14 milestone Jun 10, 2024
@alice-i-cecile alice-i-cecile added this pull request to the merge queue Jun 10, 2024
Merged via the queue into bevyengine:main with commit 33dff0d Jun 10, 2024
33 checks passed
@theredfish
Copy link
Contributor Author

Thanks everyone for the reviews! I Learned a lot through this small example ✌️.

mockersf pushed a commit that referenced this pull request Jun 10, 2024
# Objective

This PR addresses the 2D part of #12658. I plan to separate the examples
and make one PR per camera example.

## Solution

Added a new top-down example composed of:

- [x] Player keyboard movements
- [x] UI for keyboard instructions
- [x] Colors and bloom effect to see the movement of the player
- [x] Camera smooth movement towards the player (lerp)

## Testing

```bash
cargo run --features="wayland,bevy/dynamic_linking" --example 2d_top_down_camera
```



https://github.com/bevyengine/bevy/assets/10638479/95db0587-e5e0-4f55-be11-97444b795793
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Rendering Drawing game state to the screen C-Examples An addition or correction to our examples S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants