Compare commits

...

6 Commits

Author SHA1 Message Date
Zynh Ludwig 00e5bab2a5 variable naming 2024-08-20 12:14:10 -07:00
Zynh Ludwig e2b5513dd3 compute tile offset 2024-08-20 11:58:31 -07:00
Zynh Ludwig 46ebd36a9c off by one errors baby 2024-08-20 11:54:11 -07:00
Zynh Ludwig 7706a9f3ef winit desktop app 2024-08-20 10:24:53 -07:00
Zynh Ludwig 6b23727864 some tiles? 2024-08-20 10:13:47 -07:00
Zynh Ludwig 1fe15d778b use clang + mold: experimental 2024-08-20 09:49:13 -07:00
3 changed files with 30 additions and 8 deletions

View File

@ -2,4 +2,7 @@
rustflags = [
# (Nightly) Make the current crate share its generic instantiations
"-Zshare-generics=y",
"-C",
"link-arg=-fuse-ld=mold",
]
linker = "clang"

View File

@ -5,6 +5,8 @@ with pkgs;
mkShell rec {
nativeBuildInputs = [
pkg-config
mold
clang
];
buildInputs = [
udev

View File

@ -1,6 +1,8 @@
use bevy::{
color::palettes::tailwind,
prelude::*,
sprite::{MaterialMesh2dBundle, Mesh2dHandle},
winit::WinitSettings,
};
// In a vacuum this is just 2, 2 dimenionsal arrays, but I think
@ -55,6 +57,7 @@ use bevy::{
fn main() {
App::new()
.insert_resource(WinitSettings::desktop_app())
.add_plugins(DefaultPlugins)
.add_systems(Startup, setup)
.run();
@ -67,13 +70,27 @@ fn setup(
) {
commands.spawn(Camera2dBundle::default());
let circle_mesh = Mesh2dHandle(meshes.add(Circle { radius: 50. }));
let color = Color::hsl(75., 0.95, 0.7);
const TILES: i32 = 9;
const TILE_SIZE: f32 = 50.;
const GAP_SIZE: f32 = 10.;
const OFFSET: f32 = (TILE_SIZE + GAP_SIZE) / 2.;
const TOTAL_WIDTH: f32 = (TILE_SIZE + GAP_SIZE) * TILES as f32;
const TILE_SPACE: f32 = TOTAL_WIDTH / TILES as f32;
const CENTER: f32 = TOTAL_WIDTH / 2.;
commands.spawn(MaterialMesh2dBundle {
mesh: circle_mesh,
material: materials.add(color),
transform: Transform::from_xyz(0., 0., 0.),
..default()
});
let tile_mesh = Mesh2dHandle(meshes.add(Rectangle::new(TILE_SIZE, TILE_SIZE)));
let tile_color = Color::from(tailwind::NEUTRAL_700);
for i in 0..TILES {
for j in 0..TILES {
let tile_x = i as f32 * TILE_SPACE - CENTER + OFFSET;
let tile_y = j as f32 * TILE_SPACE - CENTER + OFFSET;
commands.spawn(MaterialMesh2dBundle {
mesh: tile_mesh.clone(),
material: materials.add(tile_color),
transform: Transform::from_xyz(tile_x, tile_y, 0.),
..default()
});
}
}
}