Esempio n. 1
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            random = new Random();

            // World is the most important farseer object. It's where
            // all the objects should be registered and it handles the
            // entire simulation via the step function.
            // Here we instantiate it with earth like gravity
            world = new World(new Vector2(0, 9.8f));

            floor = new DrawablePhysicsObject(world, Content.Load<Texture2D>("Floor"), new Vector2(GraphicsDevice.Viewport.Width, 100.0f), 1000);
            floor.Position = new Vector2(GraphicsDevice.Viewport.Width / 2.0f, GraphicsDevice.Viewport.Height - 50);
            floor.body.BodyType = BodyType.Static;

            crateList = new List<DrawablePhysicsObject>();

            prevKeyboardState = Keyboard.GetState();

            // TODO: use this.Content to load your game content here
        }
Esempio n. 2
0
        /// <summary>
        /// Spawn a crate at a random position at the top of the screen
        /// </summary>
        private void SpawnCrate()
        {
            DrawablePhysicsObject crate;
            crate = new DrawablePhysicsObject(world, Content.Load<Texture2D>("Crate"), new Vector2(50.0f, 50.0f), 0.1f);
            crate.Position = new Vector2(random.Next(50, GraphicsDevice.Viewport.Width - 50), 1);

            crateList.Add(crate);
        }