Пример #1
0
 public GameBoard()
 {
     board = new List<List<Sprite>>();
     initialize_board();
     current_state = State.puting;
     next = getNext();
 }
Пример #2
0
 public override void Draw(Sprite sprite)
 {
   foreach (var pixel in sprite) {
     pixel.Draw(this);
   }
   ConsoleScreen.Draw(sprite.X + sprite.Width, sprite.Y, sprite.Color, () => Console.Write(sprite));
 }
Пример #3
0
 public override void Draw(Sprite sprite)
 {
   var xc = sprite.X + sprite.Width / 2;
   var yc = sprite.Y - sprite.Height / 2;
   foreach (var pixel in sprite) {
     var xn = xc + (pixel.X - xc) * Math.Cos(sprite.Angle) + (pixel.Y - yc) * Math.Sin(sprite.Angle);
     var yn = yc - (pixel.X - xc) * Math.Sin(sprite.Angle) + (pixel.Y - yc) * Math.Cos(sprite.Angle);
     var rep = pixel.Clone();
     rep.Set(xn, yn);
     rep.Draw(this);
   }
   ConsoleScreen.Draw(sprite.X + sprite.Width, sprite.Y, sprite.Color, () => Console.Write(sprite));
 }
Пример #4
0
        public Sprite get_selected(int x, int y)
        {
            foreach (var sublist in board)
            {
                foreach (Sprite value in sublist)
                {
                    if (value.overlaps(x, y))
                    {
                        this.selected = (Sprite) value;
                        return value;
                    }
                }

            }

            return null;
        }
