Ejemplo n.º 1
0
        private void ChangeImage()
        {
            /*
             * genway:
             * 0: DownRight
             * 1: TopLeft
             * 2: TopRight
             * 3: DownLeft
             */
            Random rnd = new Random();

            genway = rnd.Next(0, 4);

            if (genway == 0)
            {
                x = _Dimension.Width - img.Width;
                y = _Dimension.Height - img.Height;
            }
            else if (genway == 1)
            {
                x = 0;
                y = 0;
            }
            else if (genway == 2)
            {
                x = _Dimension.Width - img.Width;
                y = 0;
            }
            else if (genway == 3)
            {
                x = 0;
                y = _Dimension.Height - img.Height;
            }



            Random rand = new Random();
            Size   size = new Size((int)(_Dimension.Width * 1.2), (int)(_Dimension.Height * 1.2));

            switch (rand.Next(0, 3))
            {
            case 0:
                img = CT_Helper.resizeImage(Properties.Resources._2, size);
                break;

            case 1:
                img = CT_Helper.resizeImage(Properties.Resources._3, size);
                break;

            case 2:
                img = CT_Helper.resizeImage(Properties.Resources._4, size);
                break;
            }
        }
Ejemplo n.º 2
0
        private void CT_UI_Paint(object sender, PaintEventArgs e)
        {
            Graphics g = e.Graphics;

            if (!started)
            {
                g.DrawImage(img, new Point(x, y));
            }
            else
            {
                System.Drawing.Drawing2D.Matrix m = g.Transform;
                //here we do not need to translate, we rotate at the specified point
                float x = (float)(23 / 2) + (float)carpanel.Location.X;
                float y = (float)(12 / 2) + (float)carpanel.Location.Y;
                m.RotateAt(carpanel.Angle, new PointF(x, y), System.Drawing.Drawing2D.MatrixOrder.Append);
                g.Transform = m;
                g.DrawImage(CT_Helper.resizeImage(Properties.Resources.Taxi_GTA2, new Size(23, 12)), new Point(carpanel.Location.X - 11, carpanel.Location.Y - 6));
            }
        }
Ejemplo 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;
            }
        }
Ejemplo 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;
            }
        }