Exemplo n.º 1
0
 //Settings
 //ConstructorMovables
 public Game(ContentManager content)
 {
     arial = content.Load<SpriteFont>(@"arial");
        gamebg = content.Load<Texture2D>(@"images/Backgrounds/GameBG");
      StopGame = content.Load<Texture2D>(@"images/Buttons/StopGame");
      paddle = new Paddle(content);
      ball = new Ball(content, paddle);
      Tet = new Tetris(content, paddle, ball);
      StopGameRect = new Rectangle(1100, 650, StopGame.Width, StopGame.Height);
      _content = content;
 }
Exemplo n.º 2
0
        //Constructor
        public Blocks(ContentManager c, string ImageName, Color kleur, Tetris tet, Ball b)
        {
            this.content = c;
            this.blockText = content.Load<Texture2D>(@"images/Game/Tetris/" + ImageName + "/Up");
            this.blockRect = new Rectangle(150, 0, blockText.Width, blockText.Height);
            this.IName = ImageName;
            this.kleur = kleur;
            this.Side = 1;
            this.TextSide = "Up";
            this.Speed = 1;
            this.arial = content.Load<SpriteFont>("arial");
            this.tetris = tet;
            this.ball = b;

            BlockTextureData = new Color[this.blockText.Width * this.blockText.Height];
            this.blockText.GetData(BlockTextureData);
        }
Exemplo n.º 3
0
        public void Update(GameTime gt, Tetris tetris)
        {
            kState = Keyboard.GetState();
               if (Direction == 1)
               {
               ballRect.X = ballRect.X - XSpeed;
               }else{
               ballRect.X = ballRect.X + XSpeed;
               }
               if (kState.IsKeyDown(Keys.Space) && !GameStarted && tetris.TetDone)
               {
               XSpeed = 10;
               GameStarted = true;
               this.state = new Move0PercentUp(this);
               }
               if (GameStarted == true)
               {
               if (ballRect.Y <= 0)
               {
                   Side = true;
               }
               else if (ballRect.Y >= 630)
               {
                   Side = false;
               }
               if (ballRect.X + ballRect.Width >= Paddle.PaddleRect.X && ballRect.Y + ballRect.Height >= Paddle.PaddleRect.Y && ballRect.Y + ballRect.Height <= Paddle.PaddleRect.Y + Paddle.PaddleRect.Height)
               {
                    if (ballRect.Y <= Paddle.PaddleRect.Y + 10)
                    {
                        Side = false;
                        this.state = new Move10PercentUp(this);
                    }
                    else if (ballRect.Y <= Paddle.PaddleRect.Y + 20)
                    {
                        Side = false;
                        this.state = new Move20PercentUp(this);
                    }
                    else if (ballRect.Y <= Paddle.PaddleRect.Y + 30)
                    {
                        Side = false;
                        this.state = new Move30PercentUp(this);
                    }
                    else if (ballRect.Y <= Paddle.PaddleRect.Y + 40)
                    {
                        Side = false;
                        this.state = new Move40PercentUp(this);
                    }
                    else if (ballRect.Y <= Paddle.PaddleRect.Y + 50)
                    {
                        Side = false;
                        this.state = new Move50PercentUp(this);
                    }
                    else if (ballRect.Y <= Paddle.PaddleRect.Center.Y)
                    {
                        this.state = new Move0PercentUp(this);
                    }
                    else if (ballRect.Y <= Paddle.PaddleRect.Y + 70)
                    {
                        Side = true;
                        this.state = new Move60PercentUp(this);
                    }
                    else if (ballRect.Y <= Paddle.PaddleRect.Y + 80)
                    {
                        Side = true;
                        this.state = new Move70PercentUp(this);
                    }
                    else if (ballRect.Y <= Paddle.PaddleRect.Y + 90)
                    {
                        Side = true;
                        this.state = new Move80PercentUp(this);
                    }
                    else if (ballRect.Y <= Paddle.PaddleRect.Y + 100)
                    {
                        Side = true;
                        this.state = new Move90PercentUp(this);
                    }
                    else if (ballRect.Y <= Paddle.PaddleRect.Y + 110 && ballRect.Y >= Paddle.PaddleRect.Y + 100)
                    {
                        Side = true;
                        this.state = new Move100PercentUp(this);
                    }
                    //this.state = new Move0PercentUp(this);

                   Direction = 1;
               }

                  // Direction = 1;
               if (ballRect.X <= 0)
               {
                   Direction = 0;
               }

               if (ballRect.X > 1280)
               {
                   //ballRect = new Rectangle(720, 150, 15, 15);
                   tetris.ArkScore = tetris.ArkScore - 500;
                   GameStarted = false;
                   this.state = new BallStart(this, this.Paddle);
                   XSpeed = 0;
                   Direction = 1;
               }
               }

               this.state.Update(gt);
        }