Exemplo n.º 1
0
        private void Initialize()
        {
            if (!_initialized)
            {
                Fullscreen();
                _Dimension = GetResolution();
                Size size = new Size((int)(_Dimension.Width * 1.2), (int)(_Dimension.Height * 1.2));
                img = Properties.Resources._3;
                img = CT_Helper.resizeImage(img, size);

                initGame();

                #region Menu
                int drawingPointWidth = _Dimension.Width / 2;
                int drawingPointHeight = _Dimension.Height / 2;
                Point menu = new Point(drawingPointWidth - 683 / 2, drawingPointHeight - 384 / 2);
                menuContainer = new DoubleBufferedPanel(menu);

                menuContainer.Width = _Dimension.Width;
                menuContainer.Height = _Dimension.Height;

                menuContainer.Location = new Point(0, 0);
                menuContainer.Name = "Menu";

                menuHolder = new DoubleBufferedPanel();

                string[] buttonTexts = { "Starten", "Laden", "Speichern", "Highscore","Pong spielen","Beenden" };
                int positionMultiplicator = 1;
                int offset = 10;
                foreach (string text in buttonTexts)
                {

                    VistaButton button = new VistaButton();
                    button.ButtonText = text;

                    button.Width = 160;
                    button.Height = 38;
                    button.Location = new Point(offset + button.Width / 4, (button.Height + offset) * positionMultiplicator);
                    menuHolder.Controls.Add(button);
                    positionMultiplicator++;
                    button.Click += Button_Click;
                    button.KeyDown += CT_UI_KeyDown;
                    button.KeyUp += CT_UI_KeyUp;
                    button.BackColor = Color.Transparent;
                    button.BaseColor = Color.Transparent;
                    button.ButtonColor = Color.FromArgb(155, Color.DarkSlateGray);
                    button.GlowColor = Color.LightGray;
                    button.Font = new System.Drawing.Font("Pricedown", 16.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
                    button.CornerRadius = 8;
                }

                this.Controls.Add(menuContainer);
                this.Controls.Add(menuHolder);
                menuHolder.BringToFront();
                menuHolder.BorderStyle = BorderStyle.Fixed3D;
                menuHolder.Width = 683;
                menuHolder.Height = 384;
                menuHolder.Location = menu;
                menuHolder.BackColor = Color.Black;
                menuContainer.BackColor = Color.FromArgb(150, Color.Black);

                #endregion

                setCursor();
                this.Focus();
                this.TransparencyKey = Color.FromArgb(255, 255, 254);

                this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
                this.SetStyle(ControlStyles.UserPaint, true);
                this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true);

                pong=new Pong(new Size(_Dimension.Width,_Dimension.Height));

                gameBox.Size = new Size(_Dimension.Width, _Dimension.Height);

                // Resize our backbuffer
                backbuffer = new Bitmap(gameBox.Size.Width,gameBox.Size.Height, PixelFormat.Format32bppPArgb);
                backBufferGraphics = Graphics.FromImage(backbuffer);

                Updater.Interval = UPDATE_INTERVAL;

                _initialized = true;
            }
        }
Exemplo n.º 2
0
        private void Initilize()
        {
            if (!_initialized)
            {
                Fullscreen();
                _Dimension = GetResolution();
                Size size = new Size((int)(_Dimension[0] * 1.2), (int)(_Dimension[1] * 1.2));
                img = Properties.Resources._3;
                img = CT_Helper.resizeImage(img, size);

                #region Menu
                int   drawingPointWidth  = _Dimension[0] / 2;
                int   drawingPointHeight = _Dimension[1] / 2;
                Point menu = new Point(drawingPointWidth - 683 / 2, drawingPointHeight - 384 / 2);
                menuContainer = new DoubleBufferedPanel(menu);



                menuContainer.Width  = _Dimension[0];
                menuContainer.Height = _Dimension[1];

                menuContainer.Location = new Point(0, 0);
                menuContainer.Name     = "Menu";

                menuHolder = new DoubleBufferedPanel();

                string[] buttonTexts           = { "Starten", "Laden", "Speichern", "Fortsetzen", "Beenden", "Highscore" };
                int      positionMultiplicator = 1;
                int      offset = 10;
                foreach (string text in buttonTexts)
                {
                    VistaButton button = new VistaButton();
                    button.ButtonText = text;

                    button.Width    = 136;
                    button.Height   = 38;
                    button.Location = new Point(offset + button.Width / 4, (button.Height + offset) * positionMultiplicator);
                    menuHolder.Controls.Add(button);
                    positionMultiplicator++;
                    button.Click       += Button_Click;
                    button.KeyDown     += CT_UI_KeyDown;
                    button.KeyUp       += CT_UI_KeyUp;
                    button.BackColor    = Color.Transparent;
                    button.BaseColor    = Color.Transparent;
                    button.ButtonColor  = Color.FromArgb(155, Color.DarkSlateGray);
                    button.GlowColor    = Color.LightGray;
                    button.Font         = new System.Drawing.Font("Pricedown", 16.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
                    button.CornerRadius = 8;
                }

                this.Controls.Add(menuContainer);
                this.Controls.Add(menuHolder);
                menuHolder.BringToFront();
                menuHolder.BorderStyle  = BorderStyle.Fixed3D;
                menuHolder.Width        = 683;
                menuHolder.Height       = 384;
                menuHolder.Location     = menu;
                menuHolder.BackColor    = Color.Black;
                menuContainer.BackColor = Color.FromArgb(150, Color.Black);

                #endregion

                #region car
                carpanel = new CarPanel(_Dimension);
                //this.Controls.Add(carpanel);
                #endregion

                setCursor();
                this.Focus();

                //Bilderordner angeben
                MapParser.ImagePath = string.Format(@"{0}{1}MapImages", Directory.GetCurrentDirectory(), Path.DirectorySeparatorChar);
                //Karte aus XML laden
                //map = MapParser.Load(@"C:\Users\Bongo\Desktop\Berufsschule\Diagramme AE\Game\CrazyTaxi\testmap.xml");
                map = MapParser.Load(20, 20);
                //Karte vergrößert sich automatisch mit GUI
                //Karte im GUI anzeigen

                //Karte an Größe des GUIs anpassen
                map.Initialize(new Size(_Dimension[0], _Dimension[1]));
                this.BackgroundImage = map.DrawImage(new Size(_Dimension[0], _Dimension[1]));
                this.TransparencyKey = Color.FromArgb(255, 255, 254);
                this.Controls.Add(carpanel);
                map.Collision.SetDebugTarget(this);
                entity = map.Collision.AddEntity(new Size(12, 23));

                _initialized = true;
            }
        }
Exemplo n.º 3
0
        private void Initialize()
        {
            if (!_initialized)
            {
                Fullscreen();
                _Dimension = GetResolution();
                Size size = new Size((int)(_Dimension.Width * 1.2), (int)(_Dimension.Height * 1.2));
                img = Properties.Resources._3;
                img = CT_Helper.resizeImage(img, size);

                initGame();

                #region Menu
                int   drawingPointWidth  = _Dimension.Width / 2;
                int   drawingPointHeight = _Dimension.Height / 2;
                Point menu = new Point(drawingPointWidth - 683 / 2, drawingPointHeight - 384 / 2);
                menuContainer = new DoubleBufferedPanel(menu);

                menuContainer.Width  = _Dimension.Width;
                menuContainer.Height = _Dimension.Height;

                menuContainer.Location = new Point(0, 0);
                menuContainer.Name     = "Menu";

                menuHolder = new DoubleBufferedPanel();

                string[] buttonTexts           = { "Starten", "Laden", "Speichern", "Highscore", "Pong spielen", "Beenden" };
                int      positionMultiplicator = 1;
                int      offset = 10;
                foreach (string text in buttonTexts)
                {
                    VistaButton button = new VistaButton();
                    button.ButtonText = text;

                    button.Width    = 160;
                    button.Height   = 38;
                    button.Location = new Point(offset + button.Width / 4, (button.Height + offset) * positionMultiplicator);
                    menuHolder.Controls.Add(button);
                    positionMultiplicator++;
                    button.Click       += Button_Click;
                    button.KeyDown     += CT_UI_KeyDown;
                    button.KeyUp       += CT_UI_KeyUp;
                    button.BackColor    = Color.Transparent;
                    button.BaseColor    = Color.Transparent;
                    button.ButtonColor  = Color.FromArgb(155, Color.DarkSlateGray);
                    button.GlowColor    = Color.LightGray;
                    button.Font         = new System.Drawing.Font("Pricedown", 16.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
                    button.CornerRadius = 8;
                }

                this.Controls.Add(menuContainer);
                this.Controls.Add(menuHolder);
                menuHolder.BringToFront();
                menuHolder.BorderStyle  = BorderStyle.Fixed3D;
                menuHolder.Width        = 683;
                menuHolder.Height       = 384;
                menuHolder.Location     = menu;
                menuHolder.BackColor    = Color.Black;
                menuContainer.BackColor = Color.FromArgb(150, Color.Black);

                #endregion

                setCursor();
                this.Focus();
                this.TransparencyKey = Color.FromArgb(255, 255, 254);

                this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
                this.SetStyle(ControlStyles.UserPaint, true);
                this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true);

                pong = new Pong(new Size(_Dimension.Width, _Dimension.Height));

                gameBox.Size = new Size(_Dimension.Width, _Dimension.Height);

                // Resize our backbuffer
                backbuffer         = new Bitmap(gameBox.Size.Width, gameBox.Size.Height, PixelFormat.Format32bppPArgb);
                backBufferGraphics = Graphics.FromImage(backbuffer);

                Updater.Interval = UPDATE_INTERVAL;

                _initialized = true;
            }
        }
Exemplo n.º 4
0
        private void Initilize()
        {
            if (!_initialized)
            {
                Fullscreen();
                _Dimension = GetResolution();
                Size size = new Size((int)(_Dimension[0] * 1.2), (int)(_Dimension[1] * 1.2));
                img = Properties.Resources._3;
                img = CT_Helper.resizeImage(img, size);

                #region Menu
                int drawingPointWidth = _Dimension[0] / 2;
                int drawingPointHeight = _Dimension[1] / 2;
                Point menu = new Point(drawingPointWidth - 683 / 2, drawingPointHeight - 384 / 2);
                menuContainer = new DoubleBufferedPanel(menu);

                menuContainer.Width = _Dimension[0];
                menuContainer.Height = _Dimension[1];

                menuContainer.Location = new Point(0, 0);
                menuContainer.Name = "Menu";

                menuHolder = new DoubleBufferedPanel();

                string[] buttonTexts = { "Starten", "Laden", "Speichern", "Fortsetzen", "Beenden", "Highscore" };
                int positionMultiplicator = 1;
                int offset = 10;
                foreach (string text in buttonTexts)
                {

                    VistaButton button = new VistaButton();
                    button.ButtonText = text;

                    button.Width = 136;
                    button.Height = 38;
                    button.Location = new Point(offset + button.Width / 4, (button.Height + offset) * positionMultiplicator);
                    menuHolder.Controls.Add(button);
                    positionMultiplicator++;
                    button.Click += Button_Click;
                    button.KeyDown += CT_UI_KeyDown;
                    button.KeyUp += CT_UI_KeyUp;
                    button.BackColor = Color.Transparent;
                    button.BaseColor = Color.Transparent;
                    button.ButtonColor = Color.FromArgb(155, Color.DarkSlateGray);
                    button.GlowColor = Color.LightGray;
                    button.Font = new System.Drawing.Font("Pricedown", 16.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
                    button.CornerRadius = 8;
                }

                this.Controls.Add(menuContainer);
                this.Controls.Add(menuHolder);
                menuHolder.BringToFront();
                menuHolder.BorderStyle = BorderStyle.Fixed3D;
                menuHolder.Width = 683;
                menuHolder.Height = 384;
                menuHolder.Location = menu;
                menuHolder.BackColor = Color.Black;
                menuContainer.BackColor = Color.FromArgb(150, Color.Black);

                #endregion

                #region car
                carpanel = new CarPanel(_Dimension);
                //this.Controls.Add(carpanel);
                #endregion

                setCursor();
                this.Focus();

                //Bilderordner angeben
                MapParser.ImagePath = string.Format(@"{0}{1}MapImages", Directory.GetCurrentDirectory(), Path.DirectorySeparatorChar);
                //Karte aus XML laden
                //map = MapParser.Load(@"C:\Users\Bongo\Desktop\Berufsschule\Diagramme AE\Game\CrazyTaxi\testmap.xml");
                map = MapParser.Load(20, 20);
                //Karte vergrößert sich automatisch mit GUI
                //Karte im GUI anzeigen

                //Karte an Größe des GUIs anpassen
                map.Initialize(new Size(_Dimension[0], _Dimension[1]));
                this.BackgroundImage = map.DrawImage(new Size(_Dimension[0],_Dimension[1]));
                this.TransparencyKey = Color.FromArgb(255, 255, 254);
                this.Controls.Add(carpanel);
                map.Collision.SetDebugTarget(this);
                entity = map.Collision.AddEntity(new Size(12,23));

                _initialized = true;
            }
        }