Beispiel #1
0
    public GameWorld(int width, int height, ContentManager Content)
    {
        screenWidth = width;
        screenHeight = height;
        random = new Random();
        gameState = GameState.Menu;
        inputHelper = new InputHelper();
        block = Content.Load<Texture2D>("block");
        reset = Content.Load<Texture2D>("reset");
        font = Content.Load<SpriteFont>("SpelFont");
        font2 = Content.Load<SpriteFont>("SpriteFont1");
        font3 = Content.Load<SpriteFont>("SpriteFont2");
        playButton = Content.Load<Texture2D>("Play");
        optionsButton = Content.Load<Texture2D>("Options");
        backButton = Content.Load<Texture2D>("Back");
        polytris = Content.Load<Texture2D>("Polytris");
        grid = new TetrisGrid(block);
        level = 1;
        levelspeed = 1;
        score = 0;
        i = (int)random.Next(7) + 1;
        i2 = (int)random.Next(7) + 1;
        blockcounter = 1;

        blocks = new BlockList(block, Content);          //Voegen de verschillende blockobjecten toe aan de lijst
        block1 = new Block1(block, Content);
        blocks.Add(block1, 1);
        block2 = new Block2(block, Content);
        blocks.Add(block2, 2);
        block3 = new Block3(block, Content);
        blocks.Add(block3, 3);
        block4 = new Block4(block, Content);
        blocks.Add(block4, 4);
        block5 = new Block5(block, Content);
        blocks.Add(block5, 5);
        block6 = new Block6(block, Content);
        blocks.Add(block6, 6);
        block7 = new Block7(block, Content);
        blocks.Add(block7, 7);

        //Voegen de verschillende blockobjecten toe aan een tweede lijst voor het tekenen van het volgende blokje
        block1res = new Block1(block, Content);
        blocks.AddToReserve(block1res, 1);
        block2res = new Block2(block, Content);
        blocks.AddToReserve(block2res, 2);
        block3res = new Block3(block, Content);
        blocks.AddToReserve(block3res, 3);
        block4res = new Block4(block, Content);
        blocks.AddToReserve(block4res, 4);
        block5res = new Block5(block, Content);
        blocks.AddToReserve(block5res, 5);
        block6res = new Block6(block, Content);
        blocks.AddToReserve(block6res, 6);
        block7res = new Block7(block, Content);
        blocks.AddToReserve(block7res, 7);

        options = new Options(block, reset, backButton, width, height, font, blocks);
        menu = new Menu(playButton, optionsButton, polytris, width, height);
        gameOver = new GameOver(backButton, width, height);
    }
Beispiel #2
0
 void HideBlock()
 {
     Block1.Hide();
     Block2.Hide();
     Block3.Hide();
     Block4.Hide();
     Block5.Hide();
     Block6.Hide();
     Block7.Hide();
     Block8.Hide();
     Block9.Hide();
     Block10.Hide();
 }
Beispiel #3
0
 public int[,] createBlock()
 {
     if (r.Next(7) == 0)
     {
         Block1 newArray = new Block1();
         currentBlock = newArray.getArray();
         currentColor = Color.Cyan;
     }
     else if (r.Next(7) == 1)
     {
         Block2 newArray = new Block2();
         currentBlock = newArray.getArray();
         currentColor = Color.CornflowerBlue;
     }
     else if (r.Next(7) == 2)
     {
         Block3 newArray = new Block3();
         currentBlock = newArray.getArray();
         currentColor = Color.Orange;
     }
     else if (r.Next(7) == 3)
     {
         Block4 newArray = new Block4();
         currentBlock = newArray.getArray();
         currentColor = Color.Yellow;
     }
     else if (r.Next(7) == 4)
     {
         Block5 newArray = new Block5();
         currentBlock = newArray.getArray();
         currentColor = Color.LimeGreen;
     }
     else if (r.Next(7) == 5)
     {
         Block6 newArray = new Block6();
         currentBlock = newArray.getArray();
         currentColor = Color.Purple;
     }
     else
     {
         Block7 newArray = new Block7();
         currentBlock = newArray.getArray();
         currentColor = Color.Red;
     }
     return(currentBlock);
 }