Exemplo n.º 1
0
        public void Update(GameTime gameTime)
        {
            //сначала с чем сталкиваемся потом что сталкиваем
            if (TennisBall.IntersectsPixel(TennisBall.BallRectangle, TennisBall.BallTextureData, Panel.PanelRectangle, Panel.PanelTextureData))
            {
                TennisBall.Update(gameTime);
            }
            else if (TennisBall.IntersectsPixel(TennisBall.BallRectangle, TennisBall.BallTextureData, JumpButton.PanelRectangle, JumpButton.PanelTextureData))
            {
                TennisBall.BallVelocity *= 2f;
                TennisBall.Update(gameTime);
            }
            else if (EndBlock.IntersectsPixel(TennisBall.BallRectangle, TennisBall.BallTextureData, EndBlock.PanelRectangle, EndBlock.PanelTextureData))
            {
                TennisBall.Update(gameTime);
                finished = true;
            }
            else
            {
                TennisBall.Update(gameTime);
            }

            if (JumpButton.IntersectsPixel(cursorRectangle, cursorTextureData, JumpButton.PanelRectangle, JumpButton.PanelTextureData) &&
                Mouse.GetState().LeftButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed && !TennisBall.started)
            {
                float x, y;
                x = JumpButton.PanelPosition.X - mouse.X;
                y = JumpButton.PanelPosition.Y - mouse.Y;
                JumpButton.PanelPosition.X = Mouse.GetState().X + x;
                JumpButton.PanelPosition.Y = Mouse.GetState().Y + y;
            }
            if (gui.Start.IntersectsPixel(cursorRectangle, cursorTextureData, gui.Start.ButtonRectangle, gui.Start.ButtonTextureData) &&
                mouse.LeftButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed)
            {
                TennisBall.started = true;
            }
            if (gui.Stop.IntersectsPixel(cursorRectangle, cursorTextureData, gui.Stop.ButtonRectangle, gui.Stop.ButtonTextureData) &&
                mouse.LeftButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed)
            {
                TennisBall.started = false;
            }
            if (gui.Hint.IntersectsPixel(cursorRectangle, cursorTextureData, gui.Hint.HRectangle, gui.Hint.HTextureData) &&
                Mouse.GetState().LeftButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed && TennisBall.started == false)
            {
                MessageBox.Show("Фиолетовый ускоритель поможет мячику забраться\n" +
                                "выше если его правильно использовать.\n", "Подсказка #4", MessageBoxButtons.OK);
            }
            Panel.Update(gameTime);
            JumpButton.Update(gameTime);

            EndBlock.Update(gameTime);

            gui.Update(gameTime);
            mouse           = Mouse.GetState();
            cursorRectangle = new Rectangle(mouse.X - (cursorTexture.Width / 2),
                                            mouse.Y - (cursorTexture.Height / 2), cursorTexture.Width, cursorTexture.Height);
        }
