Exemple #1
1
 /// <summary>
 /// The main entry point for the application.
 /// </summary>
 static void Main(string[] args)
 {
     using (Game game = new Game())
     {
         game.Run();
     }
 }
Exemple #2
1
 public Form1()
 {
     InitializeComponent();
     game = new Game(15, 10,timer1);
     this.DoubleBuffered = true;
     timer1.Interval = MaxTime;
     bpf = new BestPlayersForm();
     bestPlayer = bpf.bp.getBestPlayer();
     bestScoreLbl.Text = bestPlayer.Points.ToString();
 }
Exemple #3
1
 public static Piece ExecuteCommand(Game game,char command)
 {
     command = char.ToLower(command);
     Piece result;
     switch (command)
     {
         case 'a':
             result = game.MovingPiece.MoveTowards(-1, game.Width);
             break;
         case 'd':
             result = game.MovingPiece.MoveTowards(1, game.Width);
             break;
         case 's':
             result = game.MovingPiece.MoveDown(1, game.GameField.Length);
             break;
         case 'q':
             result = game.MovingPiece.TurnLeft(game.Width, game.GameField.Length);
             break;
         default://case 'e':
             result = game.MovingPiece.TurnRight(game.Width, game.GameField.Length);
             break;
     }
     return result;
 }
Exemple #4
1
 static void Main(string[] args)
 {
     var game = new Game(args[0]);
     game.Run();
 }
 public GameOverState(Game g)
 {
     game = g;
     game.sound.GameOverSound();
 }
Exemple #6
1
 public PreGameState(Game g)
 {
     game = g;
 }
Exemple #7
1
    public void Drop(Game game)
    {
      // get coordinates
      float[] x = new float[4];
      float[] y = new float[4];

      ToCoordinates(ref x, ref y);

      for (int i = 0; i < 4; i++)
      {
        if ((x[i] < Game.Width) && (y[i] < Game.Height))
        {
          game.Block[(int)x[i], (int)(y[i])] = m_nColor;
        }
      }

      game.Score += ((24 + (3 * game.Level)) - m_nFreefalls);
      game.CheckLines();
    }
Exemple #8
1
 public Block(Game game)
 {
   m_theGame = game;
 }
Exemple #9
1
 public PausedState(Game g)
 {
     game = g;
 }
Exemple #10
1
 void StartGame(InterleavedFieldManager.NumPlayers players)
 {
     Thread thread = new Thread(new ThreadStart(delegate()
       {
     using (Game game = new Game(players))
     {
       game.Run(30.0, 60.0);
     }
       }));
       thread.Start();
 }
Exemple #11
0
    // Use this for initialization
    public void Init()
    {
        Mino.ShadowColor = ShadowColor.ToBlockColor();
        RandomItemGenerator <MinoType> queue = new RandomItemGenerator <MinoType>(Tetromino.TETROMINO_TYPES, queueSize, queueLookback, queueTries);
        BaseTetrisBoard board = Board.Controller;

        if (AIControlled)
        {
            game = new Game(TetrisAi.CurrentState, board, queue);
        }
        else
        {
            game = new Game(InputManager, board, queue);
        }
        initialized = true;
        OnEnabled();
        game.GameStart();
        game.OnDisable();
    }
Exemple #12
0
 static void Main(string[] args)
 {
     var jsonFile = File.ReadAllText("random-w100000-h5-c100000.json");
     GameInfo gameInfo = JsonConvert.DeserializeObject<GameInfo>(jsonFile);
     Game game = new Game(gameInfo.Width,gameInfo.Height,gameInfo.Pieces);
     Commands commands = new Commands(gameInfo.Commands);
     Stopwatch sw = new Stopwatch();
     sw.Start();
     while (!commands.IsFinished())
     {
         char command = commands.GetCurrentCommand();
         commands = commands.CommandExecuted();
         if (char.ToLower(command) != 'p')
         {
             game = game.MovePiece(ExecuteCommand(game,command));
             if (game.PieceFixed)
             {
                 Console.WriteLine((commands.CommandNum - 1) + " " + game.Score);
             }
         }
         else
         {
             Console.WriteLine(game.ToString());
         }
         /*if (commands.CommandNum > 425)
         {
             Console.WriteLine(commands.GetCurrentCommand());
             Console.WriteLine(game.ToString());
             Console.ReadKey();
         }*/
     }
     sw.Stop();
     Console.WriteLine(sw.ElapsedMilliseconds);
 }
Exemple #13
0
 public ActiveState(Game g)
 {
     game = g;
 }