阅读391 返回首页    go iPhone_iPad_Mac_apple


使用游戏引擎实现的水波纹

asdfsadf

这是波纹的截图。 程序运行时是波动的。

代码如下:

public static void valfff()
        {
            int ScreenWidth = 800; //; Feel free to change this to see the pixel filling speed !
            int ScreenHeight = 600;
            int[] CosTable = new int[ScreenWidth * 2];
            int[] ColorTable = new int[255];
            for (int i = 0; i             {
                CosTable[i] = (int)(GSin(360 * i / 320) * 32 + 32);
            }
            GameScreen gs = new GameScreen();

            // gs.OpenWindowedScreen(hande, 0, 0, 800, 600, 0, 0, 0);

            gs.OpenFullScreen(ScreenResolution.R800X600, ScreenColorDepth.X32, "srlPlasma");
            int Wave = 0;
            do
            {
                int tc = GetTickCount();
                Wave += 6;
                Wave = (Wave > 320) ? Wave = 0 : Wave;
                Console.Write(Wave);
                if (gs.StartDrawing() != 0)
                {
                    int iBuffer = gs.DrawingBuffer();
                    int iPitch = gs.DrawingBufferPitch();
                    PixelFormat iPixelFormat = gs.DrawingBufferPixelFormat();
                    if (iPixelFormat == PixelFormat.PF32Bits_RGB)
                    {
                        for (int i = 0; i                         {

                            ColorTable[i] = i                         }
                    }
                    else
                    {
                        for (int i = 0; i                         {
                            ColorTable[i] = i;
                        }
                    }
                    for (int y = 0; y                     {
                        int pos1 = CosTable[y + Wave];

                        int loc = iBuffer + iPitch * y;

                        for (int x = 0; x                         {
                            int pos2 = (CosTable[x + Wave] + CosTable[x + y] + pos1);
                            gs.SetVideoMemory(loc, ColorTable[pos2]);
                            loc += 4;
                        }
                    }
                    gs.StopDrawing();
                }
                gs.FlipBuffers();
                Console.WriteLine(GetTickCount() - tc);

            } while (gs.KeyIsReleased(Key.Escape) == false);
            gs.Close();

        }

        public static float GSin(float angle)
        {
            return (float)Math.Sin(angle * (2 * 3.14 / 360));
        }

最后更新:2017-04-02 00:06:36

  上一篇:go ASP.NET中为DataGrid添加合计字段
  下一篇:go 利用ASP.NET的内置功能抵御Web攻击