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

            FlxG.setHudGamepadButton(FlxHud.TYPE_KEYBOARD, FlxHud.Keyboard_Arrow_Left, 10, 110);
            FlxG.setHudGamepadButton(FlxHud.TYPE_KEYBOARD_DIRECTION, FlxHud.Keyboard_Arrow_Right, 110, 110);



            FlxSprite bg = new FlxSprite(0, 0);

            bg.createGraphic(FlxG.width, FlxG.width, new Color(0.05f, 0.05f, 0.08f));
            bg.setScrollFactors(0, 0);
            add(bg);

            stars = new FlxGroup();


            // Make a starfield to fly through.
            for (int i = 0; i < 100; i++)
            {
                star = new FlxSprite(FlxU.random(0, FlxG.width), FlxU.random(0, FlxG.height));
                star.createGraphic(3, 3, Color.White);
                star.velocity.Y = FlxU.random(20, 100);
                star.velocity.X = 0;
                stars.add(star);
            }

            add(stars);

            spaceShip = new FlxSprite(FlxG.width / 2, FlxG.height / 2);
            spaceShip.loadGraphic(FlxG.Content.Load <Texture2D>("flixel/surt/spaceship_32x32"), true, false, 32, 32);

            //Add some animations to our Spaceship
            spaceShip.addAnimation("static", new int[] { 0 }, 36, true);

            spaceShip.addAnimation("transform1", new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 }, 12, false);
            spaceShip.addAnimation("transform2", new int[] { 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39 }, 12, false);
            spaceShip.addAnimation("transform3", new int[] { 40, 41, 42 }, 12, false);


            //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}, 24, false);
            //spaceShip.addAnimation("reverse", 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 }, 24, false);

            spaceShip.addAnimation("transform", spaceShip.generateFrameNumbersBetween(0, 39), 24, false);
            spaceShip.addAnimation("reverse", spaceShip.generateFrameNumbersBetween(39, 0), 24, false);

            spaceShip.play("static");

            //Add an animation callback - This will call Pulse on every frame.
            spaceShip.addAnimationCallback(pulse);

            spaceShip.scale = 3;
            spaceShip.setDrags(1100, 1100);
            add(spaceShip);

            jets = new FlxEmitter();

            jets.setSize(5, 50);
            jets.createSprites(FlxG.Content.Load <Texture2D>("flixel/diagnostic/testpalette"), 100, true, 0.0f, 0.0f);
            jets.setXSpeed(-110, 110);
            jets.setYSpeed(40, 80);

            add(jets);
            jets.at(spaceShip);
        }
예제 #2
0
        public Hud(int xPos, int yPos)
            : base(xPos, yPos)
        {
            loadGraphic(FlxG.Content.Load <Texture2D>("Lemonade/currentChar"), true, false, 14, 28);

            setScrollFactors(0, 0);

            addAnimation("andre", new int[] { 2 }, 0, true);

            play("andre");


            coin = new Coin(FlxG.width - 24, 2, true);
            coin.setScrollFactors(0, 0);

            coinCounter = new FlxText(FlxG.width - 36, 10, 100);
            coinCounter.setFormat(null, 1, Lemonade_Globals.GAMEBOY_COLOR_4, FlxJustification.Left, Lemonade_Globals.GAMEBOY_COLOR_1);
            coinCounter.alignment = FlxJustification.Left;
            coinCounter.setScrollFactors(0, 0);

            toastySprite = new FlxSprite(0, FlxG.height);

            string person = "Lemonade/illustration/andre_drawing";
            int    ran    = (int)FlxU.random(0, 4);

            switch (ran)
            {
            case 0:
                person = "Lemonade/illustration/andre_drawing";
                break;

            case 1:
                person = "Lemonade/illustration/liselot_drawing";
                break;

            case 2:
                person = "Lemonade/illustration/army_drawing";
                break;

            case 3:
                person = "Lemonade/illustration/worker_drawing";
                break;

            default:
                person = "Lemonade/illustration/andre_drawing";
                break;
            }

            toastySprite.loadGraphic(person, false, false, 302, 640);
            toastySprite.setScrollFactors(0, 0);

            tween = new Tweener(4, 12, 1, Quadratic.EaseInOut);
            tween.Start();
            tween.PingPong = true;

            powerBar = new FlxGroup();

            for (int i = 0; i < 30; i++)
            {
                int offsetY = 0;
                int offsetS = 0;

                                #if __ANDROID__
                offsetY = 50;
                offsetS = 150;
                                #endif

                FlxSprite bar = new FlxSprite(offsetS + 5 + (i * 10), FlxG.height - 10 - offsetY);
                bar.createGraphic(8, 8, Lemonade_Globals.GAMEBOY_COLOR_4);
                bar.setScrollFactors(0, 0);
                powerBar.add(bar);
            }
        }
예제 #3
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);
        }