コード例 #1
0
        private void SpawnCrate()
        {
            DrawablePhysicsObject crate;

            crate          = new DrawablePhysicsObject(World, BoxTexture, new Vector2(50.0f, 50.0f), 5f);
            crate.Position = new Vector2(Random.Next(50, GraphicsDevice.Viewport.Width - 50), 1);

            CrateList.Add(crate);
        }
コード例 #2
0
ファイル: Game1.cs プロジェクト: Xe3d/Main
        private void SpawnCrate()
        {
            DrawablePhysicsObject crate;

            crate          = new DrawablePhysicsObject(world, Content.Load <Texture2D>("wooden"), new Vector2(50.0f, 50.0f), 0.1f);
            crate.Position = new Vector2(random.Next(50, GraphicsDevice.Viewport.Width - 50), 1);

            crateList.Add(crate);
        }
コード例 #3
0
ファイル: Game1.cs プロジェクト: Xe3d/Main
        /// <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>("White"), new Vector2(1.0f, 1.0f), 0.1f);
            crate.Position = new Vector2(playerObj.Position.X, playerObj.Position.Y);
            if (playerObj.Facing == "right")
            {
                Vector2 targetPos = new Vector2(playerObj.Position.X + 100, random.Next(0, GraphicsDevice.Viewport.Height));
            }
            crateList.Add(crate);
        }
コード例 #4
0
ファイル: Game1.cs プロジェクト: Xe3d/Main
        /// <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);



            world = new World(new Vector2(0, 9.8f));



            random = new Random();

            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 = new KeyboardState();

            // TODO: use this.Content to load your game content here
        }
コード例 #5
0
        protected override void LoadContent()
        {
            CrepLightList.Add(new CrepuscularLight()
            {
                Position = new Vector2(1280 / 2, 720 / 2),
                Decay    = 0.9999f,
                Exposure = 0.23f,
                Density  = 0.826f,
                Weight   = 0.358767f
            });

            CrepLightList.Add(new CrepuscularLight()
            {
                Position = new Vector2(1280 / 2, 720 / 2),
                Decay    = 0.9999f,
                Exposure = 0.23f,
                Density  = 0.826f,
                Weight   = 0.358767f
            });

            //for (int i = 0; i < 5; i++)
            //{
            //    CrepLightList.Add(new CrepuscularLight()
            //    {
            //        Position = new Vector2(Random.Next(0, 1280), Random.Next(0, 720)),
            //        Decay = 0.9999f,
            //        Exposure = 0.23f,
            //        Density = 0.826f,
            //        Weight = 0.358767f
            //    });
            //}

            HitEffectParticle = Content.Load <Texture2D>("HitEffectParticle");
            Glowball          = Content.Load <Texture2D>("Glowball");

            Buffer2 = new RenderTarget2D(GraphicsDevice, 1280, 720, false, SurfaceFormat.Rgba64, DepthFormat.None, 1, RenderTargetUsage.PreserveContents);
            Buffer1 = new RenderTarget2D(GraphicsDevice, 1280, 720);

            OcclusionMap = new RenderTarget2D(GraphicsDevice, 1280, 720);

            EmissiveMap = new RenderTarget2D(GraphicsDevice, 1280, 720);
            BlurMap     = new RenderTarget2D(GraphicsDevice, 1280, 720);
            ColorMap    = new RenderTarget2D(GraphicsDevice, 1280, 720);
            NormalMap   = new RenderTarget2D(GraphicsDevice, 1280, 720);
            LightMap    = new RenderTarget2D(GraphicsDevice, 1280, 720, false, SurfaceFormat.Rgba64, DepthFormat.None, 8, RenderTargetUsage.PreserveContents);

            FinalMap     = new RenderTarget2D(GraphicsDevice, 1280, 720);
            SpecMap      = new RenderTarget2D(GraphicsDevice, 1280, 720);
            CrepLightMap = new RenderTarget2D(GraphicsDevice, 1280, 720);
            CrepColorMap = new RenderTarget2D(GraphicsDevice, 1280, 720);
            DepthMap     = new RenderTarget2D(GraphicsDevice, 1280, 720);

            ShadowMap = new RenderTarget2D(GraphicsDevice, 1280, 720);//, false, SurfaceFormat.Rgba64, DepthFormat.None, 8, RenderTargetUsage.PreserveContents);

            BasicEffect                    = new BasicEffect(GraphicsDevice);
            BasicEffect.Projection         = Matrix.CreateOrthographicOffCenter(0, 1280, 720, 0, 0, 1);
            BasicEffect.VertexColorEnabled = true;

            DepthEffect = Content.Load <Effect>("Depth");
            DepthEffect.Parameters["Projection"].SetValue(Projection);

            spriteBatch = new SpriteBatch(GraphicsDevice);

            Sprite = Content.Load <Texture2D>("Sprite");
            CrepuscularLightTexture = Content.Load <Texture2D>("Flare1");
            HealDrone         = Content.Load <Texture2D>("HealDrone");
            HealDroneNormal   = Content.Load <Texture2D>("HealDroneNormal");
            HealDroneEmissive = Content.Load <Texture2D>("HealDroneEmissive");
            BoxTexture        = Content.Load <Texture2D>("Box");
            Laser             = Content.Load <Texture2D>("Beam");

            SolidList.Add(new Solid(BoxTexture, new Vector2(400, 300), new Vector2(80, 80)));
            SolidList.Add(new Solid(BoxTexture, new Vector2(100, 250), new Vector2(50, 20)));
            SolidList.Add(new Solid(BoxTexture, new Vector2(500, 400), new Vector2(120, 40)));
            SolidList.Add(new Solid(BoxTexture, new Vector2(1000, 500), new Vector2(70, 80)));

            for (int i = 0; i < 40; i++)
            {
                SolidList.Add(new Solid(BoxTexture, new Vector2(150 + (24 * i), 250), new Vector2(4, 32)));
            }

            SpriteList.Add(new Sprite(HealDrone, new Vector2(1280 / 2 - 32, 720 / 2 - 32), HealDroneNormal, HealDroneEmissive));

            SpriteList.Add(new Sprite(HealDrone, new Vector2(100, 100), HealDroneNormal, HealDroneEmissive));
            SpriteList.Add(new Sprite(HealDrone, new Vector2(800, 500), HealDroneNormal, HealDroneEmissive));


            BlurEffect    = Content.Load <Effect>("Blur");
            LightCombined = Content.Load <Effect>("LightCombined");
            LightEffect   = Content.Load <Effect>("LightEffect");

            RaysEffect = Content.Load <Effect>("Crepuscular");

            RaysEffect.Parameters["Projection"].SetValue(Projection);
            BlurEffect.Parameters["Projection"].SetValue(Projection);

            LightVertices    = new VertexPositionColorTexture[4];
            LightVertices[0] = new VertexPositionColorTexture(new Vector3(-1, 1, 0), Color.White, new Vector2(0, 0));
            LightVertices[1] = new VertexPositionColorTexture(new Vector3(1, 1, 0), Color.White, new Vector2(1, 0));
            LightVertices[2] = new VertexPositionColorTexture(new Vector3(-1, -1, 0), Color.White, new Vector2(0, 1));
            LightVertices[3] = new VertexPositionColorTexture(new Vector3(1, -1, 0), Color.White, new Vector2(1, 1));

            CrepVertices    = new VertexPositionColorTexture[4];
            CrepVertices[0] = new VertexPositionColorTexture(new Vector3(-1, 1, 0), Color.White, new Vector2(0, 0));
            CrepVertices[1] = new VertexPositionColorTexture(new Vector3(1, 1, 0), Color.White, new Vector2(1, 0));
            CrepVertices[2] = new VertexPositionColorTexture(new Vector3(-1, -1, 0), Color.White, new Vector2(0, 1));
            CrepVertices[3] = new VertexPositionColorTexture(new Vector3(1, -1, 0), Color.White, new Vector2(1, 1));

            EmissiveVertices    = new VertexPositionColorTexture[6];
            EmissiveVertices[0] = new VertexPositionColorTexture(new Vector3(0, 0, 0), Color.White, new Vector2(0, 0));
            EmissiveVertices[1] = new VertexPositionColorTexture(new Vector3(1280, 0, 0), Color.White, new Vector2(1, 0));
            EmissiveVertices[2] = new VertexPositionColorTexture(new Vector3(1280, 720, 0), Color.White, new Vector2(1, 1));
            EmissiveVertices[3] = new VertexPositionColorTexture(new Vector3(1280, 720, 0), Color.White, new Vector2(1, 1));
            EmissiveVertices[4] = new VertexPositionColorTexture(new Vector3(0, 720, 0), Color.White, new Vector2(0, 1));
            EmissiveVertices[5] = new VertexPositionColorTexture(new Vector3(0, 0, 0), Color.White, new Vector2(0, 0));

            Texture       = Content.Load <Texture2D>("Texture");
            NormalTexture = Content.Load <Texture2D>("NormalTexture");

            LightList.Add(new Light()
            {
                //Color = new Color(141, 38, 10, 42),
                //Color = new Color(10, 25, 70, 5),
                //Color = Color.LightGreen,
                Color    = Color.Plum,
                Active   = true,
                Power    = 0.7f,
                Position = new Vector3(100, 100, 100),
                Size     = 800
            });

            LightList.Add(new Light()
            {
                //Color = new Color(141, 38, 10, 42),
                //Color = new Color(10, 25, 70, 5),
                //Color = Color.DarkSeaGreen,
                Color = Color.Silver,
                //Color = Color.Plum,
                //Color = new Color(141, 38, 10, 42),
                //Color = Color.White,
                Active   = true,
                Power    = 0.8f,
                Position = new Vector3(200, 100, 100),
                Size     = 400
            });

            //LightList.Add(new Light()
            //{
            //    //Color = new Color(141, 38, 10, 42),
            //    Color = Color.White,
            //    Active = true,
            //    Power = 1.8f,
            //    Position = new Vector3(500, 600, 100),
            //    Size = 600
            //});

            //LightList.Add(new Light()
            //{
            //    //Color = new Color(141, 38, 10, 42),
            //    Color = Color.LimeGreen,
            //    Active = true,
            //    Power = 1.8f,
            //    Position = new Vector3(1000, 80, 100),
            //    Size = 400
            //});

            //LightList.Add(new Light()
            //{
            //    //Color = new Color(141, 38, 10, 42),
            //    Color = Color.Purple,
            //    Active = true,
            //    Power = 0.2f,
            //    Position = new Vector3(1280 / 2, 50, 250),
            //    Size = 600
            //});

            //LightList.Add(new Light()
            //{
            //    //Color = new Color(0, 180, 255, 42),
            //    Color = Color.Goldenrod,
            //    Active = true,
            //    Power = 0.8f,
            //    Position = new Vector3(1280 - 700, 720 - 180, 250),
            //    Size = 1200
            //});


            World               = new World(new Vector2(0, 9.8f));
            Floor               = new DrawablePhysicsObject(World, BoxTexture, new Vector2(1280, 100), 1000);
            Floor.Position      = new Vector2(1280 / 2, 720 - 50);
            Floor.body.BodyType = BodyType.Static;

            CrateList = new List <DrawablePhysicsObject>();
        }
