本文整理汇总了C#中Tile.ToBytes方法的典型用法代码示例。如果您正苦于以下问题:C# Tile.ToBytes方法的具体用法?C# Tile.ToBytes怎么用?C# Tile.ToBytes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tile
的用法示例。
在下文中一共展示了Tile.ToBytes方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main(string[] args)
{
Random rand = new Random();
List<Tile> tiles = new List<Tile>();
int prevX = 0;
while (true)
{
float[] vector = new float[114];
for (int j = 0; j < 114; j++)
{
vector[j] = (float)rand.NextDouble();
}
vector[0] *= tiles.Count / 50;
vector[1] *= 0.65f;
Tile t = new Tile(vector);
t.PageFlag = (t.X < prevX);
prevX = t.X;
tiles.Add(t);
if (t.End)
break;
}
byte[] rom = File.ReadAllBytes(ROM_PATH);
int romPointer = LevelExtractor.LEVELS[0];
foreach (Tile t in tiles)
{
ushort tileBytes = t.ToBytes();
byte b0 = (byte)(tileBytes >> 8);
byte b1 = (byte)(tileBytes & 0xFF);
byte rom0 = rom[romPointer];
byte rom1 = rom[romPointer + 1];
rom[romPointer++] = b0;
if (t.End)
break;
rom[romPointer++] = b1;
}
string outFileName = "totallyRandom.nes";
File.WriteAllBytes(outFileName, rom);
}
示例2: Main
static void Main(string[] args)
{
byte[] rom = File.ReadAllBytes(ROM_PATH);
List<Tile> tiles = new List<Tile>();
using (StreamWriter outfile = new StreamWriter(VECTOR_FILE_PATH))
for (int level = 0; level < LEVELS.Length; level++)
{
Tile t = null;
for (int i = LEVELS[level]; (t == null) || (!t.End); i += 2)
{
byte rom_0 = rom[i];
byte rom_1 = rom[i + 1];
t = new Tile(rom_0, rom_1);
string word = t.ToWord();
outfile.WriteLine(word);
Tile recreated = new Tile(word);
if (t.ToString() != recreated.ToString())
{
throw new Exception("Recreated tile failed to match!");
}
ushort recreatedBytes = recreated.ToBytes();
byte byte0 = (byte)((recreatedBytes & 0xFF00) >> 8);
byte byte1 = (byte)(recreatedBytes & 0xFF);
if (rom_0 != byte0)
{
//throw new Exception("Recreated bytes failed to match!");
Debugger.Break();
}
if (!recreated.End &&
rom_1 != byte1)
{
//throw new Exception("Recreated bytes failed to match!");
Debugger.Break();
}
tiles.Add(t);
}
}
}