Пример #1
0
        private void MainTimer_Tick(object sender, EventArgs e)
        {
            for (int k = 0; k < Races.Length; k++)
            {
                if (!Races[k].Forward(0.001f * (float)MainTimer.Interval))
                {
                    Races[k] = new Firework(new Firework.Config());
                }
            }

            Invalidate();
        }
Пример #2
0
        void MainCanvas_Draw(CanvasControl sender, CanvasDrawEventArgs args)
        {
            var ds = args.DrawingSession;

            ds.Clear(Colors.Black);

            float dt = m_stopwatch.ElapsedMilliseconds / 1000.0f;

            m_stopwatch.Restart();

            // We are abusing the Draw call as our "game loop" = create new fireworks here
            // independent of the timing of input events.
            //if (m_wasPointerPressed == true) // Disable check so we always are rendering.
            {
                for (int i = 0; i < Constants.NumPerFrame; i++)
                {
                    var firework = new Firework(
                        (float)m_pointerPos.X + RndFloat(-Constants.PosRndMax, Constants.PosRndMax),
                        (float)m_pointerPos.Y + RndFloat(-Constants.PosRndMax, Constants.PosRndMax),
                        (float)(m_pointerPos.X - m_pointerPrevPos.X) / dt * Constants.PointerVelCoeff + RndFloat(-Constants.VelRndMax, Constants.VelRndMax),
                        (float)(m_pointerPos.Y - m_pointerPrevPos.Y) / dt * Constants.PointerVelCoeff + RndFloat(-Constants.VelRndMax, Constants.VelRndMax),
                        RndFloat(Constants.RadiusMin, Constants.RadiusMax),
                        Color.FromArgb(
                            255,
                            RndByte(0, 255),
                            RndByte(0, 255),
                            RndByte(0, 255)
                            ));

                    m_controller.AddFirework(firework);
                }
            }

            m_controller.UpdateFireworks(dt);
            m_controller.RenderFireworks(ds);

            // We snap the pointer position with each Draw call, independent of the frequency of input events.
            m_pointerPrevPos = m_pointerPos;

            // Render loop.
            sender.Invalidate();
        }
Пример #3
0
 public void AddFirework(Firework f)
 {
     m_fireworks.Add(f);
 }
Пример #4
0
 public static void RemoveFirework(Firework firework)
 {
     fireworks.Remove(firework);
 }
Пример #5
0
 public void AddFirework(Firework f)
 {
     m_fireworks.Add(f);
 }
Пример #6
0
        void MainCanvas_Draw(CanvasControl sender, CanvasDrawEventArgs args)
        {
            var ds = args.DrawingSession;
            ds.Clear(Colors.Black);

            float dt = m_stopwatch.ElapsedMilliseconds / 1000.0f;
            m_stopwatch.Restart();

            // We are abusing the Draw call as our "game loop" = create new fireworks here
            // independent of the timing of input events.
            //if (m_wasPointerPressed == true) // Disable check so we always are rendering.
            {
                for (int i = 0; i < Constants.NumPerFrame; i++)
                {
                    var firework = new Firework(
                        (float)m_pointerPos.X + RndFloat(-Constants.PosRndMax, Constants.PosRndMax),
                        (float)m_pointerPos.Y + RndFloat(-Constants.PosRndMax, Constants.PosRndMax),
                        (float)(m_pointerPos.X - m_pointerPrevPos.X) / dt * Constants.PointerVelCoeff + RndFloat(-Constants.VelRndMax, Constants.VelRndMax),
                        (float)(m_pointerPos.Y - m_pointerPrevPos.Y) / dt * Constants.PointerVelCoeff + RndFloat(-Constants.VelRndMax, Constants.VelRndMax),
                        RndFloat(Constants.RadiusMin, Constants.RadiusMax),
                        Color.FromArgb(
                            255,
                            RndByte(0, 255),
                            RndByte(0, 255),
                            RndByte(0, 255)
                        ));

                    m_controller.AddFirework(firework);
                }
            }

            m_controller.UpdateFireworks(dt);
            m_controller.RenderFireworks(ds);

            // We snap the pointer position with each Draw call, independent of the frequency of input events.
            m_pointerPrevPos = m_pointerPos;

            // Render loop.
            sender.Invalidate();
        }