コード例 #6
0
ファイル: Game1.cs プロジェクト: Xe3d/Main
        /// <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();



            pList = new List <PhysicsParticleObject>();

            cam.Pos = new Vector2(500.0f, 200.0f);


            // 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));

            floorTexture = Content.Load <Texture2D>("floor");



            floor               = new DrawablePhysicsObject(world, floorTexture, new Vector2(GraphicsDevice.Viewport.Width, floorTexture.Height), 1000);
            floor.Position      = new Vector2(GraphicsDevice.Viewport.Width / 2.0f, GraphicsDevice.Viewport.Height - 50);
            floor.body.BodyType = BodyType.Static;

            wall                    = new DrawablePhysicsObject(world, floorTexture, new Vector2(floorTexture.Width, floorTexture.Height), 1000);
            wall.Position           = new Vector2(GraphicsDevice.Viewport.Width / 2.0f, GraphicsDevice.Viewport.Height - 400);
            wall.body.FixedRotation = true;
            wall.body.Rotation      = 15.5f;
            wall.body.BodyType      = BodyType.Static;


            platform               = new DrawablePhysicsObject(world, floorTexture, new Vector2(GraphicsDevice.Viewport.Width / 2, floorTexture.Height), 1000);
            platform.Position      = new Vector2(GraphicsDevice.Viewport.Width / 2.0f, GraphicsDevice.Viewport.Height / 2);
            platform.body.BodyType = BodyType.Static;


            player = new DrawablePhysicsObject(world, null, new Vector2(36.0f, 48.0f), 1000);
            //  player = BodyFactory.CreateRectangle(world, 36*pixelToUnit, 48*pixelToUnit, 1f);
            player.Position = new Vector2(200.0f, 100.0f);
            //    player.body.body.Rotation = 90;
            player.body.BodyType = BodyType.Dynamic;



            crateList = new List <DrawablePhysicsObject>();

            prevKeyboardState = Keyboard.GetState();


            Animation playerAnimation = new Animation();
            Texture2D playerTexture   = Content.Load <Texture2D>("shipAnimation");
            Texture2D spriteTexture   = Content.Load <Texture2D>("jasperrun");

            playerAnimation.Initialize(spriteTexture, new Vector2(0, 0), 32, 48, 4, 100, Color.White, 1f, true);

            //     playerAnimation.Initialize(playerTexture, new Vector2(0, 0), 115, 69, 8, 30, Color.White, 1f, true);
            playerObj.Initialize(playerAnimation, new Vector2(player.Position.X, player.Position.Y));


            List <Texture2D> textures = new List <Texture2D>();

            textures.Add(Content.Load <Texture2D>("white"));
            white = Content.Load <Texture2D>("white");

            particleEngine = new ParticleEngine(textures, new Vector2(playerObj.Position.X, playerObj.Position.Y), world);

            // TODO: use this.Content to load your game content here
        }