예제 #1
0
        private void SpawnBlocks()
        {
            // Create a new Camera
            camera = new FirstPersonCamera();
            AddComponent(camera);

            // Setup physics
            AddComponent(new Physics());

            // Create the plane and make it immovable
            PhysicsActor plane = new PhysicsActor("Content/ig_plane", new BoxObject(new Vector3(4f, .01f, 4)))
            {
                PhysicsObject = { Immovable = true }
            };
            AddComponent(plane);

            // Create the stack of boxes
            for (int y = 0; y < 3; y++)
            {
                for (int x = 0; x < 3; x++)
                {
                    PhysicsActor box = new PhysicsActor("Content/ig_box", new BoxObject(
                        new Vector3(.5f),
                        new Vector3(-.5f + (x * 0.52f), .5f + (y * 0.52f), -1),
                        Vector3.Zero))
                    {
                        Scale = new Vector3(.5f)
                    };

                    AddComponent(box);
                }
            }
        }
예제 #2
0
        private void HandleInput()
        {
            KeyboardState kbs = Keyboard.GetState();

            if (!kbs.IsKeyDown(Keys.Enter) || fired) return;

            fired = true;
            firedTime = Engine.GameTime.TotalGameTime.TotalSeconds;
            PhysicsActor act = new PhysicsActor(
                "Content/sphere",
                new SphereObject(.7f, new Vector3(0, .5f, 1), Vector3.Zero));
                //new CapsuleObject(.7f, .7f, new Vector3(0, .5f, 1), Vector3.Zero));
                //new CylinderObject(1f, .5f, new Vector3(0, .5f, 1), Vector3.Zero));
                //new BoxObject(new Vector3(1), new Vector3(0, .5f, 1), Vector3.Zero));
            AddComponent(act);
            act.Scale = new Vector3(1);
            act.PhysicsObject.Mass = 1;
            act.PhysicsObject.Velocity = new Vector3(0, 2, -6);
        }
예제 #3
0
        private void HandleInput()
        {
            KeyboardState kbs = Keyboard.GetState();

            if (kbs.IsKeyDown(Keys.Enter) && !fired)
            {
                fired = true;
                firedTime = Engine.GameTime.TotalGameTime.TotalSeconds;
                PhysicsActor act = new PhysicsActor(
                    "Content/ig_box",
                    new BoxObject(new Vector3(1), new Vector3(0, .5f, 1), Vector3.Zero));
                AddComponent(act);
                act.Scale = new Vector3(1);
                act.PhysicsObject.Mass = 1000;
                act.PhysicsObject.Velocity = new Vector3(0, 2, -6);
            }

            if (kbs.IsKeyDown(Keys.Up))
            {
                Vector3 dir = camera.Target - camera.Position;
                dir.Normalize();
            }
        }