Exemple #1
0
        public void lineColor()
        {
            this.InitSdl();

            //Random rand = new Random();
            int result = SdlGfx.lineColor(surfacePtr, 100, 200, 300, 300, 7777777);

            result = Sdl.SDL_Flip(surfacePtr);
            Thread.Sleep(sleepTime);
            Assert.AreEqual(result, 0);
            this.Quit();
        }
Exemple #2
0
        static void DoFrame()
        {
            sw.Start();

            bool hit = false;

            Voxlap.lpoint3d loc;
            Color           voxcolor;

            Voxlap.Face face;
            int         x, y;

            Voxlap.ClearRect(p1, p2);
            Voxlap.SetRectWithWoodTexture(p1, p2, Color.BurlyWood);
            if (Voxlap.Hitscan(or.ipo, or.ifo, out loc, out voxcolor, out face) == Voxlap.HitStatus.Hit)
            {
                double xdist = or.ipo.x - loc.x;
                double ydist = or.ipo.y - loc.y;
                double zdist = or.ipo.z - loc.z;
                double dist  = Math.Sqrt(xdist * xdist + ydist * ydist + zdist * zdist);
                if (dist < 40)
                {
                    p1 = new Voxlap.lpoint3d()
                    {
                        x = loc.x & 0x7ffffff8, y = loc.y & 0x7ffffff8, z = loc.z & 0x7ffffff8
                    };
                    p2 = new Voxlap.lpoint3d()
                    {
                        x = p1.x + 7, y = p1.y + 7, z = p1.z + 7
                    };
                    Voxlap.ClearRect(p1, p2);

                    Voxlap.SetRectWithWoodTexture(p1, p2, Color.BurlyWood, 200);
                }
                hit = true;
            }
            Voxlap.UpdateVxl();


            Sdl.SDL_LockSurface(g_pDisplaySurface);


            Voxlap.SetFrameBuffer(g_DisplaySurface.pixels, g_DisplaySurface.pitch, g_DisplaySurface.w, g_DisplaySurface.h);
            Voxlap.SetCamera(
                or.ipo,
                or.ist,
                or.ihe,
                or.ifo,
                g_DisplaySurface.w * .5f,
                g_DisplaySurface.h * .5f,
                g_DisplaySurface.w * .5f);
            Voxlap.Opticast();

            sw.Stop();


            Voxlap.Print(10, 10, Color.White, Color.Transparent, "x={0} y={1} z={2}", or.ipo.x, or.ipo.y, or.ipo.z);
            Voxlap.Print(10, 20, Color.White, Color.Transparent, "{0} fps", sw.ElapsedMilliseconds == 0 ? "Infinity" : (1000 / sw.ElapsedMilliseconds).ToString());
            if (hit)
            {
                Voxlap.Print(10, 30, Color.White, Color.Transparent, "HIT x={0} y={1} z={2} face={3}", loc.x, loc.y, loc.z, face);
            }
            sw.Reset();

            Sdl.SDL_UnlockSurface(g_pDisplaySurface);

            SdlGfx.lineColor(g_pDisplaySurface, SCREEN_WIDTH / 2 - 10, SCREEN_HEIGHT / 2, SCREEN_WIDTH / 2 + 10, SCREEN_HEIGHT / 2, -1);
            SdlGfx.lineColor(g_pDisplaySurface, SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2 - 10, SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2 + 10, -1);
        }