Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- hier die main
- public static player _player = new player();
- public static List<char> level = new List<char>();
- public static void Main(string[] args)
- {
- player.init(1, 100, 10, 10, 0);
- load.loadfile("level1.txt", _player);
- Console.ReadKey();
- und ja die main wurde etwas abgehakt aber egal mehr steht nämlich nicht drinn und hier die load methode
- public static void loadfile(string name, player player)
- {
- //load
- string line;
- try
- {
- using (StreamReader sr = new StreamReader(name))
- {
- for (int i = 0; i < 18; i++)
- {
- line = sr.ReadLine();
- Program.level.Add(line);
- }
- }
- }
- catch (Exception ex)
- {
- Console.WriteLine("error cannot read file: " + name);
- }
- //process
- for(int i = 0; i < Program.level.Count(); i++)
- {
- for(int j = 0; j < Program.level[i].Length; j++)
- {
- tile = Program.level[i][j];
- switch (tile)
- {
- case '@':
- Program._player.setpos(j, i);
- break;
- }
- }
- }
- }
- die variable tile wird darüber erstellt eigentlich unötig weil die eh nur dadrin benutzt wird aber egal
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement