Exemplo n.º 1
0
        static void Main()
        {
            //SETTINGS STRUCT
            //Used to pass setting variables between menus and game
            StartMenu.GameSettings settings = new StartMenu.GameSettings();


            //Create and run the menu form
            SMenu = new StartMenu(settings);
            Application.Run(SMenu);

            //If start game was pressed
            if (settings.isGameCreated)
            {
                //Create and run the game
                TronGame newGame = new TronGame(settings.num, settings.Colours, settings.Names);
                newGame.Run();
            }
        }
Exemplo n.º 2
0
        //CONSTRUCTOR
        public MultiplayerMenu(StartMenu.GameSettings set)
        {
            settings = set;
            InitializeComponent();

            //Put form into fullscreen and make background black
            FormBorderStyle = FormBorderStyle.None;
            this.Size       = Screen.PrimaryScreen.WorkingArea.Size;
            WindowState     = FormWindowState.Maximized;
            BackColor       = Color.FromArgb(0, 0, 0);

            //Find middle points of form for positiong objects
            int midX, midY;

            midX = this.Width / 2;
            midY = this.Height / 2;

            this.KeyDown += new KeyEventHandler(Form_KeyDown);

            //EXIT BUTTON
            var Exit = new PictureBox
            {
                Name     = "Exit",
                AutoSize = true,
                Image    = Image.FromFile("Images/All Menus/Exit.png")
            };

            Exit.Click += new EventHandler(Exit_Click);
            this.Controls.Add(Exit);
            Exit.Location = new Point((this.Width / 15) * 14 - Exit.Width / 2, 0);

            //BACK BUTTON
            var Back = new PictureBox
            {
                Name     = "Back",
                AutoSize = true,
                Image    = Image.FromFile("Images/All Menus/Back.png")
            };

            Back.Click += new EventHandler(Back_Click);
            this.Controls.Add(Back);
            Back.Location = new Point((this.Width / 15) - Exit.Width / 2, 0);

            //MULTIPLAYER TITLE
            var Multiplayer = new PictureBox
            {
                Name     = "Multiplayer",
                AutoSize = true,
                Image    = Image.FromFile("Images/Multiplayer Menu/Multiplayer Heading.png")
            };

            this.Controls.Add(Multiplayer);
            Multiplayer.Location = new Point(midX - (Multiplayer.Width / 2), 0);

            //NUMBER OF PLAYERS LABEL
            var NumOfPlayers = new PictureBox
            {
                Name     = "NumOfPlayers",
                AutoSize = true,
                Image    = Image.FromFile("Images/Multiplayer Menu/Number Of Players.png")
            };

            this.Controls.Add(NumOfPlayers);
            NumOfPlayers.Location = new Point(midX - (NumOfPlayers.Width / 2), (this.Height / 16) * 5 - (NumOfPlayers.Height / 2));

            //RADIO BUTTONS
            for (int i = 0; i < 3; i++)
            {
                RadioButtons[i] = new RadioButton
                {
                    Name      = "RadioButton" + (i + 2),
                    Text      = (i + 2).ToString(),
                    AutoSize  = true,
                    ForeColor = Color.White,
                    Font      = new Font("Ariel", 15, FontStyle.Bold),
                    AutoCheck = true,
                    Cursor    = Cursors.Cross,
                };
                this.Controls.Add(RadioButtons[i]);
                RadioButtons[i].Location = new Point((this.Width / 10) * (i + 4), (this.Height / 16) * 6 - (RadioButtons[i].Height / 2));
            }

            RadioButtons[2].Checked = true;

            RadioButtons[0].Click += new EventHandler(TwoPlayers);
            RadioButtons[1].Click += new EventHandler(ThreePlayers);
            RadioButtons[2].Click += new EventHandler(FourPlayers);


            for (int i = 0; i < 4; i++)
            {
                //PLAYER LABELS
                PlayerLabels[i] = new PictureBox
                {
                    Name     = "PlayerLabel" + (i + 1),
                    AutoSize = true,
                    Image    = Image.FromFile("Images/Multiplayer Menu/Player " + (i + 1) + ".png")
                };
                this.Controls.Add(PlayerLabels[i]);
                PlayerLabels[i].Location = new Point(((this.Width / 5) * (i + 1)) - (PlayerLabels[i].Width / 2), (this.Height / 16) * 8 - (PlayerLabels[i].Height / 2));

                //NAME TEXT BOXES
                NameBoxes[i] = new TextBox
                {
                    Name      = "NameBox" + (i + 1),
                    AutoSize  = false,
                    Font      = new Font("Ariel", 20, FontStyle.Bold),
                    Size      = new Size(this.Width / 10, 38),
                    MaxLength = 18,
                };
                NameBoxes[i].KeyPress += new KeyPressEventHandler(TextResize);
                this.Controls.Add(NameBoxes[i]);
                NameBoxes[i].Location = new Point(((this.Width / 5) * (i + 1)) - (NameBoxes[i].Width / 2), (this.Height / 16) * 10 - (NameBoxes[i].Height / 2));

                //COLOUR BUTTONS
                ColourButtons[i] = new Button
                {
                    Name = "ColourButton" + (i + 1),
                    Size = new Size(this.Width / 10, this.Height / 20),
                };
                ColourButtons[i].Click += new EventHandler(ColourButton_Click);
                this.Controls.Add(ColourButtons[i]);
                ColourButtons[i].Location = new Point(((this.Width / 5) * (i + 1)) - (ColourButtons[i].Width / 2), (this.Height / 16) * 12 - (ColourButtons[i].Height / 2));
            }
            //Default colours
            ColourButtons[0].BackColor = Color.MidnightBlue;
            ColourButtons[1].BackColor = Color.DarkRed;
            ColourButtons[2].BackColor = Color.Yellow;
            ColourButtons[3].BackColor = Color.DarkGreen;

            //NAME LABEL
            var Name = new PictureBox
            {
                Name     = "Name",
                AutoSize = true,
                Image    = Image.FromFile("Images/Multiplayer Menu/Name.png")
            };

            this.Controls.Add(Name);
            Name.Location = new Point((NameBoxes[0].Left / 2) - (Name.Width / 2), (this.Height / 16) * 10 - (Name.Height / 2));

            //COLOUR LABEL
            var Colour = new PictureBox
            {
                Name     = "Colour",
                AutoSize = true,
                Image    = Image.FromFile("Images/Multiplayer Menu/Colour.png")
            };

            this.Controls.Add(Colour);
            Colour.Location = new Point((NameBoxes[0].Left / 2) - (Colour.Width / 2), (this.Height / 16) * 12 - (Colour.Height / 2));

            //SETTINGS LABEL
            var Settings = new PictureBox
            {
                Name     = "Settings",
                AutoSize = true,
                Image    = Image.FromFile("Images/All Menus/Settings.png")
            };

            this.Controls.Add(Settings);
            Settings.Location = new Point((this.Width / 8) * 1 - Settings.Width / 2, (this.Height) - (Settings.Height));

            //HELP LABEL
            var Help = new PictureBox
            {
                Name     = "Help",
                AutoSize = true,
                Image    = Image.FromFile("Images/All Menus/Help.png")
            };

            this.Controls.Add(Help);
            Help.Location = new Point((this.Width / 8) * 7 - Help.Width / 2, (this.Height) - (Help.Height));

            //START GAME BUTTON
            var StartGame = new PictureBox
            {
                Name     = "StartGame",
                AutoSize = true,
                Image    = Image.FromFile("Images/Multiplayer Menu/Start Game.png")
            };

            StartGame.Click += new EventHandler(GameStart);
            this.Controls.Add(StartGame);
            StartGame.Location = new Point(midX - (StartGame.Width / 2), (this.Height) - (StartGame.Height));
        }
