Add a camera, render a rect, and set the clear colour
This commit is contained in:
parent
4e47cf5aba
commit
7b29ec8beb
29
src/main.rs
29
src/main.rs
|
@ -1,15 +1,36 @@
|
||||||
use bevy::{prelude::*, window::PresentMode};
|
use bevy::{prelude::*, window::PresentMode};
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
App::new()
|
let window_plugin = WindowPlugin {
|
||||||
.add_plugins(DefaultPlugins.set(WindowPlugin {
|
|
||||||
primary_window: Some(Window {
|
primary_window: Some(Window {
|
||||||
title: "Harenae".into(),
|
title: "Harenae".into(),
|
||||||
resolution: (1280.0, 720.0).into(),
|
resolution: (1280., 720.).into(),
|
||||||
present_mode: PresentMode::AutoVsync,
|
present_mode: PresentMode::AutoVsync,
|
||||||
..default()
|
..default()
|
||||||
}),
|
}),
|
||||||
..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();
|
.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()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue