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

Added move_sprite example #2391

Closed
wants to merge 26 commits into from
Closed

Conversation

jak6jak
Copy link
Contributor

@jak6jak jak6jak commented Jun 24, 2021

Objective

There is no bevy example that shows how to transform a sprite. At least as its singular purpose. This creates an example of how to use transform.translate to move a sprite up and down.

Solution

I created move_sprite example.

@github-actions github-actions bot added the S-Needs-Triage This issue needs to be labelled label Jun 24, 2021
}

struct BevyLogo {
rising: bool,
Copy link
Member

Choose a reason for hiding this comment

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

We should use an enum for this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm a bit new to rust and bevy ECS. can you explain why?

Copy link
Contributor

Choose a reason for hiding this comment

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

Rust enums provide an extra level of type safety and you can also name the variants to be more descriptive.

effectively

enum Movement {
    Rising, 
    Falling
}

and

bool

are equivalent.

However the Movement enum is more descriptive as to what the two states actually represent.

Copy link
Member

Choose a reason for hiding this comment

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

Especially if you call it something amusing like
Logomotion

Cargo.toml Outdated Show resolved Hide resolved
@alice-i-cecile alice-i-cecile added C-Examples An addition or correction to our examples A-Rendering Drawing game state to the screen and removed S-Needs-Triage This issue needs to be labelled labels Jun 25, 2021
Copy link
Member

@alice-i-cecile alice-i-cecile left a comment

Choose a reason for hiding this comment

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

Simple, does what it says on the tin. Probably useful enough to beginners to be worth including.

Comment on lines 24 to 28
.spawn_bundle(SpriteBundle {
material: materials.add(texture_handle.into()),
..Default::default()
})
Copy link
Member

Choose a reason for hiding this comment

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

could you add a transform component to show how to place a sprite from the start?

App::build()
.add_plugins(DefaultPlugins)
.add_startup_system(setup.system())
.add_system(sprite_movement.system())
Copy link
Contributor

Choose a reason for hiding this comment

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

on main the .system() syntax is no longer needed.
So we should probably also remove it here :)

Copy link
Member

Choose a reason for hiding this comment

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

it can be done later, we will need a big pass on all examples anyway

@jak6jak
Copy link
Contributor Author

jak6jak commented Jun 29, 2021

okay I messed up trying to update my branch so that optional system was implemented. Can someone help?

@NathanSWard
Copy link
Contributor

NathanSWard commented Jun 29, 2021

okay I messed up trying to update my branch so that optional system was implemented. Can someone help?

If you can find the previous commit (before updating to main, reset to that branch)

git reset --hard <commit-hash>

Then when you update to main you want to rebase onto it.
For example I would do something like:

git fetch upstream
git rebase upstream/main

My remote repo for bevy (not my personal fork) is aliased as upstream.
So then I rebase on top of that main which will essentially pull all of your new commits off, apply main's commits, and then reapply yours.
See here to learn more about rebasing.

It looks like the old commit hash you want is 33a87b4eba2569deb2e159d296f79c2341eff364

@jak6jak
Copy link
Contributor Author

jak6jak commented Jun 29, 2021

I just decided to redo the pull request since I seemed to mess it up more :( #2414

@jak6jak jak6jak closed this Jun 29, 2021
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants