Exemple #1
0
        public override void Draw(/*SpriteBatch spriteBatch*/)
        {
            // make the size of the black hole pulsate
            float scale = 1 + 0.1f * (float)Math.Sin(10 * GameRoot.ElapsedTime);

            CustomRenderer.Draw(image, Position, color, Orientation, Size / 2f, scale, 0);
        }
Exemple #2
0
        public override void Start()
        {
            Art.Load();

            var   graphics = AtomicNET.GetSubsystem <Graphics>();
            float width    = graphics.Width;
            float height   = graphics.Height;

            ScreenSize   = new Vector2(width, height);
            ScreenBounds = new IntRect(0, 0, (int)ScreenSize.X, (int)ScreenSize.Y);

            var renderer = AtomicNET.GetSubsystem <Renderer>();
            var viewport = renderer.GetViewport(0);

            renderer.HDRRendering = true;

            var cache      = GetSubsystem <ResourceCache>();
            var renderpath = viewport.GetRenderPath().Clone();

            renderpath.Append(cache.GetResource <XMLFile>("RenderPath/BloomHDR.xml"));
            renderpath.Append(cache.GetResource <XMLFile>("RenderPath/Blur.xml"));
            viewport.SetRenderPath(renderpath);

            Scene = new Scene();
            Scene.CreateComponent <Octree>();

            var camera = Scene.CreateChild("Camera").CreateComponent <Camera>();

            camera.Node.Position = new Vector3(width / 2.0f, height / 2.0f, 0.0f);
            camera.Orthographic  = true;
            camera.OrthoSize     = height;

            viewport.Scene  = Scene;
            viewport.Camera = camera;

            CustomRenderer.Initialize();

            ParticleManager = new ParticleManager <ParticleState>(1024 * 20, ParticleState.UpdateParticle);

#if ATOMIC_DESKTOP
            const int maxGridPoints = 1600;
#else
            const int maxGridPoints = 400;
#endif

            float   amt         = (float)Math.Sqrt(ScreenBounds.Width * ScreenBounds.Height / maxGridPoints);
            Vector2 gridSpacing = new Vector2(amt, amt);

            IntRect expandedBounds = ScreenBounds;
            expandedBounds.Inflate((int)gridSpacing.X, (int)gridSpacing.Y);
            Grid = new Grid(expandedBounds, gridSpacing);

            EntityManager.Add(PlayerShip.Instance);

            SubscribeToEvent("Update", HandleUpdate);
            SubscribeToEvent("RenderPathEvent", HandleRenderPathEvent);
        }
        /// <summary>
        /// Draw the particles.
        /// </summary>
        public void Draw(/*SpriteBatch spriteBatch*/)
        {
            for (int i = 0; i < particleList.Count; i++)
            {
                var particle = particleList[i];

                Vector2 origin = new Vector2(particle.Texture.Width / 2, particle.Texture.Height / 2);
                CustomRenderer.Draw(particle.Texture, particle.Position, particle.Tint, particle.Orientation, origin, particle.Scale, 0);
            }
        }
Exemple #4
0
        public override void Draw(/*SpriteBatch spriteBatch*/)
        {
            if (timeUntilStart > 0)
            {
                // Draw an expanding, fading-out version of the sprite as part of the spawn-in effect.
                float factor = timeUntilStart / 60f;    // decreases from 1 to 0 as the enemy spawns in
                CustomRenderer.Draw(image, Position, Color.White * factor, Orientation, Size / 2f, 2 - factor, 0);
            }

            base.Draw();
        }
Exemple #5
0
        void HandleRenderPathEvent(uint eventType, ScriptVariantMap eventData)
        {
            if (eventData.GetString("name") != "customrender")
            {
                return;
            }

            CustomRenderer.Begin();

            Draw();

            CustomRenderer.End();
        }
Exemple #6
0
 public virtual void Draw(/*SpriteBatch spriteBatch*/)
 {
     CustomRenderer.Draw(image, Position, color, Orientation, Size / 2, 1.0f, 0);
     //spriteBatch.Draw(image, Position, null, color, Orientation, Size / 2f, 1f, 0, 0);
 }
Exemple #7
0
        public void Draw(/*SpriteBatch spriteBatch*/)
        {
            screenSize = GameRoot.ScreenSize;

            int   width  = points.GetLength(0);
            int   height = points.GetLength(1);
            Color color  = new Color(30 / 255.0f, 30 / 255.0f, 139 / 255.0f, 100 / 255.0f); // dark blue

            for (int y = 1; y < height; y++)
            {
                for (int x = 1; x < width; x++)
                {
                    Vector2 left = new Vector2(), up = new Vector2();
                    Vector2 p = ToVec2(points[x, y].Position);
                    if (x > 1)
                    {
                        left = ToVec2(points[x - 1, y].Position);
                        float thickness = y % 3 == 1 ? 3f : 1f;

                        // use Catmull-Rom interpolation to help smooth bends in the grid
                        int     clampedX = Math.Min(x + 1, width - 1);
                        Vector2 mid      = Vector2.CatmullRom(ToVec2(points[x - 2, y].Position), left, p, ToVec2(points[clampedX, y].Position), 0.5f);

                        // If the grid is very straight here, draw a single straight line. Otherwise, draw lines to our
                        // new interpolated midpoint
                        if (Vector2.DistanceSquared(mid, (left + p) / 2) > 1)
                        {
                            CustomRenderer.DrawLine(left, mid, color, thickness);
                            CustomRenderer.DrawLine(mid, p, color, thickness);
                        }
                        else
                        {
                            CustomRenderer.DrawLine(left, p, color, thickness);
                        }
                    }
                    if (y > 1)
                    {
                        up = ToVec2(points[x, y - 1].Position);
                        float   thickness = x % 3 == 1 ? 3f : 1f;
                        int     clampedY  = Math.Min(y + 1, height - 1);
                        Vector2 mid       = Vector2.CatmullRom(ToVec2(points[x, y - 2].Position), up, p, ToVec2(points[x, clampedY].Position), 0.5f);

                        if (Vector2.DistanceSquared(mid, (up + p) / 2) > 1)
                        {
                            CustomRenderer.DrawLine(up, mid, color, thickness);
                            CustomRenderer.DrawLine(mid, p, color, thickness);
                        }
                        else
                        {
                            CustomRenderer.DrawLine(up, p, color, thickness);
                        }
                    }

                    // Add interpolated lines halfway between our point masses. This makes the grid look
                    // denser without the cost of simulating more springs and point masses.
                    if (x > 1 && y > 1)
                    {
                        Vector2 upLeft = ToVec2(points[x - 1, y - 1].Position);
                        CustomRenderer.DrawLine(0.5f * (upLeft + up), 0.5f * (left + p), color, 1f);   // vertical line
                        CustomRenderer.DrawLine(0.5f * (upLeft + left), 0.5f * (up + p), color, 1f);   // horizontal line
                    }
                }
            }
        }