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

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

            robot = new FlxSprite(60, 60);
            robot.loadGraphic("flixel/surt/race_or_die", true, false, 64, 64);
            robot.addAnimation("static", new int[] { 0 }, 12, true);
            robot.play("static");
            robot.angle  = 0;
            robot.width  = 32;
            robot.height = 32;
            robot.setOffset(12, 12);
            robot.health = 100;
            robot.alpha  = 0.1f;

            add(robot);

            bar = new FlxBar(30, 30, FlxBar.FILL_LEFT_TO_RIGHT, 100, 10, robot, "rad", 0, 100, true);
            add(bar);

            bar2 = new FlxBar(60, 90, FlxBar.FILL_LEFT_TO_RIGHT, 20, 2, null, "health", 0, 100, false);
            bar2.loadCustomEmptyGraphic("flixel/initials/healthBar");
            bar2.emptyBar.offset.X = 2;
            bar2.emptyBar.offset.Y = 3;
            add(bar2);
        }
Example #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);
            }
        }
Example #3
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);
        }
Example #4
0
        override public void create()
        {
            FlxG.resetHud();
            FlxG.showHud();

            FlxG.backColor = Color.LightGray;

            base.create();

            string levelData = FlxU.randomString(10);

            FlxG.log("levelData: " + levelData);

            makeCave(0.1f, Color.Black);
            makeCave(0.5f, new Color(0.98f, 1.0f, 0.95f));
            makeCave2(1.0f, Color.Green);

            spaceShip = new FlxSprite(60, 60);
            spaceShip.loadGraphic(FlxG.Content.Load <Texture2D>("flixel/surt/spaceship_32x32"), true, false, 32, 32);
            spaceShip.addAnimation("Static", new int[] { 0 }, 36, true);
            spaceShip.addAnimation("Transform", new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39 }, 36, false);
            spaceShip.play("Static");

            spaceShip.setDrags(1100, 1100);
            add(spaceShip);

            FlxG.follow(spaceShip, 10.0f);
            FlxG.followBounds(0, 0, 50 * 16, 40 * 16);
        }
Example #5
0
        override public void create()
        {
            FlxG.backColor = Color.DarkBlue;



            base.create();


            FlxG.resetHud();


            string textInfo = "";

            textInfo  = "Choose:\n";
            textInfo += "1. Camera Test State\n";
            textInfo += "2. Cave Tiles Test State\n";


            FlxG.setHudText(1, textInfo);
            FlxG.setHudTextPosition(1, 20, 20);
            FlxG.setHudTextScale(1, 3);
            FlxG.setHudGamepadButton(FlxHud.TYPE_KEYBOARD, FlxHud.Keyboard_1, FlxG.width - 40, 30);

            FlxG.showHud();
        }
Example #6
0
        override public void create()
        {
            base.create();

            FlxG.mouse.show(FlxG.Content.Load <Texture2D>("flixel/cursor"));

            mouseInfo           = new FlxText(1, 1, 100);
            mouseInfo.text      = "Info:";
            mouseInfo.alignment = FlxJustification.Left;
            mouseInfo.setScrollFactors(1, 1);
            add(mouseInfo);

            FlxG.resetHud();

            string textInfo = "";

            textInfo  = "Choose:\n";
            textInfo += "1. Cheat State\n";
            textInfo += "2. Cave State\n";
            textInfo += "3. Race Or Die\n";
            textInfo += "4. Tweens\n";
            textInfo += "5. Robot Football\n";
            textInfo += "6. Animation Callbacks\n";
            textInfo += "7. FlxPath \n";
            textInfo += "8. Physics \n";
            textInfo += "9. Angle And Velocity\n";
            textInfo += "F2. Physics 2\n";
            textInfo += "F3. Island \n";
            textInfo += "F4. Island 2 \n";
            textInfo += "F5. Physics Hockey \n";
            textInfo += "F6. FlxBar \n";
            textInfo += "F7. Scrolling Test \n";

            textInfo += "Q. Garbage Tests \n";
            FlxG.setHudText(1, textInfo);
            FlxG.setHudTextPosition(1, 50, 20);
            FlxG.setHudTextScale(1, 2);
            FlxG.setHudGamepadButton(FlxHud.TYPE_KEYBOARD, FlxHud.Keyboard_1, FlxG.width - 120, 30);

            FlxG.showHud();

            /*
             *          FlxSprite logo = new FlxSprite(12, 12);
             *          logo.loadGraphic("flixel/surt/race_or_die", true, false, 64, 64);
             *          logo.addAnimation("Static", new int[] { 8 }, 0, true);
             *          logo.play("Static");
             *          logo.setDrags(5, 5);
             *          add(logo);
             */
        }
