123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- use bevy::prelude::{ColorMaterial, Entity, Handle, SystemLabel};
- pub const ARENA_WIDTH: u32 = 10;
- pub const ARENA_HEIGHT: u32 = 10;
- pub struct SnakeHead {
- pub direction: Direction,
- }
- pub struct Food;
- pub struct GrowthEvent;
- #[derive(Default, Copy, Clone, Eq, PartialEq, Hash)]
- pub struct Position {
- pub x: i32,
- pub y: i32,
- }
- pub struct GridSize {
- pub width: f32,
- pub height: f32,
- }
- impl GridSize {
- pub fn square(x: f32) -> GridSize {
- Self {
- width: x,
- height: x,
- }
- }
- }
- pub struct Materials {
- pub head_material: Handle<ColorMaterial>,
- pub segment_material: Handle<ColorMaterial>,
- pub food_material: Handle<ColorMaterial>,
- }
- #[derive(PartialEq, Copy, Clone)]
- pub enum Direction {
- Left,
- Up,
- Right,
- Down,
- }
- impl Direction {
- pub fn opposite(self) -> Self {
- match self {
- Self::Left => Self::Right,
- Self::Right => Self::Left,
- Self::Up => Self::Down,
- Self::Down => Self::Up,
- }
- }
- }
- #[derive(SystemLabel, Debug, Hash, PartialEq, Eq, Clone)]
- pub enum SnakeMovement {
- Input,
- Movement,
- Eating,
- Growth,
- }
- pub struct SnakeSegment;
- #[derive(Default)]
- pub struct SnakeSegments {
- pub segments: Vec<Entity>,
- }
|