示例#1
0
 //Constructor, just sets the player, bullet, health, facing, and position
 public Tank(Player play, Bullet bul, int face, int pX, int pY, int playerNumber):base(face, pX, pY, GameVariables.RedTankDownImage)
 {
     scrapbooking = new Bitmap[4];
     controller = play;
     //If the player is playerOne, creates an array of red images
     if(playerNumber == 1)
     {
         scrapbooking[0] = new Bitmap(GameVariables.RedTankUpImage);
         scrapbooking[1] = new Bitmap(GameVariables.RedTankRightImage);
         scrapbooking[2] = new Bitmap(GameVariables.RedTankDownImage);
         scrapbooking[3] = new Bitmap(GameVariables.RedTankLeftImage);
     }
     //Else,creates an array of green images
     if (playerNumber == 2)
     {
         scrapbooking[0] = new Bitmap(GameVariables.GreenTankUpImage);
         scrapbooking[1] = new Bitmap(GameVariables.GreenTankRightImage);
         scrapbooking[2] = new Bitmap(GameVariables.GreenTankDownImage);
         scrapbooking[3] = new Bitmap(GameVariables.GreenTankLeftImage);
     }
     bill = bul;
     health = 2;
 }
示例#2
0
        //Basic constructor, simply places the walls, tanks and bullets on the "board"
        public GameForm(InfoForm i, string p1, string p2, string map)
        {
            info = i;
            player1Name = p1;
            player2Name = p2;
            mapText = map;
            InitializeComponent();

                //Any posX and posY values set here are just placeholder values before the map.txt is read
                //Walls are in the walle list because there can be any number of walls 
                walle = new List<Wall>();
                playerOne = new Player(player1Name, 1);
                playerTwo = new Player(player2Name, 2);

                //sets bullets, but starts them inactive to avoid instant death
                bullOne = new Bullet(1, 5, 5);
                bullOne.Active = false;
                bullTwo = new Bullet(1, 10, 10);
                bullTwo.Active = false;

                //sets tanks, with an assigned player and bullet
                //The placement is default if the map.txt file has no values
                tankOne = new Tank(playerOne, bullOne, 1, 10, 20, 1);
                tankTwo = new Tank(playerTwo, bullTwo, 3, 20, 20, 2);

                //Reads the map file in bin/debug
                ReadMap(mapText);  //this can be changed, and should be the map file.
                DrawGame();
                //The under-the-hood properties
                gameOver = false;
                //Console.CursorVisible = false;  //avoids a blinking cursor
                //sets window properties.  Uses default BufferWidth to avoid an error
                this.Width = GameVariables.GameWidth;
                this.Height = GameVariables.GameHeight;
                GameVariables.InnerHeight = this.ClientSize.Height;
                GameVariables.InnerWidth = this.ClientSize.Width;

                //Adds each piece of the game to the form's Controls directory
                this.Controls.Add(tankOne.PicBox);
                this.Controls.Add(tankTwo.PicBox);
                this.Controls.Add(bullOne.PicBox);
                this.Controls.Add(bullTwo.PicBox);
                foreach(Wall w in walle)
                {
                    this.Controls.Add(w.PicBox);
                }
                gameTimer.Start();
                //GameLoop();
            }