Example #7
0
        //PlayHud localHud;

        override public void create()
        {
            FlxG.backColor = Color.Black;

            base.create();

            FlxG.mouse.show(FlxG.Content.Load <Texture2D>("initials/crosshair"));

            //FlxG.backColor = new Color(0xc2, 0x88, 0x83);

            base.create();

            FlxG.resetHud();
            FlxG.showHud();

            _nameEntry = new FlxText(60, 150, FlxG.width);
            _nameEntry.setFormat(null, 2, Color.White, FlxJustification.Left, Color.White);
            _nameEntry.text = "";
            add(_nameEntry);

            try
            {
                _nameEntry.text = LoadFromDevice();
            }
            catch
            {
                Console.WriteLine("Cannot load name from file");
            }

            FlxG.showHud();
            FlxG.setHudText(1, "Enter name, use @ symbol to specify Twitter handle.\nPress enter when complete.");
            FlxG.setHudTextScale(1, 2);
            FlxG.setHudTextScale(3, 2);
            FlxG.setHudTextPosition(1, 30 * 2, 40 * 2);
            FlxG.setHudTextPosition(3, 10 * 2, 20 * 2);

            //play = new FlxButton(FlxG.width / 2 - 50, FlxG.height - 30, advanceToNextState, FlxButton.ControlPadA);
            ////play = new FlxButton(0, FlxG.height - 30, advanceToNextState, FlxButton.ControlPadA);

            //play.loadGraphic((new FlxSprite()).loadGraphic(FlxG.Content.Load<Texture2D>("fourchambers/menuButton"), false, false, 100, 20), (new FlxSprite()).loadGraphic(FlxG.Content.Load<Texture2D>("fourchambers/menuButtonPressed"), false, false, 100, 20));

            //play.loadText(new FlxText(2, 2, 100, "Enter"), new FlxText(2, 2, 100, "ENTER"));
            //add(play);

            FlxG.setHudGamepadButton(FlxHud.TYPE_XBOX, FlxButton.ControlPadA, FlxG.width / 2 + 54, FlxG.height - 100);

            FlxG.flash.start(Color.Black, 1.5f);
        }
Example #8
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);
        }
Example #9
0
        override public void create()
        {
            base.create();

            FlxG.resetHud();

            String hudText = "Press \n";

            hudText += "Q. Back \n";
            hudText += "W. Bounce \n";
            hudText += "E. Circular \n";
            hudText += "R. Cubic \n";
            hudText += "A. Elastic \n";
            hudText += "S. Exponential \n";
            hudText += "D. Linear \n";
            hudText += "F. Quadratic \n";
            hudText += "Z. Quartic \n";
            hudText += "X. Quintic \n";
            hudText += "C. Sinusoidal";

            FlxG.setHudText(2, hudText);

            FlxG.mouse.hide();

            //Define the time it takes to move the car across the screen.
            timeToMove = 2.5f;

            //Define the distance the car will move.
            driveDistance = 350;

            //Define the starting positions of the cars.
            car1Pos = new Vector2(20, 0);
            car2Pos = new Vector2(20, 50);
            car3Pos = new Vector2(20, 100);
            car4Pos = new Vector2(20, 150);
            car5Pos = new Vector2(20, 200);
            car6Pos = new Vector2(20, 250);

            redCarText      = new FlxText(car1Pos.X, car1Pos.Y + 40, FlxG.width);
            redCarText.text = "Back.EaseInOut";
            redCarText.setFormat(null, 1, Color.Red, FlxJustification.Left, Color.Black);
            add(redCarText);

            yellowCarText      = new FlxText(car2Pos.X, car2Pos.Y + 40, FlxG.width);
            yellowCarText.text = "Bounce.EaseInOut";
            yellowCarText.setFormat(null, 1, Color.Yellow, FlxJustification.Left, Color.Black);
            add(yellowCarText);

            greenCarText      = new FlxText(car3Pos.X, car3Pos.Y + 40, FlxG.width);
            greenCarText.text = "Circular.EaseInOut";
            greenCarText.setFormat(null, 1, Color.Green, FlxJustification.Left, Color.Black);
            add(greenCarText);

            blueCarText      = new FlxText(car4Pos.X, car4Pos.Y + 40, FlxG.width);
            blueCarText.text = "Cubic.EaseInOut";
            blueCarText.setFormat(null, 1, Color.Blue, FlxJustification.Left, Color.Black);
            add(blueCarText);

            purpleCarText      = new FlxText(car5Pos.X, car5Pos.Y + 40, FlxG.width);
            purpleCarText.text = "Elastic.EaseInOut - Loop";
            purpleCarText.setFormat(null, 1, Color.Purple, FlxJustification.Left, Color.Black);
            add(purpleCarText);

            lightGreenCarText      = new FlxText(car6Pos.X, car6Pos.Y + 40, FlxG.width);
            lightGreenCarText.text = "Exponential.EaseInOut - Ping Pong";
            lightGreenCarText.setFormat(null, 1, Color.LightGreen, FlxJustification.Left, Color.Black);
            add(lightGreenCarText);



            carsGroup = new FlxGroup();
            add(carsGroup);

            redCar = new FlxSprite(car1Pos.X, car1Pos.Y);
            redCar.loadGraphic(FlxG.Content.Load <Texture2D>("flixel/surt/race_or_die"), true, false, 64, 64);
            redCar.addAnimation("Static", new int[] { 6 }, 0, true);
            redCar.play("Static");
            redCar.angle = 180;
            carsGroup.add(redCar);

            redCarTween      = new Tweener(car1Pos.X, driveDistance, TimeSpan.FromSeconds(timeToMove), Back.EaseInOut);
            redCarTween.Loop = true;
            redCarTween.Start();

            yellowCar = new FlxSprite(car2Pos.X, car2Pos.Y);
            yellowCar.loadGraphic(FlxG.Content.Load <Texture2D>("flixel/surt/race_or_die"), true, false, 64, 64);
            yellowCar.addAnimation("Static", new int[] { 7 }, 0, true);
            yellowCar.play("Static");
            yellowCar.angle = 180;
            carsGroup.add(yellowCar);

            yellowCarTween      = new Tweener(car2Pos.X, driveDistance, TimeSpan.FromSeconds(timeToMove), Bounce.EaseInOut);
            yellowCarTween.Loop = true;

            greenCar = new FlxSprite(car3Pos.X, car3Pos.Y);
            greenCar.loadGraphic(FlxG.Content.Load <Texture2D>("flixel/surt/race_or_die"), true, false, 64, 64);
            greenCar.addAnimation("Static", new int[] { 8 }, 0, true);
            greenCar.play("Static");
            greenCar.angle = 180;
            carsGroup.add(greenCar);

            greenCarTween      = new Tweener(car3Pos.X, driveDistance, TimeSpan.FromSeconds(timeToMove), XNATweener.Circular.EaseInOut);
            greenCarTween.Loop = true;


            blueCar = new FlxSprite(car4Pos.X, car4Pos.Y);
            blueCar.loadGraphic(FlxG.Content.Load <Texture2D>("flixel/surt/race_or_die"), true, false, 64, 64);
            blueCar.addAnimation("Static", new int[] { 9 }, 0, true);
            blueCar.play("Static");
            blueCar.angle = 180;
            carsGroup.add(blueCar);

            blueCarTween      = new Tweener(car4Pos.X, driveDistance, TimeSpan.FromSeconds(timeToMove), XNATweener.Cubic.EaseInOut);
            blueCarTween.Loop = true;


            purpleCar = new FlxSprite(car5Pos.X, car5Pos.Y);
            purpleCar.loadGraphic(FlxG.Content.Load <Texture2D>("flixel/surt/race_or_die"), true, false, 64, 64);
            purpleCar.addAnimation("Static", new int[] { 10 }, 0, true);
            purpleCar.play("Static");
            purpleCar.angle = 180;
            carsGroup.add(purpleCar);

            purpleCarTween      = new Tweener(car5Pos.X, driveDistance, TimeSpan.FromSeconds(timeToMove), XNATweener.Elastic.EaseInOut);
            purpleCarTween.Loop = true;


            lightGreenCar = new FlxSprite(car6Pos.X, car6Pos.Y);
            lightGreenCar.loadGraphic(FlxG.Content.Load <Texture2D>("flixel/surt/race_or_die"), true, false, 64, 64);
            lightGreenCar.addAnimation("Static", new int[] { 11 }, 0, true);
            lightGreenCar.play("Static");
            lightGreenCar.angle = 180;
            carsGroup.add(lightGreenCar);

            lightGreenCarTween          = new Tweener(car6Pos.X, driveDistance, TimeSpan.FromSeconds(timeToMove), XNATweener.Exponential.EaseInOut);
            lightGreenCarTween.PingPong = true;

            Console.WriteLine(lightGreenCar.GetType().AssemblyQualifiedName);


            String myClass = "org.flixel.examples.CarSprite";

            var type = Type.GetType(myClass);

            Console.WriteLine(type);
            var myObject = (FlxSprite)Activator.CreateInstance(type, 800, 400);

            //Console.WriteLine(myObject.GetType().AssemblyQualifiedName);
            //myObject.x = 300;
            //myObject.y = 300;
            add(myObject);
        }
