예제 #1
0
        // Cria asteroides
        public void gerenciarObstaculos(SpriteBatch _batch)
        {
            int    n_obs = recuperaComponentesTotal <Obstaculo>();
            Random r     = new Random();

            while (n_obs < numMaxObstaculos)
            {
                n_obs++;
                obstaculo = new Obstaculo(getGame(), 5, 10, 10, "imagens/asteroid", new Vector2(r.Next(0, 780), -50), _batch);
                getGame().Components.Add(obstaculo);
            }
        }
예제 #2
0
        public Vector2 Calculate(Obstaculo obstaculo, float secs)
        {
            if (Mouse.GetState().LeftButton == ButtonState.Pressed)
            {
                alvo = new Vector2(Mouse.GetState().X, Mouse.GetState().Y);
            }

            Vector2 desired = alvo - obstaculo.getPosition();

            desired = Vector2.Normalize(desired) * obstaculo.getMaxVelocidade();
            return(desired - obstaculo.getVelocidade());
        }
        public Vector2 Calculate(Obstaculo obstaculo, float secs)
        {
            float   jitterTimeSlice = jitter * secs * 9;
            Vector2 tmp             = new Vector2(
                RandomClamped() * jitterTimeSlice,
                RandomClamped() * jitterTimeSlice);

            wanderTarget += tmp;
            wanderTarget  = Vector2.Normalize(wanderTarget) * radius;

            Vector2 target = obstaculo.getPosition();

            target += obstaculo.direcao * distance;
            target += wanderTarget;
            return(new BehaviorSeek(target).Calculate(obstaculo, secs));
        }