public Game() { //camera = new Camera(0, 0); //level = new Level(); //level.LoadLevel(); gameTextures = new GameTextures(); level = new Level(); entityController = EntityController.GetInstance(); }
public void LoadLevel(String lvlName) { this.LevelName = lvlName; Bitmap bmp = (Bitmap)Image.FromFile(Resources.RESOURCE_PATH + "\\src\\game\\levels\\" + lvlName + ".bmp"); levelBounds = new RectangleF(0, 0, bmp.Width * Block.WIDTH, bmp.Height * Block.HEIGHT); for (int x = 0; x < bmp.Width; x++) { for (int y = 0; y < bmp.Height; y++) { string hexColor = bmp.GetPixel(x, y).Name.ToUpper(); if (hexColor != "FFFF00FF") //Check if the pixel does not represent an empty tile (pink) { BaseEntity ent; if (hexColor == "FF5EF6FF") { ent = new FallingBlock(x * Block.WIDTH, y * Block.HEIGHT, GameTextures.IceBlock); Game.AddCollidableEntity(ent); } else if (hexColor == "FFFF2340") { ent = new BouncyBlock(x * Block.WIDTH, y * Block.HEIGHT, GameTextures.ArrowRight); Game.AddCollidableEntity(ent); } else if (hexColor == "FF000000") { ent = new Penguin(x * Block.WIDTH, y * Block.HEIGHT); Camera.GetInstance().SetActor(ent); EntityController.GetInstance().SetPuppetEntity((ControllableEntity)ent); Game.AddCollidableEntity(ent); } else if (hexColor == "FFFFFFFF") { ent = new Block(x * Block.WIDTH, y * Block.HEIGHT, GameTextures.SnowBlock); Game.AddEntity(ent); } else { ent = new Block(x * Block.WIDTH, y * Block.HEIGHT, GameTextures.UnknowEntity); Game.AddEntity(ent); } } } } }