Example #10
0
        override public void create()
        {
            base.create();

            FlxG.resetHud();

            makeCave(1.0f, Color.White);

            FlxSprite avatar = new FlxSprite(0, FlxG.height - 64);

            avatar.loadGraphic(FlxG.Content.Load <Texture2D>("flixel/surt/race_or_die"), true, false, 64, 64);
            avatar.addAnimation("Static", new int[] { 2 }, 0, true);
            avatar.play("Static");
            avatar.setScrollFactors(0, 0);

            add(avatar);

            p = new FlxPath(null);
            addPathPointWithMarker(40.0f, 40.0f, 0);
            addPathPointWithMarker(522.67800098f, 342.106739267f, 1);
            addPathPointWithMarker(582.8467536f, 603.25142048f, 2);
            addPathPointWithMarker(531.13384868f, 263.27163512f, 3);
            addPathPointWithMarker(1447.02681801f, 449.15789055f, 4);
            addPathPointWithMarker(1201.74908191f, 528.33347167f, 5);
            addPathPointWithMarker(147.07640576f, 672.46462447f, 6);
            addPathPointWithMarker(199.62346884f, 584.58110087f, 7);
            addPathPointWithMarker(108.19931517f, 355.52333218f, 8);
            addPathPointWithMarker(698.584671041f, 174.70156601f, 9);

            for (int i = 0; i < 9; i++)
            {
                FlxLine line = new FlxLine(0, 0, new Vector2(p.nodes[i].X, p.nodes[i].Y), new Vector2(p.nodes[i + 1].X, p.nodes[i + 1].Y), Color.White, 2);
                add(line);
            }

            car = new FlxSprite(40, 40);
            car.loadGraphic(FlxG.Content.Load <Texture2D>("flixel/surt/race_or_die"), true, false, 64, 64);
            //car.addAnimation("Static", new int[] { 8 }, 0, true);
            //car.play("Static");
            car.frame = 8;
            car.setDrags(5, 5);
            add(car);

            car.path            = p;
            car.pathCornering   = 5.0f;
            car.pathAngleOffset = 180;
            //car.pathSpeed = 500.0f;
            car.followPath(p, 250.0f, FlxSprite.PATH_LOOP_FORWARD, true);

            FlxG.follow(car, 5.0f);
            FlxG.followBounds(0, 0, 100 * 16, 100 * 16);


            for (int i = 0; i < 7; i++)
            {
                p = new FlxPath(null);
                p.add(40.0f, 40.0f);
                p.add(522.67800098f + FlxU.random(1, 100), 342.106739267f + FlxU.random(1, 100));
                p.add(582.8467536f, 603.25142048f + FlxU.random(1, 1200));
                p.add(531.13384868f, 263.27163512f + FlxU.random(1, 1200));
                p.add(1447.02681801f, 449.15789055f + FlxU.random(1, 1200));
                p.add(1201.74908191f, 528.33347167f + FlxU.random(1, 1200));
                p.add(147.07640576f, 672.46462447f + FlxU.random(1, 1200));
                p.add(199.62346884f, 584.58110087f + FlxU.random(1, 1200));
                p.add(108.19931517f, 355.52333218f + FlxU.random(1, 1200));
                p.add(698.584671041f, 174.70156601f + FlxU.random(1, 2100));


                car = new FlxSprite(40, 40);
                car.loadGraphic(FlxG.Content.Load <Texture2D>("flixel/surt/race_or_die"), true, false, 64, 64);
                //car.addAnimation("Static", new int[] { 8 }, 0, true);
                //car.play("Static");
                car.frame = 6 + i;
                car.setDrags(5, 5);
                add(car);

                car.path            = p;
                car.pathCornering   = 5.0f;
                car.pathAngleOffset = 180;
                //car.pathSpeed = 500.0f;
                car.followPath(p, 50.0f + (i * 30), FlxSprite.PATH_LOOP_FORWARD, true);
            }
        }
