Ejemplo n.º 1
0
        public Playing(ContentManager content, EventHandler screenEvent, GraphicsDevice gd)
            : base(screenEvent)
        {
            graphic = gd;
            playingBackground = content.Load<Texture2D>(@"picture/candi borobudur background");
            puzzleFont = content.Load<Texture2D>(@"picture/tulisan puzzle");
            pauseFont = content.Load<Texture2D>(@"picture/tulisan puzzle");
            moveFont = content.Load<Texture2D>(@"picture/counter pindah");
            moveCounter = content.Load<SpriteFont>(@"move");
            successFont = content.Load<Texture2D>(@"picture/berhasil");

            state = GameState.post;
            picture = new Picture();
            pictureGame = content.Load<Texture2D>(@"picture/" + picture.getNamePicture() + "");

            move = 0;
                //pictureGame = content.Load<Texture2D>(@"picture/siap");
            ct = content;
            grayBackground = content.Load<Texture2D>(@"picture/gray");
            backButton = content.Load<Texture2D>(@"picture/button kembali");
            playButton = content.Load<Texture2D>(@"picture/button main");
            pauseButton = content.Load<Texture2D>(@"picture/button berhenti");
            resumeButton = content.Load<Texture2D>(@"picture/button lanjut");
            backButtonPosition = new Vector2(20, 420);
            playButtonPosition = new Vector2(40, 370);
            pauseButtonPosition = new Vector2(40, 370);
            resumeButtonPosition = new Vector2(40, 370);
        }
Ejemplo n.º 2
0
        private void mouseClicked(int x, int y)
        {
            Rectangle mouseClickedRect = new Rectangle(x, y, 10, 10);
            Rectangle backButtonRect = new Rectangle((int)backButtonPosition.X, (int)backButtonPosition.Y, 160, 40);
            if (mouseClickedRect.Intersects(backButtonRect))
                {
                    picture = new Picture();
                    pictureGame = ct.Load<Texture2D>(@"picture/" + picture.getNamePicture() + "");
                    splitAndShufflePicture();
                    screenEvent.Invoke(this, new EventArgs());
                    state = GameState.pre;
                    pause = false;
                }
            if (state == GameState.pre)
            {
                Rectangle playButtonRect = new Rectangle((int)playButtonPosition.X, (int)playButtonPosition.Y, 125, 40);
                if (mouseClickedRect.Intersects(playButtonRect))
                {
                    splitAndShufflePicture();
                    state = GameState.middle;
                }
            }
            else if (state == GameState.middle)
            {
                if (!pause)
                {
                    Rectangle pauseButtonRect = new Rectangle((int)pauseButtonPosition.X, (int)pauseButtonPosition.Y, 140, 40);
                    if (mouseClickedRect.Intersects(pauseButtonRect))
                    {
                        pause = true;
                    }
                    Rectangle tile1Rect = new Rectangle(300, 30, 142, 142);
                    Rectangle tile2Rect = new Rectangle(442, 30, 142, 142);
                    Rectangle tile3Rect = new Rectangle(584, 30, 142, 142);
                    Rectangle tile4Rect = new Rectangle(300, 172, 142, 142);
                    Rectangle tile5Rect = new Rectangle(442, 172, 142, 142);
                    Rectangle tile6Rect = new Rectangle(584, 172, 142, 142);
                    Rectangle tile7Rect = new Rectangle(300, 314, 142, 142);
                    Rectangle tile8Rect = new Rectangle(442, 314, 142, 142);
                    Rectangle tile9Rect = new Rectangle(584, 314, 142, 142);

                    if (mouseClickedRect.Intersects(tile1Rect))
                    {
                        checkTile(0);
                        move++;
                    }
                    else if (mouseClickedRect.Intersects(tile2Rect))
                    {
                        checkTile(1);
                        move++;
                    }
                    else if (mouseClickedRect.Intersects(tile3Rect))
                    {
                        checkTile(2);
                        move++;
                    }
                    else if (mouseClickedRect.Intersects(tile4Rect))
                    {
                        checkTile(3);
                        move++;
                    }
                    else if (mouseClickedRect.Intersects(tile5Rect))
                    {
                        checkTile(4);
                        move++;
                    }
                    else if (mouseClickedRect.Intersects(tile6Rect))
                    {
                        checkTile(5);
                        move++;
                    }
                    else if (mouseClickedRect.Intersects(tile7Rect))
                    {
                        checkTile(6);
                        move++;
                    }
                    else if (mouseClickedRect.Intersects(tile8Rect))
                    {
                        checkTile(7);
                        move++;
                    }
                    else if (mouseClickedRect.Intersects(tile9Rect))
                    {
                        checkTile(8);
                        move++;
                    }

                }
                else
                {
                    Rectangle resumeButtonRect = new Rectangle((int)resumeButtonPosition.X, (int)resumeButtonPosition.Y, 140, 40);
                    if (mouseClickedRect.Intersects(resumeButtonRect))
                    {
                        pause = false;
                    }
                }
            }
            else if (state == GameState.post)
            {

            }
        }