Exemplo n.º 2
0
        public void Update(GameTime gameTime)
        {
            if (SoccerBall.IntersectsPixel(SoccerBall.BallRectangle, SoccerBall.BallTextureData, Panel.PanelRectangle, Panel.PanelTextureData))
            {
                SoccerBall.Update(gameTime);
            }
            else if (EndBlock.IntersectsPixel(SoccerBall.BallRectangle, SoccerBall.BallTextureData, EndBlock.PanelRectangle, EndBlock.PanelTextureData))
            {
                SoccerBall.Update(gameTime);
                finished = true;
            }
            else
            {
                SoccerBall.Update(gameTime);
            }
            if (Panel.IntersectsPixel(cursorRectangle, cursorTextureData, Panel.PanelRectangle, Panel.PanelTextureData) &&
                Mouse.GetState().LeftButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed && !SoccerBall.started)
            {
                float x, y;
                x = Panel.PanelPosition.X - mouse.X;
                y = Panel.PanelPosition.Y - mouse.Y;
                Panel.PanelPosition.X = Mouse.GetState().X + x;
                Panel.PanelPosition.Y = Mouse.GetState().Y + y;
            }
            if (gui.Start.IntersectsPixel(cursorRectangle, cursorTextureData, gui.Start.ButtonRectangle, gui.Start.ButtonTextureData) &&
                mouse.LeftButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed)
            {
                SoccerBall.started = true;
            }
            if (gui.Stop.IntersectsPixel(cursorRectangle, cursorTextureData, gui.Stop.ButtonRectangle, gui.Stop.ButtonTextureData) &&
                mouse.LeftButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed)
            {
                SoccerBall.started = false;
            }
            if (gui.Hint.IntersectsPixel(cursorRectangle, cursorTextureData, gui.Hint.HRectangle, gui.Hint.HTextureData) &&
                Mouse.GetState().LeftButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed && SoccerBall.started == false)
            {
                MessageBox.Show("Используй наклонный блок для направления мяча.\n" +
                                "Пол также можно использовать для прохождения уровня!", "Подсказка #1", MessageBoxButtons.OK);
            }
            Panel.Update(gameTime);
            EndBlock.Update(gameTime);
            gui.Update(gameTime);

            //sprite.Update(gameTime);

            cursorRectangle = new Rectangle(mouse.X - (cursorTexture.Width / 2),
                                            mouse.Y - (cursorTexture.Height / 2), cursorTexture.Width, cursorTexture.Height);
            mouse = Mouse.GetState();
        }
Exemplo n.º 3
0
        public void Update(GameTime gameTime)
        {
            if (TennisBall.IntersectsPixel(TennisBall.BallRectangle, TennisBall.BallTextureData, Panel.PanelRectangle, Panel.PanelTextureData))
            {
                TennisBall.Update(gameTime);
            }
            else if (TennisBall.IntersectsPixel(TennisBall.BallRectangle, TennisBall.BallTextureData, Panel1.PanelRectangle, Panel1.PanelTextureData))
            {
                TennisBall.Update(gameTime);
            }
            else if (TennisBall.IntersectsPixel(TennisBall.BallRectangle, TennisBall.BallTextureData, Panel2.PanelRectangle, Panel2.PanelTextureData))
            {
                TennisBall.Update(gameTime);
            }
            else if (EndBlock.IntersectsPixel(TennisBall.BallRectangle, TennisBall.BallTextureData, EndBlock.PanelRectangle, EndBlock.PanelTextureData))
            {
                TennisBall.Update(gameTime);
                finished = true;
            }
            else
            {
                TennisBall.Update(gameTime);
            }

            if (Panel1.IntersectsPixel(cursorRectangle, cursorTextureData, Panel1.PanelRectangle, Panel1.PanelTextureData) &&
                Mouse.GetState().LeftButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed && !TennisBall.started)
            {
                float x, y;
                x = Panel1.PanelPosition.X - mouse.X;
                y = Panel1.PanelPosition.Y - mouse.Y;
                Panel1.PanelPosition.X = Mouse.GetState().X + x;
                Panel1.PanelPosition.Y = Mouse.GetState().Y + y;
            }

            if (gui.Start.IntersectsPixel(cursorRectangle, cursorTextureData, gui.Start.ButtonRectangle, gui.Start.ButtonTextureData) &&
                mouse.LeftButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed)
            {
                TennisBall.started = true;
            }
            if (gui.Stop.IntersectsPixel(cursorRectangle, cursorTextureData, gui.Stop.ButtonRectangle, gui.Stop.ButtonTextureData) &&
                mouse.LeftButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed)
            {
                TennisBall.started = false;
            }
            if (gui.Hint.IntersectsPixel(cursorRectangle, cursorTextureData, gui.Hint.HRectangle, gui.Hint.HTextureData) &&
                Mouse.GetState().LeftButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed && TennisBall.started == false)
            {
                MessageBox.Show("Чтобы довести мяч до финиша используй\n" +
                                "отскок мяча от блоков. Есть только один\n" +
                                "путь до финиша!\n", "Подсказка #2", MessageBoxButtons.OK);
            }
            gui.Update(gameTime);
            Panel.Update(gameTime);
            Panel1.Update(gameTime);
            Panel2.Update(gameTime);
            EndBlock.Update(gameTime);


            mouse           = Mouse.GetState();
            cursorRectangle = new Rectangle(mouse.X - (cursorTexture.Width / 2),
                                            mouse.Y - (cursorTexture.Height / 2), cursorTexture.Width, cursorTexture.Height);
        }