Example #11
0
        override public void create()
        {
            FlxG.resetHud();
            FlxG.hideHud();

            FlxG.backColor = FlxColor.ToColor("#3cbcfc");

            base.create();

            FlxCaveGeneratorExt caveExt = new FlxCaveGeneratorExt(40, 40, 0.514f, 2);

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

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

            Color[] colors = new Color[] {
                FlxColor.ToColor("#7C7C7C"),

                FlxColor.ToColor("#0000FC"),

                FlxColor.ToColor("#0000BC"),

                FlxColor.ToColor("#4428BC"),

                FlxColor.ToColor("#940084"),

                FlxColor.ToColor("#A80020"),

                FlxColor.ToColor("#A81000"),

                FlxColor.ToColor("#881400"),

                FlxColor.ToColor("#503000"),

                FlxColor.ToColor("#007800"),

                FlxColor.ToColor("#006800"),

                FlxColor.ToColor("#005800"),

                FlxColor.ToColor("#004058"),

                FlxColor.ToColor("#000000"),

                FlxColor.ToColor("#000000"),

                FlxColor.ToColor("#000000"),

                FlxColor.ToColor("#BCBCBC"),

                FlxColor.ToColor("#0078F8"),

                FlxColor.ToColor("#0058F8"),

                FlxColor.ToColor("#6844FC"),

                FlxColor.ToColor("#D800CC"),

                FlxColor.ToColor("#E40058"),

                FlxColor.ToColor("#F83800"),

                FlxColor.ToColor("#E45C10"),

                FlxColor.ToColor("#AC7C00"),

                FlxColor.ToColor("#00B800"),

                FlxColor.ToColor("#00A800"),

                FlxColor.ToColor("#00A844"),

                FlxColor.ToColor("#008888"),

                FlxColor.ToColor("#000000"),

                FlxColor.ToColor("#000000"),

                FlxColor.ToColor("#000000"),

                FlxColor.ToColor("#F8F8F8"),

                FlxColor.ToColor("#3CBCFC"),

                FlxColor.ToColor("#6888FC"),

                FlxColor.ToColor("#9878F8"),

                FlxColor.ToColor("#F878F8"),

                FlxColor.ToColor("#F85898"),

                FlxColor.ToColor("#F87858"),

                FlxColor.ToColor("#FCA044"),

                FlxColor.ToColor("#F8B800"),

                FlxColor.ToColor("#B8F818"),

                FlxColor.ToColor("#58D854"),

                FlxColor.ToColor("#58F898"),

                FlxColor.ToColor("#00E8D8"),

                FlxColor.ToColor("#787878"),

                FlxColor.ToColor("#000000"),

                FlxColor.ToColor("#000000"),

                FlxColor.ToColor("#FCFCFC"),

                FlxColor.ToColor("#A4E4FC"),

                FlxColor.ToColor("#B8B8F8"),

                FlxColor.ToColor("#D8B8F8"),

                FlxColor.ToColor("#F8B8F8"),

                FlxColor.ToColor("#F8A4C0"),

                FlxColor.ToColor("#F0D0B0"),

                FlxColor.ToColor("#FCE0A8"),

                FlxColor.ToColor("#F8D878"),

                FlxColor.ToColor("#D8F878"),

                FlxColor.ToColor("#B8F8B8"),

                FlxColor.ToColor("#B8F8D8"),

                FlxColor.ToColor("#00FCFC"),

                FlxColor.ToColor("#F8D8F8"),

                FlxColor.ToColor("#000000"),

                FlxColor.ToColor("#000000")
            };

            #endregion

            tileGrp  = new FlxGroup();
            waterGrp = new FlxGroup();
            pellets  = new FlxGroup();

            Vector2 startPos = new Vector2(0, 0);

            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)
                    {
                        if (startPos.X == 0)
                        {
                            startPos = new Vector2(i * 8, y * 8);
                        }
                        FlxSprite x = new FlxSprite(i * 8, y * 8);
                        //x.createGraphic(8, 8, colors[Convert.ToInt32(caveLevel[y, i])]);
                        x.loadGraphic("autotilesIsland", false, false, 8, 8);
                        //x.color = colors[Convert.ToInt32(caveLevel[y, i])];

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

                        if (FlxU.random() < 0.02f)
                        {
                            FlxSprite xx = new FlxSprite(i * 8, y * 8);
                            xx.createGraphic(8, 8, Color.Red);
                            pellets.add(xx);
                        }
                    }
                    else
                    {
                        FlxSprite x = new FlxSprite(i * 8, y * 8);
                        x.loadGraphic("water", false, false, 8, 8);
                        x.addAnimation("flow", new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }, (int)FlxU.random(1, 7), true);
                        x.play("flow");

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

                //Console.WriteLine();
            }

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


            add(tileGrp);
            add(waterGrp);
            add(pellets);

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

            shadow = new FlxSprite(startPos.X, startPos.Y);
            shadow.createGraphic(8, 8, Color.Black);
            shadow.debugName = "onground";
            shadow.alpha     = 0.5f;
            add(shadow);

            player = new FlxSprite(startPos.X, startPos.Y);
            player.createGraphic(8, 8, colors[12]);
            add(player);

            //FlxG.showHud();

            FlxG.follow(shadow, 20.0f);
            FlxG.followBounds(0, 0, 320, 320);
        }
