Exemplo n.º 1
0
 /// <summary>
 /// Allows the game to perform any initialization it needs to before starting to run.
 /// This is where it can query for any required services and load any non-graphic
 /// related content.  Calling base.Initialize will enumerate through any components
 /// and initialize them as well.
 /// </summary>
 protected override void Initialize()
 {
     // TODO: Add your initialization logic here
     gameObjects = new GameObject[5];
     gameObjects[0] = new Ball(new Vector3(-9, -9, -5), 0.3f, GraphicsDevice, gameObjects);
     gameObjects[1] = new Box(new Vector3(0, 0, 0), new Vector3(0, 0, 0), 10, GraphicsDevice);
     gameObjects[2] = new Bumper(new Vector3(0, -8f, -7f), new Vector3(0, 0, 0), 1, GraphicsDevice);
     gameObjects[3] = new Flipper(new Vector3(-8.5f, -8, 5), new Vector3(-0.75f, 0, 0), 0.2f * (float)Math.PI, -0.12f * (float)Math.PI, new Vector3(0, 0, 0), 2, (Ball)gameObjects[0], GraphicsDevice);
     gameObjects[4] = new Flipper(new Vector3(4f, -8, 5), new Vector3(2.5f, 0, 0), 0.2f * (float)Math.PI, 0.12f * (float)Math.PI, new Vector3(0, 0, 0), 2, (Ball)gameObjects[0], GraphicsDevice);
     camera = new Camera(new Vector3(0, 25, 10), new Vector3(0, 0, -1));
     IsMouseVisible = true;
     base.Initialize();
 }
Exemplo n.º 2
0
        public Flipper(Vector3 position, Vector3 pivot, float maxAngle, float rotationASecond, Vector3 rotation, float scale, Ball ball, GraphicsDevice device)
            : base()
        {
            this.pivot = position + pivot * scale;
            this.rotation = 0;
            this.maxAngle = maxAngle;
            this.rotationASecond = rotationASecond;
            this.ball = ball;

            surfaces = new Plane[10];

            //The box
            Vector3 botPosition = new Vector3(position.X, position.Y - scale, position.Z);
            Vector3 botRotation = new Vector3(rotation.X + (float)Math.PI, rotation.Y, rotation.Z);
            surfaces[0] = new Plane(botPosition, botRotation, scale, device);
            Vector3 botPosition2 = new Vector3(position.X + 2 * scale, position.Y - scale, position.Z);
            surfaces[1] = new Plane(botPosition2, botRotation, scale, device);

            Vector3 topPosition = new Vector3(position.X, position.Y + scale, position.Z);
            Vector3 topRotation = rotation;
            surfaces[2] = new Plane(topPosition, topRotation, scale, device);
            Vector3 topPosition2 = new Vector3(position.X + 2 * scale, position.Y + scale, position.Z);
            surfaces[3] = new Plane(topPosition2, topRotation, scale, device);

            Vector3 rightPosition = new Vector3(position.X + 3 * scale, position.Y, position.Z);
            Vector3 rightRotation = new Vector3(rotation.X, rotation.Y, rotation.Z - 0.5f*(float)Math.PI);
            surfaces[4] = new Plane(rightPosition, rightRotation, scale, device);

            Vector3 leftPosition = new Vector3(position.X - scale, position.Y, position.Z);
            Vector3 leftRotation = new Vector3(rotation.X, rotation.Y, rotation.Z + 0.5f * (float)Math.PI);
            surfaces[5] = new Plane(leftPosition, leftRotation, scale, device);

            Vector3 backPosition = new Vector3(position.X, position.Y, position.Z + scale);
            Vector3 backRotation = new Vector3(rotation.X + 0.5f * (float)Math.PI, rotation.Y, rotation.Z);
            surfaces[6] = new Plane(backPosition, backRotation, scale, device);
            Vector3 backPosition2 = new Vector3(position.X + 2 * scale, position.Y, position.Z + scale);
            surfaces[7] = new Plane(backPosition2, backRotation, scale, device);

            Vector3 frontPosition = new Vector3(position.X, position.Y, position.Z - scale);
            Vector3 frontRotation = new Vector3(rotation.X - 0.5f * (float)Math.PI, rotation.Y, rotation.Z);
            surfaces[8] = new Plane(frontPosition, frontRotation, scale, device);
            Vector3 front2Position = new Vector3(position.X + 2 * scale, position.Y, position.Z - scale); ;
            surfaces[9] = new Plane(front2Position, frontRotation, scale, device);
        }