public Game(int screenw, int screenh) { this.screenW = screenw; this.screenH = screenh; currentLevel = new LevelParser(this).constructLevel("level1.lvl"); gameObjects = new GameObject[] { new Player(), new Crosshair(), currentLevel }; createVBO(); createShaders(); }
private Level parseLevel(String path) { Level level = new Level(); String[] lines = System.IO.File.ReadAllLines(path); foreach (string line in lines) { string trimmed = line.Trim(); if (trimmed.StartsWith("G")) { string[] args = trimmed.Split(' '); Rectangle rect = new Rectangle(-(game.screenW/2) + int.Parse(args[1]), -(game.screenH/2) + int.Parse(args[2]), int.Parse(args[3]), int.Parse(args[4])); level.addRectangle(rect); } } level.makeVertices(); return level; }