Пример #1
0
        //Ladet alle graphicken
        private void InitializeGraphics()
        {
            //Get requested debug level
            D2D.DebugLevel debugLevel = D2D.DebugLevel.None;
            if (m_debugMode)
            {
                debugLevel = D2D.DebugLevel.Error;
            }

            //Create factory object
            m_factory = new D2D.Factory(D2D.FactoryType.SingleThreaded, debugLevel);
            //  m_factoryText = new SlimDX.DirectWrite.Factory();
            //Create the render target
            m_renderTarget = new D2D.WindowRenderTarget(m_factory, new D2D.WindowRenderTargetProperties()
            {
                Handle         = this.Handle,
                PixelSize      = this.Size,
                PresentOptions = D2D.PresentOptions.Immediately
            });

            //Create linear gradient brush
            D2D.GradientStop[] gradientStops = new D2D.GradientStop[]
            {
                new D2D.GradientStop()
                {
                    Position = 0f, Color = new Color4(Color.LightGray)
                },
                new D2D.GradientStop()
                {
                    Position = 1f, Color = new Color4(Color.Black)
                }
            };
            m_backBrushGradient = new D2D.GradientStopCollection(m_renderTarget, gradientStops);
            m_backBrushEx       = new D2D.LinearGradientBrush(
                m_renderTarget,
                m_backBrushGradient,
                new D2D.LinearGradientBrushProperties()
            {
                StartPoint = new PointF(0, this.Height),
                EndPoint   = new PointF(0, 0)
            });

            //Create gdi backbrush
            if (m_backBrushGdi != null)
            {
                m_backBrushGdi.Dispose();
            }
            m_backBrushGdi = new LinearGradientBrush(
                new Point(0, this.Height),
                new Point(0, 0),
                Color.LightGray,
                Color.LightSteelBlue);

            //Load the bitmap

            backGroundBitmap = LoadBitmap(Resources.Resource.skyline);
            groundBitmap     = LoadBitmap(Resources.Resource.ground);
            pipeLowerBitmap  = LoadBitmap(Resources.Resource.pipe_up);
            pipeUperBitmap   = LoadBitmap(Resources.Resource.pipe_down);
            birdBitmap       = LoadBitmap(Resources.Resource.bird_one);
            //Update initialization flag
            m_initialized = true;
        }
Пример #2
0
        // Ladet alle Graphischen ressoursen
        private void InitializeGraphics()
        {
            //Get requested debug level
            D2D.DebugLevel debugLevel = D2D.DebugLevel.None;
            if (m_debugMode)
            {
                debugLevel = D2D.DebugLevel.Error;
            }

            //Create factory object
            m_factory = new D2D.Factory(D2D.FactoryType.SingleThreaded, debugLevel);

            //Create the render target
            m_renderTarget = new D2D.WindowRenderTarget(m_factory, new D2D.WindowRenderTargetProperties()
            {
                Handle         = this.Handle,
                PixelSize      = this.Size,
                PresentOptions = D2D.PresentOptions.Immediately
            });

            //Create linear gradient brush
            D2D.GradientStop[] gradientStops = new D2D.GradientStop[]
            {
                new D2D.GradientStop()
                {
                    Position = 0f, Color = new Color4(Color.LightGray)
                },
                new D2D.GradientStop()
                {
                    Position = 1f, Color = new Color4(Color.Black)
                }
            };
            m_backBrushGradient = new D2D.GradientStopCollection(m_renderTarget, gradientStops);
            m_backBrushEx       = new D2D.LinearGradientBrush(
                m_renderTarget,
                m_backBrushGradient,
                new D2D.LinearGradientBrushProperties()
            {
                StartPoint = new PointF(0, this.Height),
                EndPoint   = new PointF(0, 0)
            });

            //Create gdi backbrush
            if (m_backBrushGdi != null)
            {
                m_backBrushGdi.Dispose();
            }
            m_backBrushGdi = new LinearGradientBrush(
                new Point(0, this.Height),
                new Point(0, 0),
                Color.LightGray,
                Color.LightSteelBlue);

            //Load the bitmap
            level.Backgroundgdi = Resources.Resources.SpaceBackground1;
            level.Background    = LoadBitmap(level.Backgroundgdi);

            spaceshipBitmapGDI         = Resources.Resources.GreenSpaceShip;
            spaceShipBitmap            = LoadBitmap(spaceshipBitmapGDI);
            _Player                    = new PlayerShip(spaceShipBitmap);
            projektileBitmapGdi        = Resources.Resources.greenProjectile;
            projektileBitmap           = LoadBitmap(projektileBitmapGdi);
            projektileHostileBitmapGdi = Resources.Resources.greenprojectile1;
            projektileHostileBitmap    = LoadBitmap(projektileHostileBitmapGdi);
            level.Backgroundlvl1       = LoadBitmap(Resources.Resources.SpaceBackground1);
            level.Backgroundlvl2       = LoadBitmap(Resources.Resources.sewer);
            level.BackgroundGameOver   = LoadBitmap(Resources.Resources.GameOver);
            level.BackgroundNextLevel  = LoadBitmap(Resources.Resources.NextLevel);
            enenyShipBitmap            = LoadBitmap(Resources.Resources.cartoonship_red);
            //Update initialization flag
            m_initialized = true;
        }