basic assets for tank and background grid

This commit is contained in:
joe 2026-01-11 17:16:33 -08:00
parent bc452ce03d
commit b5e0c7e6a7
6 changed files with 871 additions and 24 deletions

9
.cargo/config.toml Normal file
View file

@ -0,0 +1,9 @@
# for Linux
[target.x86_64-unknown-linux-gnu]
linker = "clang"
rustflags = ["-C", "link-arg=-fuse-ld=lld"]
# for Windows
[target.x86_64-pc-windows-msvc]
linker = "rust-lld.exe"

824
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -5,3 +5,12 @@ edition = "2024"
[dependencies] [dependencies]
bevy = { default-features = false, git = "https://github.com/bevyengine/bevy.git", branch = "release-0.18.0", features = ["2d"] } bevy = { default-features = false, git = "https://github.com/bevyengine/bevy.git", branch = "release-0.18.0", features = ["2d"] }
steel-core = { git="https://github.com/mattwparas/steel.git", branch = "master" }
# Enable a small amount of optimization in the dev profile.
[profile.dev]
opt-level = 1
# Enable a large amount of optimization in the dev profile for dependencies.
[profile.dev.package."*"]
opt-level = 3

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

View file

@ -1,3 +1,54 @@
//! Renders a 2D scene containing a single, moving sprite.
use bevy::prelude::*;
fn main() { fn main() {
println!("Hello, world!"); App::new()
.add_plugins(DefaultPlugins)
.add_systems(Startup, setup)
.add_systems(Update, sprite_movement)
.run();
}
#[derive(Component)]
enum Direction {
Left,
Right,
}
fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
commands.spawn(Camera2d);
commands.spawn((
Sprite::from_image(asset_server.load("sprites/units/basic_tank.png")),
Transform::from_xyz(0., 0., 1.0).with_scale(Vec3::ONE),
Direction::Right,
));
commands.spawn(Sprite {
image: asset_server.load("sprites/terrain/grid_paper_empty.png"),
image_mode: SpriteImageMode::Tiled {
tile_x: true,
tile_y: true,
stretch_value: 1.0, // The image will tile every 128px
},
custom_size: Some(Vec2::splat(2048.0)),
..default()
});
}
/// The sprite is animated by changing its translation depending on the time that has passed since
/// the last frame.
fn sprite_movement(time: Res<Time>, mut sprite_position: Query<(&mut Direction, &mut Transform)>) {
for (mut logo, mut transform) in &mut sprite_position {
match *logo {
Direction::Right => transform.translation.x += 150. * time.delta_secs(),
Direction::Left => transform.translation.x -= 150. * time.delta_secs(),
}
if transform.translation.x > 200. {
*logo = Direction::Left;
} else if transform.translation.x < -200. {
*logo = Direction::Right;
}
}
} }