public Player(Game game, Vector position, Vector velocity, Dictionary<string, Sprite> sprites, string defaultSprite, IController controller, //GameObject attributes WorldPhysics worldPhysics, ObjectPhysics objectPhysics, Dictionary<string, BoundingPolygon> boundingPolygons, //PhysicalObject attributes double runSpeed, double maxSpeed, //Character attributes PlayerState state) : base(game, position, velocity, sprites, defaultSprite, controller, worldPhysics, objectPhysics, boundingPolygons, runSpeed, maxSpeed) { oldFriction = objectPhysics.Friction; PlayerState = state; invincibleTimer.Start(); }
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); }
public static void Main(string[] args) { Game game = new Game(); game.Initialize(800, 600, false, "Hiage Mario"); game.MaxFPS = 60; game.Display.Zoom = 150; //Log.OutputStreamWriter = new StreamWriter("log.txt"); PlayerState initialState = new PlayerState(); initialState.HealthStatus = PlayerState.Health.Small; game.PushState(new LevelState(game, initialState, "level1")); //game.PushState(new LevelState(null, game, "minimap")); //game.PushState(new LevelState(null, game, "test_multi")); game.Run(); }
public MarioGameState(Game game, PlayerState state) : base(game) { PlayerState = state; }