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

简介: <p><a href="http://p.blog.csdn.net/images/p_blog_csdn_net/mysticboy/462983/o_asdfsadf.png"><img style="border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0p

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

目录
相关文章
|
图形学
Unity小游戏——迷你拼图
Unity小游戏——迷你拼图
308 1
|
API 图形学 C++
【Unity趣味编程】——c++实现小球的自由移动
【Unity趣味编程】——c++实现小球的自由移动
147 0
|
C#
silverlight,WPF动画终极攻略之会飞的小鸟篇(Blend 4开发)
原文:silverlight,WPF动画终极攻略之会飞的小鸟篇(Blend 4开发) 本教程基本涵盖了WPF和silverlight中的各种动画。先上张效果图。 声明下,这个做的不是让大家照搬的,只是让大家熟悉下动画效果,这个成品基本涵盖了sl里面所有的动画效果。
1414 0
|
容器
Silverlight & Blend动画设计系列五:故事板(StoryBoards)和动画(Animations)
原文:Silverlight & Blend动画设计系列五:故事板(StoryBoards)和动画(Animations)   正如你所看到的,Blend是一个非常强大的节约时间的设计工具,在Blend下能够设计出很多满意的动画作品,或许他具体是怎么实现的,通过什么方式实现的我们还是一无所知。
957 0
|
前端开发 C#
silverlight,WPF动画终极攻略之白云飘,坐车去旅游篇(Blend 4开发)
原文:silverlight,WPF动画终极攻略之白云飘,坐车去旅游篇(Blend 4开发) 这章有点长,所以我分成了两章。这一章主要是准备工作,差不多算美工篇吧,这章基本不会介绍多少动画效果,主要讲的是blend中工具的使用,利用哪些工具做出哪些效果。
1270 0
|
容器
Silverlight & Blend动画设计系列二:旋转动画(RotateTransform)
原文:Silverlight & Blend动画设计系列二:旋转动画(RotateTransform)   Silverlight的基础动画包括偏移、旋转、缩放、倾斜和翻转动画,这些基础动画毫无疑问是在Silverlight中使用得最多的动画效果,其使用也是非常简单的。
1037 0