public GameMain() { this.LoadMap(); //// Création Joueur + Carte MyMap = new Map(1200, 480); statut_player = false; LocalJekyll = new Jekyll(50, 100); LocalHide = new Hide(50, 100); }
public GameMain() { this.LoadMap(); //// Création Joueur + Carte MyMap = new Map(5100, 1000); statut_player = false; if (!FirstGame.checkpoint) { LocalJekyll = new Jekyll(115, 500); LocalHide = new Hide(115, 500); } else { LocalJekyll = new Jekyll(FirstGame.W/2-72, 100); LocalHide = new Hide(FirstGame.W-72 / 2, 100); } MyMap.SlideY(1000-FirstGame.H+72); Status = "on"; }
public void init(ContentManager content) { XElement gameData = XElement.Load("Content/steve.xml", LoadOptions.None); /** * Load Tileset data */ addTileSets(content, gameData.Element("tilesets")); /** * Load Map and tile bounds data */ foreach (XElement map in gameData.Element("maps").Elements("map")) { Map m = new Map(); m.name = (string)map.Attribute("name"); m.tileset = (string)map.Attribute("tileset"); m.width = (int)map.Attribute("width"); m.height = (int)map.Attribute("height"); m.data = new int[m.height][]; for (int i = 0; i < m.data.Length; i++) { m.data[i] = new int[m.width]; } char[] split = new char[] {',', '\r', '\n'}; string[] values = map.Element("mapdata").Value.Split(split, StringSplitOptions.RemoveEmptyEntries); string[] bounds = map.Element("bounds").Value.Split(split, StringSplitOptions.RemoveEmptyEntries); TileSet tileset = getTileSet(m.tileset); int k = 0; for (int i = 0; i < m.height; i++) { //String dbg = ""; for (int j = 0; j < m.width; j++) { int val = Convert.ToInt32(values[k]); int bound = Convert.ToInt16(bounds[k]); tileset.bounds[val] = (TileSet.Bounds)bound; m.data[i][j] = val; k++; //dbg += val.ToString() + ", "; } //Debug.Print(dbg); } maps.Add(m); } XElement aniDataElement = XElement.Load("Content/sprites.xml", LoadOptions.None); addTileSets(content, aniDataElement.Element("tilesets")); addAnimations(content, aniDataElement.Element("animations")); }
public TileSet.Bounds getMapTileBounds(int px, int py, Map mapData, TileSet tileSet) { TileSet.Bounds bounds = TileSet.Bounds.BOUNDS_NONE; //get the tile position for the pixel coords int row, col; convertScreenPxToTile(px, py, out row, out col); row %= mapData.height; col %= mapData.width; //get the bounds for the tile int tileTypeIndex = mapData.data[row][col]; bounds = tileSet.bounds[tileTypeIndex]; return bounds; }
public int getMapDataTrueIndex(Map mapData, int screenRow, int screenCol) { int col = screenCol + tileOffset; if (col >= gameData.maps[firstMap].width) col -= gameData.maps[firstMap].width; int index = mapData.data[screenRow][col]; if (index < -1) index = 0; return index; }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> public override void Initialize(IServiceProvider services) { Content = new ContentManager(services); Content.RootDirectory = "Content"; ScreenOffset = Vector2.Zero; ScreenManager.Graphics.PreferredBackBufferWidth = Settings.SCREEN_WIDTH; ScreenManager.Graphics.PreferredBackBufferHeight = Settings.SCREEN_HEIGHT; map1 = new Map(); player = new Player(); physicsWorld = new World(new Vector2(0, ConvertUnits.ToSimUnits(600f))); //AudioManager.Instance.Initialize(ScreenManager); DebugView = new DebugViewXNA(physicsWorld); //DebugView.AppendFlags(FarseerPhysics.DebugViewFlags.PolygonPoints); //DebugView.AppendFlags(FarseerPhysics.DebugViewFlags.DebugPanel); //DebugView.AppendFlags(FarseerPhysics.DebugViewFlags.ContactPoints); //DebugView.AppendFlags(FarseerPhysics.DebugViewFlags.AABB); DebugView.DefaultShapeColor = Color.Green; DebugView.StaticShapeColor = Color.Blue; DebugView.KinematicShapeColor = Color.Brown; DebugView.SleepingShapeColor = Color.White; DebugView.InactiveShapeColor = Color.Yellow; DebugView.LoadContent(ScreenManager.Graphics.GraphicsDevice, Content); }
public GameState() { map = new Map(); }
public void Load(ContentManager Content) { map = new Map(50, 50); }