예제 #1
0
 public Enemy(PictureBox carImage,int moveRate,Batman batman)
 {
     this.carImage = carImage;
     this.batman = batman;
     rand = new Random();
     carType();
     this.moveRate = moveRate;
     carTime = new Timer();
     carTime.Interval = 30;
     carTime.Enabled = true;
     carTime.Tick += carTime_Tick;
 }
예제 #2
0
 public Enemy(PictureBox carImage, int moveRate, Batman batman)
 {
     this.carImage = carImage;
     this.batman   = batman;
     rand          = new Random();
     carType();
     this.moveRate    = moveRate;
     carTime          = new Timer();
     carTime.Interval = 30;
     carTime.Enabled  = true;
     carTime.Tick    += carTime_Tick;
 }
예제 #3
0
        //private int buletNumber=0;
        public Form1()
        {
            InitializeComponent();

            roadImage    = new PictureBox();
            roadImage2   = new PictureBox();
            batmanImage  = new PictureBox();
            lifeOfBatman = new ProgressBar();
            buletImage   = new PictureBox[100];
            bulet        = new Bulet[100];
            enemyCar     = new PictureBox[100];
            enemy        = new Enemy[10000];
            rand         = new Random();
            //Bulet Timer
            //buletTimer = new Timer();
            //buletTimer.Interval = 50;
            //buletTimer.Tick += buletTimer_Tick;
            //buletTimer.Enabled = true;

            scoreLabel = new Label();

            road = new Road(roadImage, roadImage2);
            Controls.Add(roadImage);
            Controls.Add(roadImage2);

            //  roadThread = new Thread(new ThreadStart(road.roadMove));
            //  roadThread.Start();

            roadTimer          = new Timer();
            roadTimer.Interval = 1;
            roadTimer.Tick    += roadTimer_Tick;
            roadTimer.Enabled  = true;
            roadTimer.Start();
            DoubleBuffered = true;

            //Car Timer
            carTimer          = new Timer();
            carTimer.Interval = 3000;
            carTimer.Tick    += carTimer_Tick;
            carTimer.Enabled  = true;
            carTimer.Start();
            DoubleBuffered = true;

            // Bulet location trace timer


            //Batman car
            batman = new Batman(batmanImage, lifeOfBatman);
            Controls.Add(batmanImage);
            Controls.Add(lifeOfBatman);
            scoreLabel.Text     = "Score: " + Convert.ToString(scoreValue);
            scoreLabel.Location = new Point(840, 40);
            //scoreLabel.AutoSize = false;
            scoreLabel.Height = 42;
            scoreLabel.Width  = 400;
            scoreLabel.Font   = new Font("Tahoma", 20);
            Controls.Add(scoreLabel);
            batmanImage.BringToFront();

            // Batman car move
            this.AutoSize        = true;
            this.KeyPreview      = true;
            this.PreviewKeyDown += new PreviewKeyDownEventHandler(myPreview);
        }