Example #12
0
        override public void create()
        {
            FlxG.resetHud();
            FlxG.hideHud();

            FlxG.backColor = Color.DarkTurquoise;

            base.create();



            FlxCaveGeneratorExt caveExt = new FlxCaveGeneratorExt(80, 120, 0.49f, 1);

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

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

            Color[] colors = new Color[] {
                Color.Aqua,
                Color.ForestGreen,
                Color.Yellow,
                Color.Yellow,
                Color.Yellow,
                Color.Yellow,
                Color.Yellow,
                Color.Yellow,
                Color.Yellow,
                Color.Yellow,
                Color.Yellow,
                Color.Yellow,
                Color.Yellow,
                Color.Yellow,
                Color.Yellow,
                Color.Green,
                Color.Yellow,
                Color.Yellow,
                Color.Yellow,
                Color.Yellow,
                Color.Yellow,
                Color.Yellow,
                Color.Yellow,
                Color.Yellow, Color.Yellow, Color.Yellow, Color.Yellow, Color.Yellow, Color.Yellow, Color.Yellow, Color.Yellow, Color.Yellow, Color.Yellow, Color.Yellow, Color.Yellow, Color.Yellow, Color.Yellow, Color.Yellow, Color.Yellow, Color.Yellow, Color.Yellow, Color.Yellow, Color.Yellow, Color.Yellow, Color.Yellow, Color.Yellow, Color.Yellow, Color.Yellow, Color.Yellow, Color.Yellow, Color.Yellow, Color.Yellow, Color.Yellow, Color.Yellow, Color.Yellow, Color.Yellow, Color.Yellow, Color.Yellow, Color.Yellow, Color.Yellow, Color.Yellow, Color.Yellow, Color.Yellow, Color.Yellow, Color.Yellow, Color.Yellow, Color.Yellow, Color.Yellow, Color.Yellow, Color.Yellow, Color.Yellow, Color.Yellow
            };


            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)
                    {
                        FlxSprite x = new FlxSprite(i * 8, y * 8);
                        //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.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);
        }
Example #13
0
        override public void create()
        {
            FlxG.resetHud();
            FlxG.hideHud();

            FlxG.backColor = Color.DarkTurquoise;

            base.create();



            FlxCaveGeneratorExt caveExt = new FlxCaveGeneratorExt(100, 60, 0.42f, 3);

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

            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)
                    {
                        FlxSprite x = new FlxSprite(i * 8, y * 8);
                        //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.frame = Convert.ToInt32(caveLevel[y, i]);
                        //x.scale = 2;
                        x.angularDrag = 250;
                        //x.setOffset(4, 4);

                        x.@fixed = true;
                        tileGrp.add(x);
                    }
                    //Console.Write(toPrint);
                }

                //Console.WriteLine();
            }

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


            add(tileGrp);

            boats = new FlxGroup();

            for (int i = 0; i < 20; i++)
            {
                Boat b = new Boat((int)FlxU.random(0, FlxG.width), (int)FlxU.random(0, FlxG.height));
                b.velocity.X = FlxU.random(-40, 40);
                b.velocity.Y = FlxU.random(-40, 40);


                boats.add(b);
            }

            add(boats);
        }