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