예제 #1
0
        //melakukan penempatan pentomino pada posisi x, y
        public void place_pentomino(Pentominos p, int x, int y)
        {
            int     lalaye = 0;
            Boolean laye   = false;

            for (int i = 0; i < 5; i++)
            {
                for (int j = 0; j < 5; j++)
                {
                    if (p.getMatrix()[i, j] == 1)
                    {
                        p.SetPos(x, y - lalaye);

                        laye = true;
                        break;
                    }
                    else
                    {
                        lalaye += 25;
                    }
                }
                if (laye)
                {
                    break;
                }
            }
        }
예제 #2
0
파일: Form.cs 프로젝트: willyfh/pentomaster
        //menghandel pergerakan mouse
        private void frmPentominos_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            if (draggedpentomino != null)
            {
                int iPosX = e.X / 25;
                int iPosY = e.Y / 25;

                iPosX *= 25;
                iPosY *= 25;

                if (iPosX != draggedpentomino.GetX() || iPosY != draggedpentomino.GetY())
                {
                    Rectangle rect = new Rectangle(draggedpentomino.GetX() - 2, draggedpentomino.GetY() - 2, draggedpentomino.GetWidth() + 4, draggedpentomino.GetHeight() + 4);
                    draggedpentomino.SetPos(iPosX, iPosY);
                    Region rgn = new Region(rect);
                    rect = new Rectangle(iPosX - 2, iPosY - 2, draggedpentomino.GetWidth() + 4, draggedpentomino.GetHeight() + 4);
                    rgn.Union(rect);
                    Invalidate(rgn);
                }
            }
            if (editorB)
            {
                int iPosX = e.X / 25;
                int iPosY = e.Y / 25;

                iPosX *= 25;
                iPosY *= 25;

                if (e.Button == MouseButtons.Left)
                {
                    editor.atPos(iPosX, iPosY, set);
                    Rectangle rect = new Rectangle(100, 50, 350, 300);

                    Region rgn = new Region(rect);
                    rect = new Rectangle(100, 50, 350, 300);
                    rgn.Union(rect);
                    Invalidate(rgn);
                }
            }
        }