From 7b29ec8bebfa32ac3c4a4040b35cfaa5a17c4c66 Mon Sep 17 00:00:00 2001 From: Jarrod Doyle Date: Fri, 26 Jan 2024 16:51:38 +0000 Subject: [PATCH] Add a camera, render a rect, and set the clear colour --- src/main.rs | 39 ++++++++++++++++++++++++++++++--------- 1 file changed, 30 insertions(+), 9 deletions(-) diff --git a/src/main.rs b/src/main.rs index 00a8e35..9ff4c5a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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() + }); +}