示例#1
0
 private Boolean sameLane(CarDrawing car)
 {
     if (mainCar.Left < 450 && car.getLane().Equals("Left"))
     {
         return(true);
     }
     if (mainCar.Left > 450 && car.getLane().Equals("Right"))
     {
         return(true);
     }
     return(false);
 }
示例#2
0
        private Boolean carIntersects(CarDrawing car)
        {
            if ((mainCar.Bottom >= car.getTop() && mainCar.Bottom <= car.getTop() + 20))
            {
                return(false);
            }


            if ((mainCar.Top < car.getBottom() - 45) && sameLane(car))
            {
                return(true);
            }

            return(false);
        }
示例#3
0
        public CityRush()
        {
            Image image1 = Resources.Yellow;
            Image image2 = Resources.Green;
            Image image3 = Resources.Blue;

            drCar1 = new CarDrawing(image1, 217, 26);
            drCar2 = new CarDrawing(image2, 525, 26);
            drCar3 = new CarDrawing(image3, 525, 309);

            gameStarted = false;
            gamePaused  = false;
            gameOver    = false;

            score   = 0;
            speed   = 8;
            level   = 1;
            minutes = 2;
            seconds = 30;

            InitializeComponent();

            lblStatus.Visible = false;
            newGame.Visible   = false;



            typeof(Panel).InvokeMember("DoubleBuffered",
                                       BindingFlags.SetProperty | BindingFlags.Instance | BindingFlags.NonPublic,
                                       null, pnlGame, new object[] { true });
            lblScore.Parent = this;
            lblLvl.Parent   = this;
            lblTimer.Parent = this;
            lblLbl.Parent   = this;
            mainCar.Image   = Resources.Main;
            newGame.Visible = false;
        }