Example #1
0
        public void Initialize(int width, int height)
        {
            renderView.ClientSize = new System.Drawing.Size(width, height);

            graphics = renderView.CreateGraphics();
            pen      = new System.Drawing.Pen(System.Drawing.Color.White);
            font     = new System.Drawing.Font("Arial", 16);
            brush    = new System.Drawing.SolidBrush(System.Drawing.Color.Black);

            deviceWidth  = width;
            deviceHeight = height;

            System.Drawing.BufferedGraphicsContext currentContext = System.Drawing.BufferedGraphicsManager.Current;
            doubleBuffer = currentContext.Allocate(graphics, new System.Drawing.Rectangle(0, 0, width, height));
        }
        public Level(System.Windows.Forms.Form p_screen)
        {
            this.v_layers = new System.Collections.Generic.List <Spartacus.Game.Layer>();

            this.v_screen = p_screen;

            this.v_context = System.Drawing.BufferedGraphicsManager.Current;
            this.v_context.MaximumBuffer = new System.Drawing.Size(this.v_screen.Width + 1, this.v_screen.Height + 1);

            this.v_bufferedgraphics = v_context.Allocate(this.v_screen.CreateGraphics(), new System.Drawing.Rectangle(0, 0, this.v_screen.Width, this.v_screen.Height));

            this.v_timer       = new System.Windows.Forms.Timer();
            this.v_timer.Tick += new System.EventHandler(this.OnTimer);

            p_screen.MouseClick += new System.Windows.Forms.MouseEventHandler(this.OnMouseClick);
        }
Example #3
0
        //Initialize
        public virtual void Initialize(System.Windows.Forms.Form form)
        {   //Windows form
            this.form = form;
            // set up graphics device
            System.Drawing.Graphics graph = form.CreateGraphics();
            graph.CompositingMode    = System.Drawing.Drawing2D.CompositingMode.SourceCopy;
            graph.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighSpeed;
            graph.InterpolationMode  = System.Drawing.Drawing2D.InterpolationMode.Low;
            graph.PixelOffsetMode    = System.Drawing.Drawing2D.PixelOffsetMode.None;
            graph.SmoothingMode      = System.Drawing.Drawing2D.SmoothingMode.HighSpeed;
            //Set up buffer
            currenContext = System.Drawing.BufferedGraphicsManager.Current;
            backBuffer    = currenContext.Allocate(graph, form.DisplayRectangle);
            backBuffer.Graphics.CompositingMode    = System.Drawing.Drawing2D.CompositingMode.SourceCopy;
            backBuffer.Graphics.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighSpeed;
            backBuffer.Graphics.InterpolationMode  = System.Drawing.Drawing2D.InterpolationMode.Low;
            backBuffer.Graphics.PixelOffsetMode    = System.Drawing.Drawing2D.PixelOffsetMode.None;
            backBuffer.Graphics.SmoothingMode      = System.Drawing.Drawing2D.SmoothingMode.HighSpeed;


            //Set frequencies based on refresh rate (60 or 30);
            if (Game.TargetElapsedTime.TotalMilliseconds > 30)
            {                                                     //30Hz
                s1p1On = 1; s1p1Off = 2; s1p2On = 2; s1p2Off = 2; //8.5Hz
                s2p1On = 2; s2p1Off = 3; s2p2On = 2; s2p2Off = 3; //6Hz
                s3p1On = 2; s3p1Off = 2; s3p2On = 2; s3p2Off = 2; //7.5Hz
                s4p1On = 2; s4p1Off = 2; s4p2On = 2; s4p2Off = 3; //6.667Hz
            }
            else
            {                                                     //60Hz
                s1p1On = 3; s1p1Off = 4; s1p2On = 3; s1p2Off = 4; //8.5Hz
                s2p1On = 5; s2p1Off = 5; s2p2On = 5; s2p2Off = 5; //6Hz
                s3p1On = 4; s3p1Off = 4; s3p2On = 4; s3p2Off = 4; //7.5Hz
                s4p1On = 4; s4p1Off = 5; s4p2On = 4; s4p2Off = 5; //6.667Hz
            }
        }