Exemple #1
0
        override public void create()
        {
            base.create();

            FlxG.resetHud();
            FlxG.hideHud();

            _world.Gravity.Y = 0;

            team1 = new FlxGroup();
            team2 = new FlxGroup();

            puck = new FarSprite(FlxG.width / 2, FlxG.height / 2, _world);
            puck.createGraphic(20, 20, Color.Green);
            puck.attachCircle(20, 20);
            add(puck);

            puck._body.ApplyLinearImpulse(new Vector2(FlxU.random(-15000, 15000), FlxU.random(-15000, 15000)));


            for (int i = 0; i < 6; i++)
            {
                FarSprite p1 = new FarSprite(i * 80, (int)FlxU.random(0, FlxG.height), _world);

                p1.createGraphic(4, 40, Color.Red);

                p1.attachRectangle(4, 40);

                team1.add(p1);
            }

            add(team1);
            add(team2);
        }
Exemple #2
0
        override public void create()
        {
            base.create();

            //FlxG.hideHud();
            FlxG.resetHud();

            _world = new World(new Vector2(0, 980.0f));

            _ground          = BodyFactory.CreateRectangle(_world, 3000, 20, 1.0f, new Vector2(0, 700), null);
            _ground.BodyType = BodyType.Static;

            g1 = new FlxSprite(0, 700);
            g1.loadGraphic("flixel/diagnostic/testpalette", true, false, 1000, 20);
            add(g1);

            for (int i = 0; i < 40; i++)
            {
                FarSprite f = new FarSprite(Convert.ToInt32(FlxU.random(90, 800)), Convert.ToInt32(FlxU.random(-600, 0)), _world);
                f.loadGraphic("flixel/initials/crate_80x60", true, false, FlxU.randomInt(20, 40), FlxU.randomInt(40, 60));
                f._body.AngularVelocity = FlxU.randomInt(0, 5);
                add(f);
            }


            List <Dictionary <string, string> > completeSet = new List <Dictionary <string, string> >();

            string currentLevel = "l" + FlxG.level.ToString();

            XDocument xdoc = XDocument.Load("Content/flixel/ogmo/PhysicsLevel.oel");

            // Load level main stats.
            XElement xelement = XElement.Load("Content/flixel/ogmo/PhysicsLevel.oel");
            IEnumerable <XAttribute> attList =
                from at in xelement.Attributes()
                select at;

            foreach (XAttribute xAttr in attList)
            {
                //Console.WriteLine(xAttr.Name.ToString() + "  " + xAttr.Value.ToString());
                //levelAttrs.Add(xAttr.Name.ToString(), xAttr.Value.ToString());
            }

            foreach (XElement xEle in xdoc.Descendants("level").Descendants("NewLayer0").Elements())
            {
                Console.WriteLine(xEle.Name.ToString() + "  " + xEle.Attribute("x").ToString().Split('=')[1].Replace('\"', ' '));


                FarSprite f = new FarSprite(
                    Convert.ToInt32(xEle.Attribute("x").ToString().Split('=')[1].Replace('\"', ' ')) + 500,
                    Convert.ToInt32(xEle.Attribute("y").ToString().Split('=')[1].Replace('\"', ' ')) + 220,
                    _world);

                f.loadGraphic("flixel/initials/crate_80x60", true, false,
                              Convert.ToInt32(xEle.Attribute("width").ToString().Split('=')[1].Replace('\"', ' ')),
                              Convert.ToInt32(xEle.Attribute("height").ToString().Split('=')[1].Replace('\"', ' ')));

                add(f);
            }
        }
Exemple #3
0
        override public void update()
        {
            if (FlxG.mouse.justPressed() || FlxU.random() < 0.031f)
            {
                FarSprite f = new FarSprite(FlxG.mouse.screenX, FlxG.mouse.screenY, _world);
                f.loadGraphic("flixel/initials/crate_80x60", true, false, FlxU.randomInt(20, 40), FlxU.randomInt(40, 60));
                //f._body.AngularVelocity = FlxU.randomInt(0, 5);
                //f._body.ApplyLinearImpulse(new Vector2(FlxG.mouse.screenX, FlxG.mouse.screenY), new Vector2(FlxG.mouse.screenX, FlxG.mouse.screenY));
                //f._body.ApplyLinearImpulse(new Vector2(FlxU.random(-15000, 15000), FlxU.random(-15000, 15000)));
                //f._body.LinearVelocity = new Vector2(100000000000000000, 1000000000000000) ;


                f._body.ApplyLinearImpulse(new Vector2(int.MaxValue, int.MaxValue * -1));
                f._body.Mass = 2100;
                add(f);
            }

            _world.Step(Math.Min((float)FlxG.elapsedAsGameTime.ElapsedGameTime.TotalSeconds, (1f / 30f)));

            base.update();
        }
