Fix pixel art
This commit is contained in:
parent
7a064fd55a
commit
d851eb7676
|
@ -27,11 +27,11 @@ fn load_assets(
|
|||
let player_img = asset_server.load("img/Player.png");
|
||||
let player_atlas = TextureAtlas::from_grid(
|
||||
player_img,
|
||||
Vec2::new(21.0, 48.0),
|
||||
7,
|
||||
Vec2::new(32.0, 64.0),
|
||||
3,
|
||||
1,
|
||||
Some(Vec2 { x: 33., y: 0. }),
|
||||
Some(Vec2 { x: 6., y: 10. }),
|
||||
Some(Vec2 { x: 0., y: 0. }),
|
||||
Some(Vec2 { x: 0., y: 0. }),
|
||||
);
|
||||
let player_atlas_handle = texture_atlases.add(player_atlas);
|
||||
*assets = AssetLoader {
|
||||
|
|
12
src/main.rs
12
src/main.rs
|
@ -7,14 +7,18 @@ mod player;
|
|||
|
||||
fn main() {
|
||||
let mut app = App::new();
|
||||
app.add_plugins(DefaultPlugins.set(WindowPlugin {
|
||||
app.add_plugins(
|
||||
DefaultPlugins
|
||||
.set(WindowPlugin {
|
||||
primary_window: Some(Window {
|
||||
title: "Kodo Tag".into(),
|
||||
resolution: (800., 600.).into(),
|
||||
..Default::default()
|
||||
}),
|
||||
..Default::default()
|
||||
}))
|
||||
})
|
||||
.set(ImagePlugin::default_nearest()),
|
||||
)
|
||||
.add_plugins((
|
||||
camera::Camera,
|
||||
assets::AssetPlugin,
|
||||
|
@ -32,10 +36,14 @@ fn main() {
|
|||
}
|
||||
|
||||
fn keyboard_input_system(
|
||||
mut query: Query<&mut TextureAtlasSprite, With<player::Player>>,
|
||||
keyboard_input: Res<Input<KeyCode>>,
|
||||
mut app_exit_events: ResMut<Events<bevy::app::AppExit>>,
|
||||
) {
|
||||
if keyboard_input.pressed(KeyCode::Escape) {
|
||||
app_exit_events.send(bevy::app::AppExit);
|
||||
} else if keyboard_input.pressed(KeyCode::N) {
|
||||
let mut sprite = query.single_mut();
|
||||
sprite.index += 1;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ fn spawn_player(mut commands: Commands, assets: Res<AssetLoader>) {
|
|||
Player,
|
||||
SpriteSheetBundle {
|
||||
texture_atlas: assets.sprites.player.clone(),
|
||||
sprite: TextureAtlasSprite::new(1),
|
||||
sprite: TextureAtlasSprite::new(0),
|
||||
transform: Transform::from_scale(Vec3::splat(3.0)),
|
||||
..Default::default()
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue