Example #1
0
        private void precipitate(string type)
        {
            int amount;
            int fallspeed;

            amount = 145;
            if (type == "Snow")
            {
                fallspeed = 2;
            }
            else
            {
                fallspeed = 4;
            }

            OuterSpace.spriteobj.Begin(SpriteFlags.AlphaBlend | SpriteFlags.SortDepthBackToFront);

            if (duration < 160)
            {
                amount   = duration;
                duration = duration - 1;
            }

            for (int i = 0; i < amount; i++)
            {
                precipitation[i].X = (float)(precipitation[i].X + (OuterSpace.moveX[102] * rnd.NextDouble() * fallspeed) + 0.5F * OuterSpace.moveX[360 - OuterSpace.TV.theta]);
                precipitation[i].Y = (float)(precipitation[i].Y + (OuterSpace.moveY[102] * rnd.NextDouble() * fallspeed) + 0.5F * OuterSpace.moveY[360 - OuterSpace.TV.theta]);

                if (precipitation[i].X > OuterSpace.ClientArea.Width - 10)
                {
                    precipitation[i].X     = 0;
                    precipitation[i].Frame = Convert.ToInt32(5 * rnd.NextDouble());
                }

                if (precipitation[i].X < 0)
                {
                    precipitation[i].X     = OuterSpace.ClientArea.Width - 10;
                    precipitation[i].Frame = Convert.ToInt32(5 * rnd.NextDouble());
                }

                if (precipitation[i].Y > OuterSpace.ClientArea.Height - 10)
                {
                    precipitation[i].Y     = 0;
                    precipitation[i].X     = Convert.ToInt32(801 * rnd.NextDouble());
                    precipitation[i].Frame = Convert.ToInt32(5 * rnd.NextDouble());
                }

                if (precipitation[i].Y < 0)
                {
                    precipitation[i].Y     = OuterSpace.ClientArea.Height - 10;
                    precipitation[i].Frame = Convert.ToInt32(5 * rnd.NextDouble());
                }

                if (type == "Snow")
                {
                    snowSprite.Draw((int)precipitation[i].X, (int)precipitation[i].Y, snowSprite.sourceFrame[precipitation[i].Frame], 0, Color.FromArgb(150, 255, 255, 255));
                }
                else
                {
                    rainSprite.Draw((int)precipitation[i].X, (int)precipitation[i].Y, rainSprite.sourceFrame[0], 0, Color.FromArgb(150, 255, 255, 255));
                }
            }

            OuterSpace.spriteobj.Flush();
            OuterSpace.spriteobj.End();
        }
Example #2
0
        //draw
        public void RenderTitleScreen()
        {
            Mesh            moMesh;
            List <Material> moMaterials = new List <Material>();
            List <Texture>  moTextures  = new List <Texture>();
            int             iTime       = Environment.TickCount % 100000;
            Rectangle       Rect        = new Rectangle(0, 0, 1024, 768);
            float           ratioX;
            float           ratioY;

            if (!bStarted)
            {
                return;
            }

            // draw background
            OuterSpace.spriteobj.Begin(SpriteFlags.AlphaBlend | SpriteFlags.SortDepthBackToFront);

            ratioX = OuterSpace.ClientArea.Width / bgSprite.spritewidth;
            ratioY = ratioX;
            bgSprite.Draw(0, 0, Rect, 0, ratioX, ratioY, Color.White);

            OuterSpace.spriteobj.Flush();
            OuterSpace.spriteobj.End();

            // draw planet
            fAngle -= 0.001f;

            //OuterSpace.d3d_scene.transformview_projection()
            OuterSpace.device.Lights[0].Type      = LightType.Directional;
            OuterSpace.device.Lights[0].Diffuse   = Color.Azure;
            OuterSpace.device.Lights[0].Direction = new Vector3(-0.5f, -0.25f, -0.1f);
            OuterSpace.device.Lights[0].Update();
            OuterSpace.device.Lights[0].Enabled = true;
            //turn it on

            OuterSpace.device.RenderState.ZBufferEnable = true;
            OuterSpace.device.RenderState.CullMode      = Cull.Clockwise;

            moMesh      = RotatingPlanetMesh.GetMesh();
            moMaterials = RotatingPlanetMesh.GetMeshMaterials();
            moTextures  = RotatingPlanetMesh.GetTextures();

            float yaw   = (float)((fAngle / Math.PI) * -1.0F);
            float pitch = -0.5f;
            //(fAngle / Math.PI * 2.0F)
            float Roll = 0f;

            //(fAngle / Math.PI / 4.0F)

            try
            {
                OuterSpace.d3d_scene.transformWorld(Matrix.RotationX(pitch), Matrix.RotationY(yaw), Matrix.RotationZ(Roll), Matrix.Zero, Matrix.Translation(-1f, -0.75f, -196.5f));
                //OuterSpace.device.Transform.World = Matrix.Multiply(Matrix.RotationYawPitchRoll(yaw, pitch, Roll), _
                // Matrix.Translation(-1.0F, -0.75F, -196.5F))

                OuterSpace.d3d_scene.transformView_Projection();
                OuterSpace.d3d_scene.transform_Pipeline();

                for (int x = 0; x < RotatingPlanetMesh.GetNumMeshMaterials(); x++)
                {
                    OuterSpace.device.Material = moMaterials[x];
                    OuterSpace.device.SetTexture(0, moTextures[x]);
                    moMesh.DrawSubset(x);
                }
            }
            catch (Microsoft.DirectX.Direct3D.Direct3DXException ex)
            {
                MessageBox.Show(ex.Message);
            }

            OuterSpace.spriteobj.Begin(SpriteFlags.AlphaBlend | SpriteFlags.SortDepthBackToFront);

            ratioX = OuterSpace.ClientArea.Width / fgSprite.spritewidth;
            ratioY = ratioX;
            fgSprite.Draw(0, 0, new Rectangle(0, 0, 1024, 256), 0, ratioX, ratioY, Color.White);

            OuterSpace.spriteobj.Flush();
            OuterSpace.spriteobj.End();
        }
        private void drawScaleLines()
        {
            int x;
            int x1;
            int y;
            int y1;

            //Draw the scale lines.
            //Verticle first, then horizontal.
            aLine.Width       = 1;
            aLineVectors[0].X = mapArea[0].X;
            aLineVectors[0].Y = mapArea[0].Y;
            aLineVectors[1].Y = mapArea[1].Y;
            aLineVectors[1].X = mapArea[0].X;
            aLine.Draw(aLineVectors, Color.White);

            aLineVectors[0].Y = mapArea[1].Y;
            aLineVectors[1].X = mapArea[1].X;
            aLine.Draw(aLineVectors, Color.White);

            // Draw the horozontal hash marks
            for (y = 0; y <= 249; y += 50)
            {
                aLineVectors[0].X = mapArea[0].X;
                aLineVectors[0].Y = MathFunctions.scaleValue(y, 250, 0, mapArea[1].Y, mapArea[0].Y);
                aLineVectors[1].Y = aLineVectors[0].Y;
                aLineVectors[1].X = mapArea[0].X + 20;
                aLine.Draw(aLineVectors, Color.Red);

                // Biggers ones every 50
                for (y1 = 0; y1 <= 50; y1 += 10)
                {
                    aLineVectors[0].X = mapArea[0].X;
                    aLineVectors[0].Y = MathFunctions.scaleValue(y + y1, 250, 0, mapArea[1].Y, mapArea[0].Y);
                    aLineVectors[1].Y = aLineVectors[0].Y;
                    aLineVectors[1].X = mapArea[0].X + 9;
                    aLine.Draw(aLineVectors, Color.White);
                    //Smaller ones every 10
                }
            }

            // Draw the verticle hash marks
            for (x = 0; x <= 249; x += 50)
            {
                aLineVectors[0].Y = mapArea[1].Y;
                aLineVectors[0].X = MathFunctions.scaleValue(x, 250, 0, mapArea[1].X, mapArea[0].X);
                aLineVectors[1].Y = mapArea[1].Y - 20;
                aLineVectors[1].X = aLineVectors[0].X;
                aLine.Draw(aLineVectors, Color.Red);

                for (x1 = 0; x1 <= 50; x1 += 10)
                {
                    aLineVectors[0].Y = mapArea[1].Y;
                    aLineVectors[0].X = MathFunctions.scaleValue(x + x1, 250, 0, mapArea[1].X, mapArea[0].X);
                    aLineVectors[1].Y = mapArea[1].Y - 9;
                    aLineVectors[1].X = aLineVectors[0].X;
                    aLine.Draw(aLineVectors, Color.White);
                }
            }

            resizeButton.Draw(mapArea[0].X, mapArea[1].Y, resizeButton.sourceFrame[0], 0, resizeButtonColor);
        }