Ejemplo n.º 1
0
        /// <summary>
        /// The general method for creating a level.
        /// </summary>
        void newLevel()
        {
            // Create the level, reset the stick man to stationary at the spawn point, and set the camera and gravity to normal
            level = new Level(world, GraphicsDevice, Content, currentLevel);

            stickMan.Position = level.Spawn;
            stickMan.body.LinearVelocity = Vector2.Zero;
            stickMan.body.AngularVelocity = 0;
            stickMan.body.Rotation = 0;

            camera.Rotation = 0;

            gravityAngle = 0;
            gravity = new Vector2(0f, 9.8f);
            world.Gravity = gravity;
        }
Ejemplo n.º 2
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()
        {
            WIDTH = GraphicsDevice.Viewport.Width;
            HEIGHT = GraphicsDevice.Viewport.Height;

            gameOver = false;

            currentKeyboard = Keyboard.GetState();
            oldKeyboard = currentKeyboard;

            // Setting the gravity to be straight down, and creating the world
            gravityAngle = 0;
            gravity = new Vector2(0f, 9.8f);
            world = new World(gravity);

            // Creating the first level
            currentLevel = 0;
            level = new Level(world, GraphicsDevice, Content, currentLevel);

            // Creating the camera and setting it to start in the center of the screen
            camera = new Camera(WIDTH, HEIGHT);
            camera.Pos = new Vector2(WIDTH / 2, HEIGHT / 2);

            base.Initialize();
        }