Beispiel #1
0
 public void dodajFiguru(Figura obj)
 {
     if (obj != null)
     {
         _listaF.Add(obj);
     }
 }
Beispiel #2
0
        public void obrisiFiguru(Figura obj)
        {
            int icoordinata = obj.GlavnaKoordinata.X;
            int jcoordinata = obj.GlavnaKoordinata.Y;

            for (int i = 0; i < obj.N; i++)
            {
                for (int j = 0; j < obj.N; j++)
                {
                    if (obj.Matrica[i][j])
                    {
                        MatricaProvera[i + icoordinata][j + jcoordinata] = false;
                        MatricaBoja[i + icoordinata][j + jcoordinata]    = PrimarnaCetka;
                    }
                }
            }
        }
Beispiel #3
0
        public void dodajFiguru(Figura obj)
        {
            int icordinata = obj.GlavnaKoordinata.X;
            int jcordinata = obj.GlavnaKoordinata.Y;

            for (int i = 0; i < obj.N; i++)
            {
                for (int j = 0; j < obj.N; j++)
                {
                    if (obj.Matrica[i][j])
                    {
                        MatricaProvera[i + icordinata][j + jcordinata] = true;
                        MatricaBoja[i + icordinata][j + jcordinata]    = new SolidBrush(obj.Boja);
                    }
                }
            }
        }
Beispiel #4
0
 public Figura(Figura obj)
 {
     Boja    = obj.Boja;
     N       = obj.N;
     Matrica = new bool[N][];
     for (int i = 0; i < N; i++)
     {
         Matrica[i] = new bool[N];
     }
     for (int i = 0; i < N; i++)
     {
         for (int j = 0; j < N; j++)
         {
             Matrica[i][j] = obj.Matrica[i][j];
         }
     }
     GlavnaKoordinata = new Point();
 }
