Guest User

code

a guest
Dec 26th, 2018
99
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. hier die main
  2. public static player _player = new player();
  3. public static List<char> level = new List<char>();
  4. public static void Main(string[] args)
  5. {
  6. player.init(1, 100, 10, 10, 0);
  7.  
  8. load.loadfile("level1.txt", _player);
  9.  
  10.  
  11. Console.ReadKey();
  12.  
  13.  
  14. und ja die main wurde etwas abgehakt aber egal mehr steht nämlich nicht drinn und hier die load methode
  15.  
  16. public static void loadfile(string name, player player)
  17. {
  18. //load
  19. string line;
  20. try
  21. {
  22. using (StreamReader sr = new StreamReader(name))
  23. {
  24. for (int i = 0; i < 18; i++)
  25. {
  26. line = sr.ReadLine();
  27. Program.level.Add(line);
  28. }
  29. }
  30. }
  31. catch (Exception ex)
  32. {
  33. Console.WriteLine("error cannot read file: " + name);
  34. }
  35.  
  36. //process
  37.  
  38. for(int i = 0; i < Program.level.Count(); i++)
  39. {
  40. for(int j = 0; j < Program.level[i].Length; j++)
  41. {
  42. tile = Program.level[i][j];
  43.  
  44. switch (tile)
  45. {
  46. case '@':
  47. Program._player.setpos(j, i);
  48. break;
  49. }
  50. }
  51. }
  52. }
  53.  
  54. die variable tile wird darüber erstellt eigentlich unötig weil die eh nur dadrin benutzt wird aber egal
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×