Advertisement
Guest User

duda1

a guest
Apr 5th, 2020
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.77 KB | None | 0 0
  1.         public FormGame()
  2.         {
  3.             InitializeComponent();
  4.             StreamReader sr = new StreamReader("nivel1.txt");
  5.             while (!sr.EndOfStream)
  6.             {
  7.  
  8.                 tbGame.Text += sr.ReadToEnd();
  9.             }
  10.             sr.Close();
  11.            
  12.             loadMap2();
  13.             loadMap();
  14.             sr.Close();
  15.         }
  16.    
  17.         public void loadPlayers()
  18.         {
  19.            
  20.  
  21.             map[x, y] = '!'; //Player 2,2
  22.             map[x, y] = 'X'; //Monster1Lvl1 5,2
  23.             map[x, y] = 'X'; //Monster2Lvl1 14,10
  24.             map[x, y] = 'X'; //Monster3Lvl1 30,18
  25.            
  26.            
  27.         }
  28.            
  29.         public void loadMap()
  30.         {
  31.             tbGame.Text = "";
  32.             for (int i = 0; i < 44; i++)
  33.             {
  34.                 for (int j = 0; j < 20; j++)
  35.                 {
  36.                     tbGame.Text += map [i, j];
  37.                  
  38.                 }
  39.                 tbGame.Text += "\r\n";
  40.             }
  41.         }
  42.         public void loadMap2()
  43.         {
  44.             for (int i = 0; i < 44; i++)
  45.             {
  46.                 for (int j = 0; j < 20; j++)
  47.                 {
  48.                     map[i, j] = ' ';
  49.  
  50.                 }
  51.                
  52.             }
  53.         }
  54.  if (e.KeyCode == Keys.Space || e.KeyCode == Keys.Up || e.KeyCode == Keys.Down || e.KeyCode == Keys.Left || e.KeyCode == Keys.Right)
  55.             {
  56.                 if (e.KeyCode == Keys.Up)
  57.                 {
  58.                     //Aqui le doy la posicion inicial al Jugador y despues dependiendo de la tecla se movieria
  59.                     int x = 2;
  60.                     int y = 2;
  61.                     map[x, y] = ' ';
  62.                     y += 1;
  63.                     map[x, y] = '!';
  64.                     loadMap();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement