public bool CheckCollision(Snake snake, Food food)
 {
     if (snake.PositionX == food.PositionX && snake.PostitionY == food.PostitionY)
     {
         snake.Eat();
         food.Eaten();
         return true;
     }
     else
         return false;
 }
Exemple #2
0
        static void Main()
        {
            Snake snake;
            Food food;
            Enviroment enviroment;
            snake = new Snake();
            food = new Food();
            enviroment = new Enviroment();

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());
        }
Exemple #3
0
        public Form1()
        {
            InitializeComponent();
            snake = new Snake();
            food = new Food();
            gamecontrol = new GameControl();
            enviroment = new Enviroment();
            food.CreateFood();  // hogy a legelején legyen kaja

            // dupla bufferelés
            SetStyle(ControlStyles.DoubleBuffer |
                ControlStyles.UserPaint |
                ControlStyles.AllPaintingInWmPaint,
                true);
            UpdateStyles();
        }