Exemplo n.º 4
0
        public void Update(GameTime gameTime)
        {
            //сначала с чем сталкиваемся потом что сталкиваем
            if (TennisBall.IntersectsPixel(TennisBall.BallRectangle, TennisBall.BallTextureData, Panel.PanelRectangle, Panel.PanelTextureData))
            {
                TennisBall.Update(gameTime);
            }
            else if (TennisBall.IntersectsPixel(TennisBall.BallRectangle, TennisBall.BallTextureData, Button.PanelRectangle, Button.PanelTextureData))
            {
                TennisBall.Update(gameTime);
                Block.PanelPosition.Y -= 1000;
            }
            else if (TennisBall.IntersectsPixel(Block.PanelRectangle, Block.PanelTextureData, TennisBall.BallRectangle, TennisBall.BallTextureData))
            {
                TennisBall.Update(gameTime);
            }
            else if (EndBlock.IntersectsPixel(EndBlock.PanelRectangle, EndBlock.PanelTextureData, TennisBall.BallRectangle, TennisBall.BallTextureData))
            {
                TennisBall.Update(gameTime);
                finished = true;
            }
            else
            {
                TennisBall.Update(gameTime);
            }

            if (Button.IntersectsPixel(Button.PanelRectangle, Button.PanelTextureData, cursorRectangle, cursorTextureData) &&
                Mouse.GetState().LeftButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed && !TennisBall.started)
            {
                float x, y;
                x = Button.PanelPosition.X - mouse.X;
                y = Button.PanelPosition.Y - mouse.Y;
                Button.PanelPosition.X = Mouse.GetState().X + x;
                Button.PanelPosition.Y = Mouse.GetState().Y + y;
            }
            if (gui.Start.IntersectsPixel(cursorRectangle, cursorTextureData, gui.Start.ButtonRectangle, gui.Start.ButtonTextureData) &&
                mouse.LeftButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed)
            {
                TennisBall.started = true;
            }
            if (gui.Stop.IntersectsPixel(cursorRectangle, cursorTextureData, gui.Stop.ButtonRectangle, gui.Stop.ButtonTextureData) &&
                mouse.LeftButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed || !TennisBall.started)
            {
                TennisBall.started    = false;
                Block.PanelPosition.Y = 420;
            }
            if (gui.Hint.IntersectsPixel(cursorRectangle, cursorTextureData, gui.Hint.HRectangle, gui.Hint.HTextureData) &&
                Mouse.GetState().LeftButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed && TennisBall.started == false)
            {
                MessageBox.Show("Используй оранжевую кнопку чтобы\n" +
                                "убрать вертикальный блок и довести мяч до финиша.\n", "Подсказка #3", MessageBoxButtons.OK);
            }
            Panel.Update(gameTime);
            Button.Update(gameTime);
            Block.Update(gameTime);

            EndBlock.Update(gameTime);

            gui.Update(gameTime);
            mouse           = Mouse.GetState();
            cursorRectangle = new Rectangle(mouse.X - (cursorTexture.Width / 2),
                                            mouse.Y - (cursorTexture.Height / 2), cursorTexture.Width, cursorTexture.Height);
        }
