Esempio n. 1
0
 // closes all extra threads when the window closes
 public void stopGame()
 {
     gEngine.stop();
     Level1.stop();
 }
Esempio n. 2
0
        public static void initLevel()
        {
            int    gencycle       = 4;
            int    waterlevel     = 6;
            int    gencycleswitch = 1;
            Random Rnd            = new Random();
            int    rnd;
            int    rnd2;

            for (int x = 0; x < Game.LEVEL_WIDTH; x++)
            {
                rnd = Rnd.Next(-1, 3);

                if (gencycle <= 6)
                {
                    gencycleswitch = 1;
                }
                if (gencycle >= 12)
                {
                    gencycleswitch = 2;
                }
                if (gencycleswitch == 1)
                {
                    gencycle += rnd;
                }
                else
                {
                    gencycle -= rnd;
                }
                if (gencycle < 2)
                {
                    gencycle = 2;
                }

                for (int y = 0; y < Game.LEVEL_HEIGHT; y++)
                {
                    rnd2 = Rnd.Next(0, 10);

                    if (y == Game.LEVEL_HEIGHT - gencycle) //Create Grass
                    {
                        if (x == Game.PlayerX)
                        {
                            Game.PlayerY = y - 1;
                        }
                        Game.GameGrid[x, y] = 1;
                    }
                    else if (y > Game.LEVEL_HEIGHT - gencycle) // Create Dirt
                    {
                        Game.GameGrid[x, y] = 5;
                    }
                    else
                    {
                        Game.GameGrid[x, y] = 0;                         // Create Air
                    }
                    if (y > Game.LEVEL_HEIGHT - (gencycle) && rnd2 == 5) // Create Gravel
                    {
                        Game.GameGrid[x, y] = 4;
                    }
                    else if (y > Game.LEVEL_HEIGHT - waterlevel && Game.GameGrid[x, y] == 0)  // Create Water
                    {
                        Game.GameGrid[x, y] = 6;
                    }

                    if (y == Game.LEVEL_HEIGHT - 1)
                    {
                        Game.GameGrid[x, y] = 3;
                    }
                    if (y == 0)
                    {
                        Game.GameGrid[x, y] = 3;
                    }
                    if (x == Game.LEVEL_WIDTH - 1)
                    {
                        Game.GameGrid[x, y] = 3;
                    }
                    if (x == 0)
                    {
                        Game.GameGrid[x, y] = 3;
                    }
                }
            }
            //Game.GameGrid[Game.PlayerX, Game.PlayerY] = 2;

            Level1.MainLoop();

            /*
             * for (int x = 0; x < Game.LEVEL_WIDTH; x++)
             * {
             *  for (int y = 0; y < Game.LEVEL_HEIGHT; y++)
             *  {
             *      if (y >= 11)
             *      {
             *          blocks[x, y] = TextureID.dirt;
             *      }
             *      else if (y == 9 && x == 10)
             *      {
             *          blocks[x, y] = TextureID.Player;
             *      }
             *      else if (y == 1 && x == 1)
             *      {
             *          blocks[x, y] = TextureID.dirt;
             *      }
             *      else if (y == 0 && x == 2)
             *      {
             *          blocks[x, y] = TextureID.dirt;
             *      }
             *      else if (y == 2 && x == 0)
             *      {
             *          blocks[x, y] = TextureID.dirt;
             *      }
             *      else
             *      {
             *          blocks[x, y] = TextureID.air;
             *      }
             *  }
             * }
             */
        }