Beispiel #5
0
        public void dodajOblike(int n1)
        {
            _listaF.Clear();

            //crtamo i dodajemo u listu plavi pravugaonik
            Figura pravugaonik = new Figura(4, System.Drawing.Color.MediumTurquoise);

            for (int i = 0; i < 4; i++)
            {
                pravugaonik.Matrica[i][pravugaonik.GlavnaKordinataInt] = true;
            }

            //crtamo kocku popunjenu celu,veliku
            Figura kocka = new Figura(n1, System.Drawing.Color.ForestGreen);

            for (int i = 0; i < n1; i++)
            {
                for (int j = 0; j < n1; j++)
                {
                    kocka.Matrica[i][j] = true;
                }
            }

            //crtamo malu kockicu
            Figura kockica = new Figura(n1, System.Drawing.Color.Yellow);

            kockica.Matrica[kockica.GlavnaKordinataInt][kockica.GlavnaKordinataInt] = true;

            //crtamo krstic mali
            Figura krstic = new Figura(n1, System.Drawing.Color.MediumPurple);

            for (int i = 0; i < n1; i++)
            {
                krstic.Matrica[i][krstic.GlavnaKordinataInt] = true;
            }
            for (int j = 0; j < n1; j++)
            {
                krstic.Matrica[krstic.GlavnaKordinataInt][j] = true;
            }

            //crtamo crvenu figuru
            Figura kapica = new Figura(n1, System.Drawing.Color.Red);

            for (int i = 0; i < n1; i++)
            {
                kapica.Matrica[kapica.GlavnaKordinataInt][i] = true;
            }
            for (int i = 0; i < kapica.GlavnaKordinataInt; i++)
            {
                kapica.Matrica[i][kapica.GlavnaKordinataInt] = true;
            }

            Figura kvad2x2 = new Figura(2, System.Drawing.Color.Aquamarine);

            for (int i = 0; i < 2; i++)
            {
                kvad2x2.Matrica[0][i] = true;
                kvad2x2.Matrica[1][i] = true;
            }

            Figura Z = new Figura(3, System.Drawing.Color.BurlyWood);

            Z.Matrica[0][0] = true;
            Z.Matrica[1][1] = true;
            Z.Matrica[1][0] = true;
            Z.Matrica[2][1] = true;

            Figura Z1 = new Figura(3, System.Drawing.Color.DarkSeaGreen);

            Z1.Matrica[0][2] = true;
            Z1.Matrica[1][1] = true;
            Z1.Matrica[1][2] = true;
            Z1.Matrica[2][1] = true;

            Figura g1 = new Figura(3, System.Drawing.Color.Crimson);

            for (int i = 0; i < 3; i++)
            {
                g1.Matrica[i][0] = true;
                g1.Matrica[0][1] = true;
            }

            Figura g2 = new Figura(3, System.Drawing.Color.DarkTurquoise);

            for (int i = 0; i < 3; i++)
            {
                g2.Matrica[i][1] = true;
                g2.Matrica[0][0] = true;
            }

            Figura l1 = new Figura(2, System.Drawing.Color.MediumVioletRed);

            for (int i = 0; i < 2; i++)
            {
                l1.Matrica[0][i] = true;
                l1.Matrica[1][1] = true;
            }

            Figura l2 = new Figura(2, System.Drawing.Color.Gold);

            for (int i = 0; i < 2; i++)
            {
                l2.Matrica[0][i] = true;
                l2.Matrica[1][0] = true;
            }

            Figura i1 = new Figura(2, System.Drawing.Color.GreenYellow);

            for (int i = 0; i < 2; i++)
            {
                i1.Matrica[0][i] = true;
            }

            Figura i2 = new Figura(3, System.Drawing.Color.Gold);

            for (int i = 0; i < 3; i++)
            {
                i2.Matrica[i][0] = true;
                i2.Matrica[1][1] = true;
            }

            //dodajemo u listu figura
            _listaF.Add(pravugaonik);
            _listaF.Add(kocka);
            _listaF.Add(kockica);
            _listaF.Add(kapica);
            _listaF.Add(kvad2x2);
            _listaF.Add(Z);
            _listaF.Add(Z1);
            _listaF.Add(g1);
            _listaF.Add(g2);
            _listaF.Add(l1);
            _listaF.Add(l2);
            _listaF.Add(i1);
            _listaF.Add(i2);
        }
Beispiel #6
0
        public bool ZauzetoJe(Figura obj)
        {
            int  icoordinata = obj.GlavnaKoordinata.X;
            int  jcoordinata = obj.GlavnaKoordinata.Y;
            int  proveri1    = obj.N - 1 + icoordinata;
            int  proveri2    = obj.N - 1 + jcoordinata;
            int  provera3    = jcoordinata;
            bool provera     = false;

            for (int j = obj.N - 1; j >= 0; j--)
            {
                for (int i = 0; i < obj.N; i++)
                {
                    if (obj.Matrica[i][j])
                    {
                        provera = true;
                    }
                }
                if (provera)
                {
                    break;
                }
                proveri2--;
            }

            provera = false;
            for (int j = obj.N - 1; j >= 0; j--)
            {
                for (int i = 0; i < obj.N; i++)
                {
                    if (obj.Matrica[j][i])
                    {
                        provera = true;
                    }
                }
                if (provera)
                {
                    break;
                }
                proveri1--;
            }


            provera = false;
            for (int j = 0; j < obj.N; j++)
            {
                for (int i = 0; i < obj.N; i++)
                {
                    if (obj.Matrica[i][j])
                    {
                        provera = true;
                    }
                }
                if (provera)
                {
                    break;
                }
                provera3++;
            }

            if (proveri1 >= N || proveri2 >= M || provera3 < 0)
            {
                return(true);
            }
            for (int i = 0; i < obj.N; i++)
            {
                for (int j = 0; j < obj.N; j++)
                {
                    if (obj.Matrica[i][j])
                    {
                        if (MatricaProvera[i + icoordinata][j + jcoordinata] == true)
                        {
                            return(true);
                        }
                    }
                }
            }
            return(false);
        }