Add a camera, render a rect, and set the clear colour

This commit is contained in:
Jarrod Doyle 2024-01-26 16:51:38 +00:00
parent 4e47cf5aba
commit 7b29ec8beb
Signed by: Jayrude
GPG Key ID: 38B57B16E7C0ADF7
1 changed files with 30 additions and 9 deletions

View File

@ -1,15 +1,36 @@
use bevy::{prelude::*, window::PresentMode};
fn main() {
App::new()
.add_plugins(DefaultPlugins.set(WindowPlugin {
primary_window: Some(Window {
title: "Harenae".into(),
resolution: (1280.0, 720.0).into(),
present_mode: PresentMode::AutoVsync,
..default()
}),
let window_plugin = WindowPlugin {
primary_window: Some(Window {
title: "Harenae".into(),
resolution: (1280., 720.).into(),
present_mode: PresentMode::AutoVsync,
..default()
}))
}),
..default()
};
App::new()
.add_plugins(
DefaultPlugins
.set(window_plugin)
.set(ImagePlugin::default_nearest()),
)
.add_systems(Startup, setup)
.insert_resource(ClearColor(Color::rgb_u8(45, 42, 46)))
.run();
}
fn setup(mut commands: Commands) {
commands.spawn(Camera2dBundle::default());
commands.spawn(SpriteBundle {
sprite: Sprite {
color: Color::rgb(0.25, 0.25, 0.75),
custom_size: Some(Vec2::new(50.0, 100.0)),
..default()
},
transform: Transform::from_translation(Vec3::new(-50., 0., 0.)),
..default()
});
}