Base game template

This commit is contained in:
Jeremy Kaplan 2026-08-09 13:08:28 -04:00
commit f83c7c0781
7 changed files with 6158 additions and 0 deletions

View file

@ -1,3 +1,45 @@
use bevy::camera::ScalingMode;
use bevy::prelude::*;
pub const WORLD_SIZE: Vec2 = Vec2::new(480., 640.);
fn main() {
App::new()
.insert_resource(ClearColor(Color::BLACK))
.add_plugins(DefaultPlugins.set(WindowPlugin {
// Until there's a reliable way to hint that a game window should
// float on tiling window managers, the most reliable way to achieve
// that is to define a fixed non-resizable window.
//
// https://github.com/rust-windowing/winit/issues/862#issuecomment-2047791401
primary_window: Some(Window {
resize_constraints: WindowResizeConstraints {
min_width: WORLD_SIZE.x,
min_height: WORLD_SIZE.y,
max_width: WORLD_SIZE.x,
max_height: WORLD_SIZE.y,
},
..default()
}),
..default()
}))
.add_systems(Startup, (setup, greet).chain())
.run();
}
fn setup(mut commands: Commands) {
commands.spawn((
Camera2d,
Projection::Orthographic(OrthographicProjection {
scaling_mode: ScalingMode::Fixed {
width: WORLD_SIZE.x,
height: WORLD_SIZE.y,
},
..OrthographicProjection::default_2d()
}),
));
}
fn greet() {
println!("Hello, world!");
}