当前位置: 首页>>代码示例>>C#>>正文


C# Tile.ToBytes方法代码示例

本文整理汇总了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);
        }
开发者ID:terrabite3,项目名称:Level-Extraction,代码行数:44,代码来源:TotallyRandom.cs

示例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);
                    }

                }
        }
开发者ID:terrabite3,项目名称:Level-Extraction,代码行数:46,代码来源:LevelExtractor.cs


注:本文中的Tile.ToBytes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。