コード例 #1
0
ファイル: Entity.cs プロジェクト: yellowkills/PonyGameDev
        public Point[] NearbyCellsAABB(Tile[,] map)
        {
            int tileMapWidth = map.GetLength(1);
            int tileMapHeight = map.GetLength(0);

            List<Point> cells = new List<Point>();
            Point CELL_topleft = Map.VectorToCell(new Vector2(AABB.X - tileMapWidth, AABB.Y - Map.tileHeight));
            Point CELL_botright = Map.VectorToCell(new Vector2(AABB.X + AABB.Width + tileMapWidth,
                                                         AABB.Y + AABB.Height + Map.tileHeight));
            for (int i = CELL_topleft.Y; i <= CELL_botright.Y; i++)
                for (int j = CELL_topleft.X; j <= CELL_botright.X; j++)
                    cells.Add(new Point(j, i));

            return cells.ToArray();
        }
コード例 #2
0
ファイル: Entity.cs プロジェクト: yellowkills/PonyGameDev
        // it would be best to break this up into smaller functions
        public Point[] NearbyCells(Tile[,] map)
        {
            int tileMapWidth = map.GetLength(1);
            int tileMapHeight = map.GetLength(0);

            List<Point> cells = new List<Point>();
            Point CELL_topleft = Map.VectorToCell(new Vector2(LeftSideHigh.X - tileMapWidth, TopLeft.Y - Map.tileHeight));
            Point CELL_botright = Map.VectorToCell(new Vector2(RightSideLow.X + tileMapWidth,
                                                         BotRight.Y + Map.tileHeight));
            for (int i = CELL_topleft.Y; i <= CELL_botright.Y; i++)
                for (int j = CELL_topleft.X; j <= CELL_botright.X; j++)
                    cells.Add(new Point(j, i));

            return cells.ToArray();
        }