public bool TileMapCollision(int x, int y) { TiledTile t = TileCollisionLayer.GetTile(x, y); if (t == null) { return(false); } return(t.Id != 0); }
public int CellAtTileCoord(int tx, int ty) { if (tx < 0 || tx >= map.Width || ty < 0) { return(1); } if (ty >= map.Height) { return(0); } TiledTile tile = collisionLayer.GetTile(tx, ty); return(tile.Id); }
public int CellAtTileCoord(int TX, int TY) { if (TX < 0 || TX >= Map.Width || TY < 0) { return(1); } if (TY >= Map.Height) { return(0); } TiledTile Tile = CollisionLayer.GetTile(TX, TY); return(Tile.Id); }
public int CellAtTileCoord(int tx, int ty) { if (tx < 0 || tx >= map.Width || ty < 0) { return(1); } // let the player drop of the bottom of the screen (this means death) if (ty >= map.Height) { return(0); } TiledTile tile = collisionLayer.GetTile(tx, ty); return(tile.Id); }
/// <summary> /// creates a WeightedGridGraph from a TiledTileLayer. Present tile are walls and empty tiles are passable. /// </summary> /// <param name="tiledLayer">Tiled layer.</param> public AstarGridGraph(TiledTileLayer tiledLayer) { _width = tiledLayer.Width; _height = tiledLayer.Height; for (var y = 0; y < tiledLayer.TiledMap.Height; y++) { for (var x = 0; x < tiledLayer.TiledMap.Width; x++) { if (tiledLayer.GetTile(x, y) != null) { Walls.Add(new Point(x, y)); } } } }
public UnweightedGridGraph(TiledTileLayer tiledLayer) { _width = tiledLayer.Width; _height = tiledLayer.Height; _dirs = CARDINAL_DIRS; for (var y = 0; y < tiledLayer.TiledMap.Height; y++) { for (var x = 0; x < tiledLayer.TiledMap.Width; x++) { if (tiledLayer.GetTile(x, y) != null) { Walls.Add(new Point(x, y)); } } } }
/// <summary> /// This is called when the game should draw itself. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Draw(GameTime gameTime) { // Draw background GraphicsDevice.Clear(_tiledMap.BackgroundColor ?? Color.Black); _spriteBatch.Begin(); _spriteBatch.Draw(background, new Rectangle(0, 0, 800, 480), Color.White); _spriteBatch.End(); _spriteBatch.Begin(transformMatrix: _camera.GetViewMatrix()); // or you can have more control over drawing each individual layer foreach (var layer in _tiledMap.Layers) { TiledTileLayer tiledTileLayer = layer as TiledTileLayer; TiledTile t = tiledTileLayer.GetTile(0, 24); _spriteBatch.Draw(layer, _camera); } _spriteBatch.Draw(_sprite); // Draws a sprite over the cursor _spriteBatch.End(); //mainUI.Update (_spriteBatch, _world.WorldCalendar, gameTime); // var textColor = Color.White; // _spriteBatch.Begin(samplerState: SamplerState.PointClamp, blendState: BlendState.AlphaBlend); // _spriteBatch.DrawString(_bitmapFont, "WASD/Arrows: move", new Vector2(5, 32), textColor); // _spriteBatch.DrawString(_bitmapFont, "RF: zoom", new Vector2(5, 32 + _bitmapFont.LineSpacing), textColor); // _spriteBatch.DrawString(_bitmapFont, $"FPS: {_fpsCounter.AverageFramesPerSecond:0}", Vector2.One, Color.AliceBlue); // _spriteBatch.DrawString(_bitmapFont, "Tile: " + mouseOverTile.X + "," + mouseOverTile.Y, new Vector2(5, 32 + _bitmapFont.LineSpacing*2), Color.AliceBlue); // _spriteBatch.DrawString(_bitmapFont, "MouseOver: " + mouseScreenPostion.X + "," + mouseScreenPostion.Y, new Vector2(5, 32 + _bitmapFont.LineSpacing*3), Color.AliceBlue); // _spriteBatch.End(); base.Draw(gameTime); }
public override bool CheckCollision(Point startPoint) { var tile = TileCollisionLayer.GetTile(startPoint.X, startPoint.Y); return(!(tile == null || tile.Id == 0)); }