Example #1
0
        public Play()
        {
            InitializeComponent();

            rows = 10;
            columns = 10;
            offset = 20;
            comboTimerTicks = 0;
            time = 120;
            freezeSeconds = 0;
            squareWidth = Resources._1.Width + 5;

            this.CenterToScreen();
            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
            this.Height = 8 * offset + rows * squareWidth;
            this.Width = 3 * offset + columns * squareWidth - 15;
            this.BackColor = System.Drawing.Color.Black;
            this.DoubleBuffered = true;

            comboScore = false;
            bombWeaponSelected = false;
            cutWeaponSelected = false;
            freezeWeaponSelected = false;
            bombUsed = false;
            cutUsed = false;
            freezeUsed = false;

            nosTimer.Start();

            font = new Fonts("lgs.ttf", 28);

            sMatrix = new SquaresMatrix(rows, columns, squareWidth, offset);

            bomb = new Square(80 + rows * squareWidth, offset + 150, squareWidth);
            bomb.image = Resources.bomb;
            bomb.imageSelected = Resources.bomb_selected;
            bomb.imageDefault = Resources.no_bomb;
            cut = new Square(80 + rows * squareWidth, offset + 195, squareWidth);
            cut.image = Resources.cut_sword;
            cut.imageSelected = Resources.cut_sword_selected;
            cut.imageDefault = Resources.no_sword;
            freeze = new Square(80 + rows * squareWidth, offset + 240, squareWidth);
            freeze.image = Resources.freeze_time;
            freeze.imageSelected = Resources.no_freeze_time;
            mute = new Square(80 + rows * squareWidth, this.Width - squareWidth - offset - 5, squareWidth);
            mute.image = Resources.volume;
            mute.imageSelected = Resources.volume_off;
        }
Example #2
0
        public Form1()
        {
            InitializeComponent();
            mainSound = new Sounds();
            this.CenterToScreen();
            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
            this.Width = Resources.squares.Width + 15;
            this.Height = Resources.squares.Width + 15;
            this.BackColor = System.Drawing.Color.Black;
            this.DoubleBuffered = true;

            main = Resources.squares;
            playBtn = Resources.Play2;
            highScoresBtn = Resources.Score1;
            helpBtn = Resources.HelpBtn;
            exitBtn = Resources.Exit;
            playBtnHover = Resources.Play_hover;
            exitBtnHover = Resources.Exit_hover;
            scoresBtnHover = Resources.Score_hover;
            helpBtnHover = Resources.Help_hover;

            scoresHoverBtmp = new Bitmap(scoresBtnHover, new Size(210, 80));
            helpHoverBtmp = new Bitmap(helpBtnHover, new Size(210, 80));
            exitHoverBtmp = new Bitmap(exitBtnHover, new Size(210, 80));
            playHoverBtmp = new Bitmap(playBtnHover, new Size(210, 80));
            exitBitmap = new Bitmap(exitBtn, new Size(210, 80));
            helpBitmap = new Bitmap(helpBtn, new Size(210, 80));
            highScoreBitmap = new Bitmap(highScoresBtn, new Size(210, 80));
            playBitmap = new Bitmap(playBtn, new Size(210, 80));
            mainBitmap = new Bitmap(main);

            s1 = new Square(220, 410, 40);
            s1.image = Resources._1;
            s2 = new Square(290, 35, 40);
            s2.image = Resources._9;
            s3 = new Square(350, 220, 40);
            s3.image = Resources._5;
            s4 = new Square(410, 200, 40);
            s4.image = Resources._7;

            hs = new HighScores();

            animationTimer.Start();
        }
        public SquaresMatrix(int r, int c, int w, int o)
        {
            rows = r;
            columns = c;
            offset = o;
            squareWidth = w;
            score = 0;
            combo = 0;
            numberOfSquares = 5;
            numberOfSquaresPainted = 0;
            gameOver = false;
            random = new Random();
            randomImage = new RandomImage();
            gameSound = new Sounds();
            selectedSquare = null;
            selectedSquareDest = null;

            initializeMatrix();
            paintRandomSquares(numberOfSquares);
        }
 private void initializeMatrix()
 {
     matrix = new List<List<Square>>();
     for (int i = 0; i < rows; i++)
     {
         List<Square> list = new List<Square>();
         for (int j = 0; j < columns; j++)
         {
             Square s = new Square(offset + squareWidth * i, offset + squareWidth * j, squareWidth);
             list.Add(s);
         }
         matrix.Add(list);
     }
 }
 public void selectAndMove(int X, int Y)
 {
     int x = 10, y = 10;
     bool change = false;
     int i = (Y - offset) / squareWidth;
     int j = (X - offset) / squareWidth;
     if (matrix.ElementAt(i).ElementAt(j).isHit(X, Y) && matrix.ElementAt(i).ElementAt(j).isPainted)
     {
         if (selectedSquare != null)
             selectedSquare.isSelected = false;
         matrix.ElementAt(i).ElementAt(j).isSelected = true;
         selectedSquare = matrix.ElementAt(i).ElementAt(j);
         change = true;
     }
     else if (matrix.ElementAt(i).ElementAt(j).isHit(X, Y) && selectedSquare != null)
     {
         selectedSquareDest = matrix.ElementAt(i).ElementAt(j);
         x = i;
         y = j;
     }
     if (!change && selectedSquare != null && selectedSquareDest != null)
     {
         if (path())
         {
             selectedSquareDest.image = selectedSquare.image;
             selectedSquareDest.imageSelected = selectedSquare.imageSelected;
             selectedSquare.image = selectedSquare.imageDefault;
             selectedSquare.imageSelected = null;
             selectedSquare.isSelected = false;
             selectedSquare.isPainted = false;
             selectedSquareDest.isSelected = false;
             selectedSquareDest.isPainted = true;
             selectedSquare = null;
             selectedSquareDest = null;
             if (!hasConnected(x, y))
             {
                 gameSound.playPlaceSquare();
                 paintRandomSquares(numberOfSquares);
                 if (combo >= 3)
                 {
                     score += combo * 50;
                     getComboScore = combo * 50;
                 }
                 combo = 0;
             }
             else
             {
                 gameSound.playScore();
                 score += 100;
                 numberOfSquaresPainted -= 3;
                 combo++;
             }
         }
         else gameSound.playNoPath();
     }
     if (numberOfSquaresPainted == 0)
         paintRandomSquares(numberOfSquares);
 }