draw grid system

This commit is contained in:
nquidox 2026-04-17 23:26:53 +03:00
parent b95dde79a1
commit 71f6b549b7
3 changed files with 28 additions and 5 deletions

View file

@ -16,3 +16,4 @@ pub const ROUND_BALL_Z: f32 = 10.0;
pub const PINK: Color = Color::srgb_u8(250, 0, 155);
pub const BLUE: Color = Color::srgb_u8(0, 0, 255);
pub const GREEN: Color = Color::srgb_u8(0, 255, 0);
pub const DARK_GREEN: Color = Color::srgb_u8(0, 88, 88);

View file

@ -25,6 +25,7 @@ impl Plugin for LinearPlayPlugin {
Update,
(
draw_track_gizmos,
draw_grid,
spawn_round_ball,
move_round_balls,
)

View file

@ -1,4 +1,4 @@
use crate::states;
use crate::{HEIGHT, WIDTH, states, FACTOR};
use bevy::prelude::*;
use states::linear::*;
use std::f32::consts::FRAC_PI_2;
@ -52,3 +52,24 @@ pub fn draw_track_gizmos(track: Res<Track>, mut gizmos: Gizmos) {
// рисуем финиш
gizmos.circle_2d(current_pos, 5.0, Color::WHITE);
}
pub fn draw_grid(mut gizmos: Gizmos) {
let half_x = WIDTH as f32 / 2.0 * FACTOR as f32;
let half_y = HEIGHT as f32 / 2.0 * FACTOR as f32;
for i in 0..WIDTH {
gizmos.line_2d(
Vec2::new((i as f32 - 8.0) * FACTOR as f32, half_y),
Vec2::new((i as f32 - 8.0) * FACTOR as f32, -half_y),
DARK_GREEN,
);
}
for i in 0..HEIGHT {
gizmos.line_2d(
Vec2::new(-half_x, (i as f32 - 4.0) * FACTOR as f32),
Vec2::new(half_x, (i as f32 - 4.0) * FACTOR as f32),
DARK_GREEN,
)
}
}