Exemple #4
0
        override public void create()
        {
            base.create();

            FlxG.hideHud();

            _world = new World(new Vector2(0, 98.0f));

            for (int i = 0; i < 10; i++)
            {
                Vector2   v = new Vector2((int)FlxU.random(0, 400), (int)FlxU.random(0, 200));
                FarSprite f = new FarSprite((int)v.X, (int)v.Y, _world);
                f.loadGraphic("flixel/initials/crate_80x60", true, false, (int)FlxU.random(10, 20), (int)FlxU.random(10, 20));
                f._body.Mass = 500f;
                //f._body.AngularVelocity = FlxU.random(-20,20);
                add(f);
            }

            for (int i = 0; i < 10; i++)
            {
                Vector2      v = new Vector2((int)FlxU.random(0, 400), (int)FlxU.random(0, 200));
                FarTileblock f = new FarTileblock((int)v.X, (int)v.Y, (int)FlxU.random(10, 40), (int)FlxU.random(10, 40), _world);
                f.loadTiles("flixel/initials/crate_80x60", 5, 5, 0);
                //f.loadGraphic("flixel/initials/crate_80x60", true, false, (int)FlxU.random(10, 20), (int)FlxU.random(10, 20));
                f._body.Mass            = 500f;
                f._body.AngularVelocity = FlxU.random(-20, 20);
                f.moves = true;
                add(f);
            }

            _ground          = BodyFactory.CreateRectangle(_world, 2000, 20, 1.0f, new Vector2(0, 350), null);
            _ground.BodyType = BodyType.Static;

            g1 = new FlxSprite(0, 340);
            g1.loadGraphic("flixel/diagnostic/testpalette", true, false, 1000, 20);
            add(g1);
        }
Exemple #5
0
        override public void create()
        {
            FlxG.resetHud();
            FlxG.hideHud();

            FlxG.backColor = Color.DarkTurquoise;

            base.create();

            _world = new World(new Vector2(0, 0));

            FlxCaveGeneratorExt caveExt = new FlxCaveGeneratorExt(20, 20, 0.49f, 1);

            string[,] caveLevel = caveExt.generateCaveLevel();

            //Optional step to print cave to the console.
            //caveExt.printCave(caveLevel);

            tileGrp = new FlxGroup();

            for (int i = 0; i < caveLevel.GetLength(1); i++)
            {
                for (int y = 0; y < caveLevel.GetLength(0); y++)
                {
                    //string toPrint = tiles[y, i];
                    if (Convert.ToInt32(caveLevel[y, i]) != 0)
                    {
                        FarSprite x = new FarSprite(100 + (i * 10), 10 + (y * 10), _world);
                        //x.createGraphic(8, 8, colors[Convert.ToInt32(caveLevel[y, i])]);
                        x.loadGraphic("flixel/autotilesIsland", false, false, 8, 8);
                        //x.color = colors[Convert.ToInt32(caveLevel[y, i])];

                        x._body.BodyType = BodyType.Dynamic;

                        //_body.BodyType = BodyType.Dynamic;

                        x.frame = Convert.ToInt32(caveLevel[y, i]);
                        //x.scale = 2;
                        //x.angularDrag = 250;
                        //
                        //x.setOffset(4, 4);

                        tileGrp.add(x);
                    }
                    //Console.Write(toPrint);
                }

                //Console.WriteLine();
            }

            //string newMap = caveExt.convertMultiArrayStringToString(caveLevel);


            add(tileGrp);

            m = new FlxSprite(0, 0);
            m.loadGraphic("flixel/cursor");
            add(m);


            _ground          = BodyFactory.CreateRectangle(_world, 2000, 20, 1.0f, new Vector2(0, 350), null);
            _ground.BodyType = BodyType.Static;

            //g1 = new FlxSprite(0, 340);
            //g1.loadGraphic("flixel/diagnostic/testpalette", true, false, 1000, 20);
            //add(g1);
        }