我有一个XNA
程序可以绘制纹理的字段(50x50)
绘图的代码如下所示:
namespace Village
{
public class DrawLogic
{
internal static void DrawCreatures(GameTime gameTime, GraphicsDevice graphicsDevice, SpriteBatch spriteBatch, Dictionary<string, Texture2D> creatureTextures, List<Creature> list, Coordinate current)
{
spriteBatch.Begin();
foreach (var item in list)
{
Vector2 origin = new Vector2(0, 0);
if (item.Selected)
{
spriteBatch.Draw(creatureTextures["selected"], new Vector2((item.Coordinates.X * 32) - current.X, (item.Coordinates.Y * 32) - current.Y), new Rectangle(0, 0, creatureTextures["human"].Width, creatureTextures["human"].Height), Color.White, 0.0f, origin, 1f, SpriteEffects.None, 1f);
}
else
{
spriteBatch.Draw(creatureTextures["human"], new Vector2((item.Coordinates.X * 32) - current.X, (item.Coordinates.Y * 32) - current.Y), new Rectangle(0, 0, creatureTextures["human"].Width, creatureTextures["human"].Height), Color.White, 0.0f, origin, 1f, SpriteEffects.None, 1f);
}
}
spriteBatch.End();
}
internal static void DrawObjects(GameTime gameTime, GraphicsDevice graphicsDevice, SpriteBatch spriteBatch, Dictionary<string, Texture2D> creatureTextures, List<IHarvestable> list, Coordinate current)
{
spriteBatch.Begin();
foreach (var item in list)
{
Vector2 origin = new Vector2(0, 0);
spriteBatch.Draw(creatureTextures["tree"], new Vector2((item.Coordinates.X * 32) - current.X, (item.Coordinates.Y * 32) - current.Y), new Rectangle(0, 0, creatureTextures["tree"].Width, creatureTextures["tree"].Height), Color.White, 0.0f, origin, 1f, SpriteEffects.None, 1f);
}
spriteBatch.End();
}
internal static void DrawMap(GameTime gameTime, GraphicsDevice graphicsDevice, SpriteBatch spriteBatch, Dictionary<string, Texture2D> worldTextures, Block[,] map, Coordinate current)
{
spriteBatch.Begin();
for (int i = 0; i < map.GetLength(0); i++)
{
for (int j = 0; j < map.GetLength(1); j++)
{
if (map[i, j].GetType() == typeof(Grass))
{
Vector2 origin = new Vector2(0, 0);
spriteBatch.Draw(worldTextures["grass"], new Vector2((i * 32) - current.X, (j * 32) - current.Y), new Rectangle(0, 0, worldTextures["grass"].Width, worldTextures["grass"].Height), Color.White, 0.0f, origin, 1.0f, SpriteEffects.None, 1f);
}
}
}
spriteBatch.End();
}
}
}
我现在的问题是,我怎样才能旋转整个地图?
它应该是这样的:
我不知道这样做的最佳方法是什么。
我应该旋转我的每个纹理并将它们按正确的顺序放置,还是有办法旋转整个关卡?
我认为如果我可以旋转整个关卡,我的生物的行走算法会更容易,因为它与我当前的算法没有什么不同。
另一种方式(旋转每一个纹理)会更难......我想。
提前致谢!