淘先锋技术网

首页 1 2 3 4 5 6 7

泰拉瑞亚(Terraria)是一款像素风格的游戏,这个游戏的源代码被称为XNA。而XL HTML则是泰拉瑞亚的源代码中一个足以引起开发者注目的部分。


public static void DrawSliced(SpriteBatch spriteBatch, Texture2D texture, Rectangle destinationRect, Rectangle sourceRect, Color color, float rotation, Vector2 origin, SpriteEffects effects, float layerDepth)
{
    int num1 = sourceRect.Width / 3;
    int num2 = sourceRect.Height / 3;
    int num3 = destinationRect.Width / 3;
    int num4 = destinationRect.Height / 3;
    int x1 = destinationRect.X;
    int x2 = x1 + num3;
    int x3 = destinationRect.Right - num1;
    int x4 = x3 + num3;
    int y1 = destinationRect.Y;
    int y2 = y1 + num4;
    int y3 = destinationRect.Bottom - num2;
    int y4 = y3 + num4;
    Rectangle rectangle1 = new Rectangle(sourceRect.X, sourceRect.Y, num1, num2);
    Rectangle rectangle2 = new Rectangle(sourceRect.X + num1, sourceRect.Y, num1, num2);
    Rectangle rectangle3 = new Rectangle(sourceRect.X + sourceRect.Width - num1, sourceRect.Y, num1, num2);
    Rectangle rectangle4 = new Rectangle(sourceRect.X, sourceRect.Y + num2, num1, num2);
    Rectangle rectangle5 = new Rectangle(sourceRect.X + num1, sourceRect.Y + num2, num1, num2);
    Rectangle rectangle6 = new Rectangle(sourceRect.X + sourceRect.Width - num1, sourceRect.Y + num2, num1, num2);
    Rectangle rectangle7 = new Rectangle(sourceRect.X, sourceRect.Y + sourceRect.Height - num2, num1, num2);
    Rectangle rectangle8 = new Rectangle(sourceRect.X + num1, sourceRect.Y + sourceRect.Height - num2, num1, num2);
    Rectangle rectangle9 = new Rectangle(sourceRect.X + sourceRect.Width - num1, sourceRect.Y + sourceRect.Height - num2, num1, num2);
    spriteBatch.Draw(texture, new Vector2(x1, y1), rectangle1, color, rotation, origin, 1f, effects, layerDepth);
    spriteBatch.Draw(texture, new Rectangle(x2, y1, num3, num2), rectangle2, color, rotation, origin, effects, layerDepth);
    spriteBatch.Draw(texture, new Vector2(x3, y1), rectangle3, color, rotation, origin, 1f, effects, layerDepth);
    spriteBatch.Draw(texture, new Rectangle(x1, y2, num1, num4), rectangle4, color, rotation, origin, effects, layerDepth);
    spriteBatch.Draw(texture, new Rectangle(x2, y2, num3, num4), rectangle5, color, rotation, origin, effects, layerDepth);
    spriteBatch.Draw(texture, new Rectangle(x3, y2, num1, num4), rectangle6, color, rotation, origin, effects, layerDepth);
    spriteBatch.Draw(texture, new Vector2(x1, y3), rectangle7, color, rotation, origin, 1f, effects, layerDepth);
    spriteBatch.Draw(texture, new Rectangle(x2, y3, num3, num2), rectangle8, color, rotation, origin, effects, layerDepth);
    spriteBatch.Draw(texture, new Vector2(x3, y3), rectangle9, color, rotation, origin, 1f, effects, layerDepth);
}

泰拉瑞亚源代码xl html

这段代码是用于绘制一个分割好的9宫格图片的方法。它会将传入的纹理截成9个部分,并按照目标矩形分别绘制。在泰拉瑞亚游戏中,这段代码被广泛使用。

总之,泰拉瑞亚的源代码中存在着很多令人震撼的部分,而XL HTML则是其中之一。开发者可以使用这些代码来构建自己的游戏,或是对泰拉瑞亚进行改进。