The opponents are much like the player array, but because they won’t respond to events, they are simpler to set up:
private void setupOpp(){ //set up opponents int x; int y; for (int i= 1; i < 5; i++){ picOpp[i] = new PictureBox(); picOpp[i].Size = new Size(25,25); x = (int)((this.Width - picOpp[i].Width)/2); y = (int)(pnlField.Height/i - 30); picOpp[i].Location = new Point(x, y); picOpp[i].Image = myPics.Images[0]; picOpp[i].SizeMode = PictureBoxSizeMode.StretchImage; pnlField.Controls.Add(picOpp[i]); } // end for loop } // end setupOpp
The size and position of each picture box require a formula very much like the one in setupPlayer(). I set each image to the red player without a ball, which is image number 0 in the image list. I added each picture box to the controls of the panel, but adding an event listener was unnecessary.
18.221.254.61