Author SHA1 Message Date
vova-rs 9852f30581 resize rectsngle 2026-10-26 19:42:11 +03:00
vova-rs 7283bf7ecf rm unused 2026-10-26 17:30:31 +03:00
vova-rs 03c09101fe final predictiv system 2026-10-15 23:13:45 +03:00
vova-rs 27fd785034 move input whitch predikt 2026-10-15 20:51:29 +03:00
4 changed files with 78 additions and 20 deletions

No files matched your search

+8
View File
@@ -4,3 +4,11 @@ version = "0.1.0"
edition = "2024" edition = "2024"
[dependencies] [dependencies]
bevy = "0.20"
[profildev]
opt-level = 1
debug = true
[profile.dev.package."*"]
opt-level = 3
+39
View File
@@ -0,0 +1,39 @@
use bevy::prelude::*;
pub struct Cli;
impl Plugin for Cli {
fn build(&self, app: &mut App) {
app.add_systems(Startup, setup_scene);
// app.add_systems(Update, my_system);
}
}
fn setup_scene(
mut commands: Commands,
) {
commands.spawn(Camera2d);
commands.spawn((
Node {
width: Val::Percent(100.0),
height: Val::Percent(100.0),
justify_content: JustifyContent::Center,
align_items: AlignItems::Center,
..default()
},
BackgroundColor(Color::srgb(0.1, 0.1, 0.1)),
children![
(
Node {
width: Val::VMin(90.0),
height: Val::VMin(90.0),
aspect_ratio: Some(1.0),
..default()
},
BackgroundColor(Color::srgb(0.2, 0.6, 0.8)),
)
],
));
}
+20 -9
View File
@@ -4,15 +4,26 @@ use chess_api::*;
mod render_bitmask; mod render_bitmask;
use render_bitmask::*; use render_bitmask::*;
use bevy::prelude::*;
mod game_client;
fn main() { fn main() {
App::new()
.add_plugins(DefaultPlugins.set(WindowPlugin {
primary_window: Some(Window {
title: "local-chess".into(),
resolution: (800, 800).into(),
resizable: true,
..default()
}),
..default()
}))
.add_plugins(game_client::Cli)
.add_systems(Startup, hello_world_system)
.run();
}
let mut game: Breakthrough = Breakthrough::new(); fn hello_world_system() {
println!("Hello, World!");
let b = game.get_board();
println!("move: {}", game.legal_moves().len());
render_board(BoardColor::Solid('~'), vec![(b.get_mask(Color::White, 0), 'W'), (0xff << 56, 'f')]);
println!("move: {:?}", game.legal_moves());
} }
+11 -11
View File
@@ -1,4 +1,4 @@
#[derive(Clone, Copy)]
pub enum BoardColor { pub enum BoardColor {
Solid(char), Solid(char),
Checkerboard(char, char), Checkerboard(char, char),
@@ -21,20 +21,16 @@ pub fn render_u64(a: u64) {
pub fn render_board(background: BoardColor, layers: Vec<(u64, char)>){ pub fn render_board_row(background: BoardColor, layers: &[(u64, char)], row: u8) {
let mut p: u64 = 1 << 56; let p: u64 = 1 << 56 >> (row as u64 * 8);
for y in 0..8 {
for x in 0..8 { for x in 0..8 {
if let Some((_, ch)) = layers.iter().find(|(a, _)| (p << x as u64) & a > 0) { if let Some((_, ch)) = layers.iter().find(|(a, _)| (p << x as u64) & a > 0) {
print!("{}", ch) print!("{}", ch)
} else { } else {
match background { match background {
BoardColor::Solid(a) => { BoardColor::Solid(a) => print!("{}", a),
print!("{}", a)
},
BoardColor::Checkerboard(a, b) => { BoardColor::Checkerboard(a, b) => {
if (x + y) % 2 == 0 { if (x + row as usize) % 2 == 0 {
print!("{}", a) print!("{}", a)
} else { } else {
print!("{}", b) print!("{}", b)
@@ -43,7 +39,11 @@ pub fn render_board(background: BoardColor, layers: Vec<(u64, char)>){
} }
} }
} }
p = p >> 8; print!("\n");
print!("\n") }
pub fn render_board(background: BoardColor, layers: &[(u64, char)]) {
for row in 0..8 {
render_board_row(background.clone(), layers, row);
} }
} }