Пример #5
0
        public void update()
            {

                List<Sprite> equal = new List<Sprite>();
                int i = selected.i;
                int j = selected.j;

                //Arriba

                if ( i > 0 && j > 0 &&
                    board[i - 1][j].current == selected.current && 
                    board[i - 1][j - 1].current == selected.current )
                   
                {
                    equal.Add(board[i - 1][j]);
                    equal.Add(board[i - 1][j -1]);
                }

                if (i > 1 && 
                      board[i - 1][j].current == selected.current &&
                      board[i - 2][j].current == selected.current)
                {
                    equal.Add(board[i - 1][j]);
                    equal.Add(board[i - 2][j]);
                }

                if (i > 0 && j < 8 &&
                        board[i - 1][j].current == selected.current &&
                        board[i - 1][j+1].current == selected.current)
                {
                    equal.Add(board[i - 1][j]);
                    equal.Add(board[i - 1][j+1]);
                }


            //Izq
               if (j > 1 && 
                    board[i][j-1].current == selected.current &&
                    board[i][j-2].current == selected.current)
                {
                    equal.Add(board[i][j-1]);
                    equal.Add(board[i][j-2]);
                }

               if (i > 0 && j > 0 &&
                      board[i][j-1].current == selected.current &&
                      board[i-1][j-1].current == selected.current)
                {
                    equal.Add(board[i][j-1]);
                    equal.Add(board[i-1][j-1]);
                }

                if (i < 8 && j > 0 &&
                        board[i][j-1].current == selected.current &&
                        board[i+1][j-1].current == selected.current)
                {
                    equal.Add(board[i][j-1]);
                    equal.Add(board[i+1][j-1]);
                }



                //Abajo

                if (i < 8 && j > 0 &&
                    board[i + 1][j].current == selected.current &&
                    board[i + 1][j-1].current == selected.current)
                {
                    equal.Add(board[i + 1][j]);
                    equal.Add(board[i + 1][j - 1]);
                }

                if (i < 7 &&
                      board[i + 1][j].current == selected.current &&
                      board[i + 2][j].current == selected.current)
                {
                    equal.Add(board[i + 1][j]);
                    equal.Add(board[i + 2][j]);
                }

                if (i < 8 && j < 8 &&
                        board[i + 1][j].current == selected.current &&
                        board[i + 1][j + 1].current == selected.current)
                {
                    equal.Add(board[i + 1][j]);
                    equal.Add(board[i + 1][j + 1]);
                }


                //der
                if (i > 0 && j < 8 &&
                     board[i][j + 1].current == selected.current &&
                     board[i-1][j +1].current == selected.current)
                {
                    equal.Add(board[i][j + 1]);
                    equal.Add(board[i-1][j + 1]);
                }

                if (j < 7 &&
                       board[i][j + 1].current == selected.current &&
                       board[i][j + 2].current == selected.current)
                {
                    equal.Add(board[i][j + 1]);
                    equal.Add(board[i][j + 2]);
                }

                if (i < 8 && j < 8 &&
                        board[i][j + 1].current == selected.current &&
                        board[i + 1][j + 1].current == selected.current)
                {
                    equal.Add(board[i][j + 1]);
                    equal.Add(board[i + 1][j + 1]);
                }


                //sides
                if (i > 0 && i < 8 &&
                     board[i+1][j].current == selected.current &&
                     board[i-1][j].current == selected.current)
                {
                    equal.Add(board[i+1][j]);
                    equal.Add(board[i-1][j]);
                }

                if (j > 0 && j < 8 &&
                       board[i][j+1].current == selected.current &&
                       board[i][j-1].current == selected.current)
                {
                    equal.Add(board[i][j + 1]);
                    equal.Add(board[i][j - 1]);
                }

                //esquinitas
                if (i > 0 && j > 0 &&
                     board[i-1][j].current == selected.current &&
                     board[i][j-1].current == selected.current)
                {
                    equal.Add(board[i-1][j]);
                    equal.Add(board[i][j-1]);
                }

                if (j > 0 && i < 8 &&
                       board[i+1][j].current == selected.current &&
                       board[i][j-1].current == selected.current)
                {
                    equal.Add(board[i+1][j]);
                    equal.Add(board[i][j-1]);
                }

            
                if (i < 8 && j<8 &&
                         board[i+1][j].current == selected.current &&
                         board[i][j+1].current == selected.current)
                {
                    equal.Add(board[i+1][j]);
                    equal.Add(board[i][j+1]);
                }

                if (j < 8 && i > 0 &&
                       board[i-1][j].current == selected.current &&
                       board[i][j+1].current == selected.current)
                {
                    equal.Add(board[i-1][j]);
                    equal.Add(board[i][j + 1]);
                }




                foreach (Sprite val in equal)
                {
                    val.current = Sprite.Type.empty;
                }

                if ((int)selected.current < 2  && equal.Count >= 2)
                {
                    selected.current++;
                }
                foreach (Sprite val in equal)
                {
                    val.current = Sprite.Type.peon;
                }

                if ((int)selected.current < 3 && equal.Count >= 3)
                {
                    selected.current++;
            }

        public Sprite getNext()
            {
                Random random = new Random();
                next = new Sprite((Sprite.Type)random.Next(1,3));
                return next; 
            }


    }
Пример #6
0
 public Sprite(Sprite.Type current)
 {
     this.current = current;
     this.i = 11;
     this.j = 1;
    _frames.Add(new Bitmap(@"C:\Users\Zero\Downloads\Game\Game\images\peon.bmp"));
     _frames.Add(new Bitmap(@"C:\Users\Zero\Downloads\Game\Game\images\torre.bmp"));
     _frames.Add(new Bitmap(@"C:\Users\Zero\Downloads\Game\Game\images\reina.bmp"));
     _frames.Add(new Bitmap(@"C:\Users\Zero\Downloads\Game\Game\images\caballo.bmp"));
 }
Пример #7
0
        public Sprite(int i, int j, Sprite.Type current)
        {
            this.current = current;
            this.i=i;
            this.j=j;
            x = i * size;
            y = j * size;
            _frames.Add(new Bitmap(@"C:\Users\Zero\Downloads\Game\Game\images\peon.bmp"));
            _frames.Add(new Bitmap(@"C:\Users\Zero\Downloads\Game\Game\images\torre.bmp"));
            _frames.Add(new Bitmap(@"C:\Users\Zero\Downloads\Game\Game\images\reina.bmp"));
            _frames.Add(new Bitmap(@"C:\Users\Zero\Downloads\Game\Game\images\caballo.bmp"));

            
        }