Exemplo n.º 5
0
        public void Update(GameTime gameTime)
        {
            if (TennisBall.IntersectsPixel(TennisBall.BallRectangle, TennisBall.BallTextureData, Panel.PanelRectangle, Panel.PanelTextureData))
            {
                TennisBall.Update(gameTime);
            }
            else if (TennisBall.IntersectsPixel(TennisBall.BallRectangle, TennisBall.BallTextureData, Button.PanelRectangle, Button.PanelTextureData))
            {
                Block2.PanelPosition.Y -= 1000;
                TennisBall.Update(gameTime);
            }
            else if (TennisBall.IntersectsPixel(TennisBall.BallRectangle, TennisBall.BallTextureData, JumpButton.PanelRectangle, JumpButton.PanelTextureData))
            {
                TennisBall.BallVelocity.Y *= 2f;
                TennisBall.Update(gameTime);
            }
            else if (TennisBall.IntersectsPixel(TennisBall.BallRectangle, TennisBall.BallTextureData, Block2.PanelRectangle, Block2.PanelTextureData))
            {
                TennisBall.Update(gameTime);
            }
            else if (EndBlock.IntersectsPixel(TennisBall.BallRectangle, TennisBall.BallTextureData, EndBlock.PanelRectangle, EndBlock.PanelTextureData))
            {
                TennisBall.Update(gameTime);
                finished = true;
            }
            else
            {
                TennisBall.Update(gameTime);
            }

            if (JumpButton.IntersectsPixel(cursorRectangle, cursorTextureData, JumpButton.PanelRectangle, JumpButton.PanelTextureData) &&
                Mouse.GetState().LeftButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed && !TennisBall.started && !Button.IntersectsPixel(cursorRectangle, cursorTextureData, Button.PanelRectangle, Button.PanelTextureData))
            {
                float x, y;
                x = JumpButton.PanelPosition.X - mouse.X;
                y = JumpButton.PanelPosition.Y - mouse.Y;
                JumpButton.PanelPosition.X = Mouse.GetState().X + x;
                JumpButton.PanelPosition.Y = Mouse.GetState().Y + y;
            }
            if (Button.IntersectsPixel(cursorRectangle, cursorTextureData, Button.PanelRectangle, Button.PanelTextureData) &&
                Mouse.GetState().LeftButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed && !TennisBall.started && !JumpButton.IntersectsPixel(cursorRectangle, cursorTextureData, JumpButton.PanelRectangle, JumpButton.PanelTextureData))
            {
                float x, y;
                x = Button.PanelPosition.X - mouse.X;
                y = Button.PanelPosition.Y - mouse.Y;
                Button.PanelPosition.X = Mouse.GetState().X + x;
                Button.PanelPosition.Y = Mouse.GetState().Y + y;
            }
            if (gui.Start.IntersectsPixel(cursorRectangle, cursorTextureData, gui.Start.ButtonRectangle, gui.Start.ButtonTextureData) &&
                mouse.LeftButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed)
            {
                TennisBall.started = true;
            }
            if (gui.Stop.IntersectsPixel(cursorRectangle, cursorTextureData, gui.Stop.ButtonRectangle, gui.Stop.ButtonTextureData) &&
                mouse.LeftButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed || !TennisBall.started)
            {
                TennisBall.started     = false;
                Block2.PanelPosition.Y = 420;
            }
            if (gui.Hint.IntersectsPixel(cursorRectangle, cursorTextureData, gui.Hint.HRectangle, gui.Hint.HTextureData) &&
                Mouse.GetState().LeftButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed && TennisBall.started == false)
            {
                MessageBox.Show("Используй 2 блока для направления\n" +
                                "мяча к финишу, незабудь про поверхость пола!\n", "Подсказка #5", MessageBoxButtons.OK);
            }
            Panel.Update(gameTime);
            JumpButton.Update(gameTime);
            Block2.Update(gameTime);

            Button.Update(gameTime);

            EndBlock.Update(gameTime);

            gui.Update(gameTime);
            mouse           = Mouse.GetState();
            cursorRectangle = new Rectangle(mouse.X - (cursorTexture.Width / 2),
                                            mouse.Y - (cursorTexture.Height / 2), cursorTexture.Width, cursorTexture.Height);
        }