WorldPhysics worldPhysics = WorldPhysics.DefaultWorldPhysics; //Physics object used on this map. Attributes may be specified in the map file. #endregion Fields #region Constructors //Construct a levelstate object public LevelState(Game game, PlayerState player, string mapName) : base(game, player) { Activated += delegate { game.Display.Renderer.SetFont("verdana", 8); }; playerInfo = player; this.game = game; this.display = game.Display; this.mapName = mapName; // game.Display.CameraX = 50; //game.Display.CameraY = 100; //Load map MapDescriptor map = game.Resources.GetMapDescriptor(mapName); objectFactory = new ObjectFactory(game, this); tileMap = new TileMap(game.Display, game.Resources, map); //And set up the world physics attributes if (map.ExtraProperties.ContainsKey("gravity")) worldPhysics.Gravity = double.Parse(map.ExtraProperties["gravity"]); if (map.ExtraProperties.ContainsKey("ground-friction-factor")) worldPhysics.GroundFrictionFactor = double.Parse(map.ExtraProperties["ground-friction-factor"]); //Spawn all objects foreach (var o in map.Objects) { GameObject obj = objectFactory.Spawn(o.Name, new Vector(o.X, o.Y), new Vector(0,-100), worldPhysics); if (obj != null) { objects.Add(obj); if (o.Name == "mario") { this.player = (Player)objects[objects.Count-1]; } } } //Set the map background if (!string.IsNullOrEmpty(map.Background)) background = new ParallaxBackground(game.Resources.GetTexture(map.Background), 0.5, 0.2, game.Display); camera = new Camera(display, 0, map.Width * map.TileSize, 0, map.Height * map.TileSize); game.Audio.PlayMusic("overworld-intro", "overworld"); icons["coin"] = objectFactory.CreateIcon("coin", 0.7); //new Icon(game, Helpers. icons["mario"] = objectFactory.CreateIcon("mario-big", 0.5); //new Icon(game, marioIcon); }
//CollidableObject o1 = new CollidableObject(55, 53, new Vector(-30, -70)), o2 = new CollidableObject(-40, -30, new Vector(0, 0)); //CollidableObject o1 = new CollidableObject(-20, 25, new Vector(0, -10)), o2 = new CollidableObject(-35, -25, new Vector(0, 0)); public void Initialize(Game game) { this.game = game; tilemap = new TileMap(game.Display, game.Resources.GetTileset("grassland"), 10, 10, 10, -50, -50, 32); Log.Write("Edges: "); foreach (Edge e in tilemap.AllEdges) { Log.Write("" + e); } }