Exemplo n.º 3
0
        //CONSTRUCTOR
        public SinglePlayerMenu(StartMenu.GameSettings set)
        {
            settings = set;
            InitializeComponent();

            //Put form into fullscreen and make background black
            FormBorderStyle = FormBorderStyle.None;
            this.Size       = Screen.PrimaryScreen.WorkingArea.Size;
            WindowState     = FormWindowState.Maximized;
            BackColor       = Color.FromArgb(0, 0, 0);

            //Find middle points of form for positiong objects
            int midX, midY;

            midX = this.Width / 2;
            midY = this.Height / 2;

            this.KeyDown += new KeyEventHandler(Form_KeyDown);

            //EXIT BUTTON
            var Exit = new PictureBox
            {
                Name     = "Exit",
                AutoSize = true,
                Image    = Image.FromFile("Images/All Menus/Exit.png")
            };

            Exit.Click += new EventHandler(Exit_Click);
            this.Controls.Add(Exit);
            Exit.Location = new Point((this.Width / 15) * 14 - Exit.Width / 2, 0);

            //BACK BUTTON
            var Back = new PictureBox
            {
                Name     = "Back",
                AutoSize = true,
                Image    = Image.FromFile("Images/All Menus/Back.png")
            };

            Back.Click += new EventHandler(Back_Click);
            this.Controls.Add(Back);
            Back.Location = new Point((this.Width / 15) - Exit.Width / 2, 0);

            //SINGLE PLAYER TITLE
            var SinglePlayer = new PictureBox
            {
                Name     = "SinglePlayer",
                AutoSize = true,
                Image    = Image.FromFile("Images/Single Player Menu/Single Player Heading.png")
            };

            this.Controls.Add(SinglePlayer);
            SinglePlayer.Location = new Point(midX - (SinglePlayer.Width / 2), 0);

            //NAME LABEL
            var Name = new PictureBox
            {
                Name     = "Name",
                AutoSize = true,
                Image    = Image.FromFile("Images/Single Player Menu/Name.png")
            };

            this.Controls.Add(Name);
            Name.Location = new Point(midX - (Name.Width / 2), (this.Height / 16) * 4 - (Name.Height / 2));

            //NAME TEXT BOX
            var NameEntry = new TextBox
            {
                Name      = "NameEntry",
                Font      = new Font("Ariel", 30, FontStyle.Bold),
                TextAlign = HorizontalAlignment.Center,
                AutoSize  = true,
                Width     = this.Width / 3,
                MaxLength = 18,
            };

            this.Controls.Add(NameEntry);
            NameEntry.Location = new Point(midX - (NameEntry.Width / 2), (this.Height / 16) * 6 - (NameEntry.Height / 2));

            //COLOUR LABEL
            var Colour = new PictureBox
            {
                Name     = "Colour",
                AutoSize = true,
                Image    = Image.FromFile("Images/Single Player Menu/Colour.png")
            };

            this.Controls.Add(Colour);
            Colour.Location = new Point(midX - (Colour.Width / 2), (this.Height / 16) * 8 - (Colour.Height / 2));

            //COLOUR BUTTON
            var ColourEntry = new Button
            {
                Name      = "ColourEntry",
                Size      = new Size(NameEntry.Width / 2, NameEntry.Height),
                BackColor = Color.MidnightBlue,
            };

            ColourEntry.Click += new EventHandler(ColourEntry_Click);
            this.Controls.Add(ColourEntry);
            ColourEntry.Location = new Point(midX - (ColourEntry.Width / 2), (this.Height / 16) * 10 - (ColourEntry.Height / 2));

            //SETTINGS LABEL
            var Settings = new PictureBox
            {
                Name     = "Settings",
                AutoSize = true,
                Image    = Image.FromFile("Images/All Menus/Settings.png")
            };

            this.Controls.Add(Settings);
            Settings.Location = new Point((this.Width / 8) * 1 - Settings.Width / 2, (this.Height) - (Settings.Height));

            //HELP LABEL
            var Help = new PictureBox
            {
                Name     = "Help",
                AutoSize = true,
                Image    = Image.FromFile("Images/All Menus/Help.png")
            };

            this.Controls.Add(Help);
            Help.Location = new Point((this.Width / 8) * 7 - Help.Width / 2, (this.Height) - (Help.Height));

            //START GAME BUTTON
            var StartGame = new PictureBox
            {
                Name     = "StartGame",
                AutoSize = true,
                Image    = Image.FromFile("Images/Single Player Menu/Start Game.png")
            };

            this.Controls.Add(StartGame);
            StartGame.Location = new Point(midX - (StartGame.Width / 2), (this.Height) - (StartGame.Height));
        }