Пример #1
0
 private void initializeGameArea()
 {
     Bitmap back = currentLevel.getBackground();
     myGameArea = new GameArea();
     myGameArea.Width = back.Width;
     myGameArea.Height = back.Height;
     myGameArea.Visible = true;
     myGameArea.updateSize(back.Size);
     myGameArea.BackgroundImage = back;
     myGameArea.Name = "myGameArea";
     myGameArea.Paint += new System.Windows.Forms.PaintEventHandler(this.myGameArea_Paint);
     myGameArea.MouseDown += new System.Windows.Forms.MouseEventHandler(this.myGameArea_MouseDown);
     myGameArea.MouseMove += new System.Windows.Forms.MouseEventHandler(this.myGameArea_MouseMove);
     myGameArea.MouseUp += new System.Windows.Forms.MouseEventHandler(this.myGameArea_MouseUp);
     this.pEditor.Controls.Add(myGameArea);
 }
Пример #2
0
        //######Constructor
        public Form1()
        {
            InitializeComponent();

            //This allows the user to place some components on pGameArea before compiling the program and as long as the name starts with _col
            //It adds them to the collision boxes list for later use - Likely going to be a depriciated method instead I will be saving the
            //colBoxes in the GameLevel object -> a file
            this.Controls.Remove(pGameArea);
            foreach (Control tmpControl in pGameArea.Controls)
            {
                if (tmpControl.Name.ToString().Substring(0, 4) == "col_")
                {
                    colBoxes.Add(new Rectangle(tmpControl.Location, new Size(tmpControl.Width, tmpControl.Height)));
                }
            }

            //Adds the player but also passes a list of current obstruction lines so that the player constructor can also
            //construct the visibility(for flashlight);
            thePlayer = new PlayerCharacter(this.obstructLine);

            //Instantiates, adds, configures and offesets the game area.
            myGameArea = new GameArea();
            this.Controls.Add(myGameArea);
            this._Offset.X = this._Offset.X - thePlayer.getPlayerRect().Width / 2;
            this._Offset.Y = this._Offset.Y - thePlayer.getPlayerRect().Height / 2;
            myGameArea.Visible = true;
            myGameArea.Paint += new System.Windows.Forms.PaintEventHandler(this.PaintGameArea);
            myGameArea.MouseDown += new System.Windows.Forms.MouseEventHandler(this.StartDrawCustomRectangle);
            myGameArea.MouseMove += new System.Windows.Forms.MouseEventHandler(this.DrawCustomRectangle);
            myGameArea.MouseUp += new System.Windows.Forms.MouseEventHandler(this.StopDrawingRectangle);
            this.LostFocus += new System.EventHandler(stopMovement);
            //someRandomColisionRectangles();

            //Instantiates & starts the thread used to continuously check for any gui changes(such as new col/vision boxes or player movement)
            Thread t = new Thread(update);
            t.IsBackground = true;
            t.Start();
        }
Пример #3
0
        public LineTest()
        {
            InitializeComponent();
            myGameArea2 = new GameArea();
            this.panel2.Controls.Add(myGameArea2);

            myGameArea2.Visible = true;
            myGameArea2.Paint += new System.Windows.Forms.PaintEventHandler(this.PaintGameArea);
            myGameArea2.MouseDown += new System.Windows.Forms.MouseEventHandler(this.StartDrawShape);
            myGameArea2.MouseMove += new System.Windows.Forms.MouseEventHandler(this.DrawShape);
            myGameArea2.MouseUp += new System.Windows.Forms.MouseEventHandler(this.StopDrawShape);

            myGameArea2.Controls.Add(coords);
            coords.Visible = true;

            Thread t = new Thread(update);
            t.IsBackground = true;
            t.Start();
        }