예제 #1
0
    static void Main(string[] args) {
      var board = new Board(50);  //look at the collectable's start position

      var player = new Player(board._Size);

      //i have a strong feeling that i went too deep and overcomplicated this severly,
      //or at least in my mind i did and i psyched myself out.
      //or i justwas not finding the right thing about lists... it's possible
      //but i was looking all day trying to figure it out.
      var rnd = new Random();

      List<Collectable> collectablesList = new List<Collectable>() {
        new Collectable(board._Size, rnd),
        new Collectable(20, 20, board._Size, rnd),
        new Collectable(1, 1, board._Size, rnd),
        new Collectable(3, 3, board._Size, rnd),
        new Collectable(6, 42, board._Size, rnd),
        new Collectable(8, 8, board._Size, rnd),
        new Collectable(10, 17, board._Size, rnd),
        new Collectable(25, 37, board._Size, rnd),
        new Collectable(9, 28, board._Size, rnd),
        new Collectable(3, 19, board._Size, rnd)
      };

      var input = "";
      while (input != "q") {
        if (input == "h") {
          player.MoveLeft();
        }
        if (input == "j") {
          player.MoveDown();
        }
        if (input == "k") {
          player.MoveUp();
        }
        if (input == "l") {
          player.MoveRight();
        }

        //Im still looking at how to properly access the list by an calling it...
        //this is where i was thinking that i really overcomplicated it because
        //it should not be this difficult to call a list with variables in it
        //and it shouldn't be this difficult to find something online about it. 
        //i don't know how to call this properly - I want to call the name of the list
        //and have vars in the list follow, but I had such a hard time trying to find
        //accessors.                 
        //my thot process was to associate each variable in the collectablesList list with the same
        //properties... apparently it didn't work. 
        foreach (Collectable c in collectablesList) {
          c.Move();
          c.UpdateWithPlayer(player);
        }
        board.Draw(player, collectablesList);


        input = Console.ReadLine();
        Console.SetCursorPosition(0, Console.CursorTop - 1);
      }  // while loop for game "tick"
    } // main function