Example #1
0
        private void SpawnCrate()
        {
            DrawablePhysicsRectangle crate;
            crate = new DrawablePhysicsRectangle(
                m_world,
                Content.Load<Texture2D>("Textures\\Crate"),
                new Vector2(102, 102.0f),
                0.1f
            );

            // Place crate along a random (x, 0) point accounting for crate size
            crate.Position = new Vector2(
                m_random.Next(102, GraphicsDevice.Viewport.Width - 102),
                1
            );

            m_crateList.Add(crate);
        }
Example #2
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);

            m_world = new World(new Vector2(0.0f, 9.8f));

            // We set the ground floor up. It must be static so it
            // is not affected by gravity.
            m_floor = new DrawablePhysicsRectangle(
                m_world,
                Content.Load<Texture2D>("Textures\\Floor"),
                new Vector2(1024.0f, 20.0f),
                1.0f
            );

            // Position is oddly from the "center" of the rectangle body
            m_floor.Position = new Vector2(
                GraphicsDevice.Viewport.Width / 2.0f,
                GraphicsDevice.Viewport.Height - 10.0f
            );

            m_floor.body.BodyType = BodyType.Static;

            m_crateList = new List<DrawablePhysicsRectangle>();
            m_random = new Random();

            m_preKeyState = Keyboard.GetState();
        }