public void buildTilesetForOgmo1() //string LevelFile, string Tiles
        {
            //push width / height to flxg.levelheight;

            Dictionary <string, string> w = FlxXMLReader.readAttributesFromOelFile("Lemonade/levels/slf/level1.oel", "level/width");

            FlxG.levelWidth = Convert.ToInt32(w["width"]);
            Dictionary <string, string> h = FlxXMLReader.readAttributesFromOelFile("Lemonade/levels/slf/level1.oel", "level/height");

            FlxG.levelHeight = Convert.ToInt32(h["height"]);

            Console.WriteLine("FlxG.lw = {0} {1}", FlxG.levelWidth, FlxG.levelHeight);


            // ------------------------------------------

            List <Dictionary <string, string> > bgString = FlxXMLReader.readNodesFromOel1File("Lemonade/levels/slf/level" + FlxG.level + ".oel", "level/solids");

            foreach (Dictionary <string, string> nodes in bgString)
            {
                FlxTileblock ta = new FlxTileblock(Convert.ToInt32(nodes["x"]), Convert.ToInt32(nodes["y"]), Convert.ToInt32(nodes["w"]), Convert.ToInt32(nodes["h"]));
                ta.loadTiles(FlxG.Content.Load <Texture2D>("Lemonade/slf1/level1/level1_tiles"), 10, 10, 0);
                ta.auto = FlxTileblock.AUTO;
                collidableTileblocks.add(ta);
            }
        }
        public void buildBoxes()
        {
            List <Dictionary <string, string> > levelString = FlxXMLReader.readObjectsFromTmxFile("Lemonade/levels/slf2/" + Lemonade_Globals.location + "/" + Lemonade_Globals.location + "_level" + FlxG.level.ToString() + ".tmx",
                                                                                                  "map",
                                                                                                  "boxes",
                                                                                                  FlxXMLReader.NONE);

            foreach (Dictionary <string, string> nodes in levelString)
            {
                foreach (KeyValuePair <string, string> kvp in nodes)
                {
                    //Console.Write("Level String -- Key = {0}, Value = {1}, ", kvp.Key, kvp.Value);
                }
                //Console.Write("\r\n");
            }

            foreach (var item in levelString)
            {
                if (item.ContainsKey("pointsX"))
                {
                    MovingPlatform movingPlatform = new MovingPlatform(Int32.Parse(item["x"]), Int32.Parse(item["y"]));
                    movingPlatform.solid  = true;
                    movingPlatform.@fixed = true;

                    movingPlatforms.add(movingPlatform);

                    FlxPath xpath = new FlxPath(null);
                    //xpath.add(Int32.Parse(item["x"]), Int32.Parse(item["y"]));
                    xpath.addPointsUsingStrings(item["pointsX"], item["pointsY"]);
                    movingPlatform.followPath(xpath, 150, FlxSprite.PATH_YOYO, false);
                    movingPlatform.pathCornering = 0.0f;
                }
            }
        }
Beispiel #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);
        }
        //creates a new coin located on the specified tile
        public void createCoin(int X, int Y)
        {
            FlxSprite coin = new FlxSprite(X * 8 + 3, Y * 8 + 2);

            coin.makeGraphic(2, 4, FlxColor.YELLOW);
            coins.add(coin);
        }
Beispiel #5
0
        public override void create()
        {
            FlxG.bgColor = FlxColor.BLACK;
            _items       = new FlxGroup();
            _states      = new List <FlxState> ();

            _states.Add(new Platformer());
            _states.Add(new SplitScreen());
            _states.Add(new BunnyPlayState());
            _states.Add(new ModePlayState());
            _states.Add(new Particles());
            _states.Add(new Collision());
            _states.Add(new Tilemap());

            _items.add(new FlxText(0, startY, FlxG.width, "Platformer").setFormat(null, 8, Color.White, "center", Color.Black));
            _items.add(new FlxText(0, (startY += 20), FlxG.width, "SplitScreen").setFormat(null, 8, Color.White, "center", Color.Black));
            _items.add(new FlxText(0, (startY += 20), FlxG.width, "BunnyMark").setFormat(null, 8, Color.White, "center", Color.Black));
            _items.add(new FlxText(0, (startY += 20), FlxG.width, "Mode").setFormat(null, 8, Color.White, "center", Color.Black));
            _items.add(new FlxText(0, (startY += 20), FlxG.width, "Particles").setFormat(null, 8, Color.White, "center", Color.Black));
            _items.add(new FlxText(0, (startY += 20), FlxG.width, "Collision").setFormat(null, 8, Color.White, "center", Color.Black));
            _items.add(new FlxText(0, (startY += 20), FlxG.width, "Auto Tilemap").setFormat(null, 8, Color.White, "center", Color.Black));

            add(_items);

            add(new FlxText(0, 15, FlxG.width, "-- MonoFlixel Examples --").setFormat(null, 16, Color.White, "center", Color.Black));

            _selected = new FlxText(FlxG.width / 2 - 80, ((FlxText)_items.Members [selectedID]).Y, FlxG.width, ">").setFormat(null, 8, Color.White, "left", Color.Black);

            add(_selected);
        }
		public override void create()
		{
			FlxG.bgColor = FlxColor.BLACK;
			_items = new FlxGroup ();
			_states = new List<FlxState> ();

			_states.Add (new Platformer());
			_states.Add (new SplitScreen());
			_states.Add (new BunnyPlayState());
			_states.Add (new ModePlayState());
			_states.Add (new Particles());
			_states.Add (new Collision());
			_states.Add (new Tilemap());

			_items.add (new FlxText(0, startY, FlxG.width, "Platformer").setFormat (null, 8, Color.White, "center", Color.Black));
			_items.add (new FlxText(0, (startY += 20), FlxG.width, "SplitScreen").setFormat (null, 8, Color.White, "center", Color.Black));
			_items.add (new FlxText(0, (startY += 20), FlxG.width, "BunnyMark").setFormat (null, 8, Color.White, "center", Color.Black));
			_items.add (new FlxText(0, (startY += 20), FlxG.width, "Mode").setFormat (null, 8, Color.White, "center", Color.Black));
			_items.add (new FlxText(0, (startY += 20), FlxG.width, "Particles").setFormat (null, 8, Color.White, "center", Color.Black));
			_items.add (new FlxText(0, (startY += 20), FlxG.width, "Collision").setFormat (null, 8, Color.White, "center", Color.Black));
			_items.add (new FlxText(0, (startY += 20), FlxG.width, "Auto Tilemap").setFormat (null, 8, Color.White, "center", Color.Black));

			add(_items);

			add (new FlxText(0, 15, FlxG.width, "-- MonoFlixel Examples --").setFormat (null, 16, Color.White, "center", Color.Black));

			_selected = new FlxText (FlxG.width/2-80, ((FlxText)_items.Members [selectedID]).Y, FlxG.width, ">").setFormat (null, 8, Color.White, "left", Color.Black);

			add (_selected);
		}
        public void addBunnies()
        {
            float rx;
            float ry;

            for (int i = 0; i < 500; i++)
            {
                rx = FlxG.random() * (FlxG.width - 26);
                ry = FlxG.random() * (FlxG.height - 37);
                _bunnies.add((FlxBasic) new Bunny(rx, ry));
            }
            _bunnyCounter.text = "Bunnies: " + _bunnies.length;
        }
        override public void create()
        {
            base.create();

            FlxG.mouse.hide();
            FlxG.hideHud();

            playingField      = new FlxTileblock(0, 0, 640, 640);
            playingField.auto = FlxTileblock.RANDOM;
            playingField.loadTiles(FlxG.Content.Load <Texture2D>("examples/sports_ground"), 16, 16, 0);
            add(playingField);

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

            // Create two teams of 7 robots;
            for (int i = 0; i < 7; i++)
            {
                FlxSprite robot = new FlxSprite(20 + (i * 90), 10);
                robot.loadGraphic(FlxG.Content.Load <Texture2D>("flixel/surt/race_or_die"), true, false, 64, 64);
                robot.addAnimation("Static", new int[] { 7 }, 0, true);
                robot.play("Static");
                robot.angle      = 270;
                robot.velocity.Y = FlxU.random(10, 100);
                //robot.width = 32;
                //robot.height = 32;
                //robot.offset.X = 16;
                //robot.offset.Y = 16;
                team1.add(robot);
            }
            for (int i = 0; i < 7; i++)
            {
                FlxSprite robot = new FlxSprite(20 + (i * 90), 200);
                robot.loadGraphic(FlxG.Content.Load <Texture2D>("flixel/surt/race_or_die"), true, false, 64, 64);
                robot.addAnimation("Static", new int[] { 9 }, 0, true);
                robot.play("Static");
                robot.angle      = 90;
                robot.velocity.Y = FlxU.random(-10, -100);
                //robot.width = 32;
                //robot.height = 32;
                //robot.offset.X = 16;
                //robot.offset.Y = 16;
                team2.add(robot);
            }


            add(team1);
            add(team2);
        }
        //These next two functions look crazy, but all they're doing is generating
        //the level structure and placing the enemy spawners.
        protected void generateLevel()
        {
            int          r = 160;
            FlxTileblock b;

            //First, we create the walls, ceiling and floors:
            b = new FlxTileblock(0, 0, 640, 16);
            b.loadTiles(ImgTech);
            _blocks.add(b);

            b = new FlxTileblock(0, 16, 16, 640 - 16);
            b.loadTiles(ImgTech);
            _blocks.add(b);

            b = new FlxTileblock(640 - 16, 16, 16, 640 - 16);
            b.loadTiles(ImgTech);
            _blocks.add(b);

            b = new FlxTileblock(16, 640 - 24, 640 - 32, 8);
            b.loadTiles(ImgDirtTop);
            _blocks.add(b);

            b = new FlxTileblock(16, 640 - 16, 640 - 32, 16);
            b.loadTiles(ImgDirt);
            _blocks.add(b);

            //Then we split the game world up into a 4x4 grid,
            //and generate some blocks in each area.  Some grid spaces
            //also get a spawner!
            buildRoom(r * 0, r * 0, true);
            buildRoom(r * 1, r * 0);
            buildRoom(r * 2, r * 0);
            buildRoom(r * 3, r * 0, true);
            buildRoom(r * 0, r * 1, true);
            buildRoom(r * 1, r * 1);
            buildRoom(r * 2, r * 1);
            buildRoom(r * 3, r * 1, true);
            buildRoom(r * 0, r * 2);
            buildRoom(r * 1, r * 2);
            buildRoom(r * 2, r * 2);
            buildRoom(r * 3, r * 2);
            buildRoom(r * 0, r * 3, true);
            buildRoom(r * 1, r * 3);
            buildRoom(r * 2, r * 3);
            buildRoom(r * 3, r * 3, true);
        }
Beispiel #10
0
        public Aim(int xPos, int yPos)
            : base(xPos, yPos)
        {
            loadGraphic("flixel/initials/crosshair");

            direction   = false;
            hdirection  = false;
            speed       = 1;
            hspeed      = 1;
            startAim    = false;
            startHealth = false;

            points = new FlxGroup();
            for (int i = 0; i < 3; i++)
            {
                Target point = new Target(4 * i, 4 * i);
                points.add(point);
            }

            setOffset(-4, -4);

            ballPosition = new Vector2(0, 0);
        }
        //Just plops down a spawner and some blocks - haphazard and crappy atm but functional!
        protected void buildRoom(int RX, int RY, bool Spawners)
        {
            //first place the spawn point (if necessary)
            int rw = 20;
            int sx = 0;
            int sy = 0;

            if (Spawners)
            {
                sx = (int)(2 + FlxG.random() * (rw - 7));
                sy = (int)(2 + FlxG.random() * (rw - 7));
            }

            //then place a bunch of blocks
            int numBlocks = (int)(3 + FlxG.random() * 4);

            if (!Spawners)
            {
                numBlocks++;
            }
            int  maxW = 10;
            int  minW = 2;
            int  maxH = 8;
            int  minH = 1;
            int  bx;
            int  by;
            int  bw;
            int  bh;
            bool check;

            for (int i = 0; i < numBlocks; i++)
            {
                do
                {
                    //keep generating different specs if they overlap the spawner
                    bw = (int)(minW + FlxG.random() * (maxW - minW));
                    bh = (int)(minH + FlxG.random() * (maxH - minH));
                    bx = (int)(-1 + FlxG.random() * (rw + 1 - bw));
                    by = (int)(-1 + FlxG.random() * (rw + 1 - bh));
                    if (Spawners)
                    {
                        check = ((sx > bx + bw) || (sx + 3 < bx) || (sy > by + bh) || (sy + 3 < by));
                    }
                    else
                    {
                        check = true;
                    }
                } while(!check);

                FlxTileblock b;
                b = new FlxTileblock(RX + bx * 8, RY + by * 8, bw * 8, bh * 8);
                b.loadTiles(ImgTech);
                _blocks.add(b);

                //If the block has room, add some non-colliding "dirt" graphics for variety
                if ((bw >= 4) && (bh >= 5))
                {
                    b = new FlxTileblock(RX + bx * 8 + 8, RY + by * 8, bw * 8 - 16, 8);
                    b.loadTiles(ImgDirtTop);
                    _decorations.add(b);

                    b = new FlxTileblock(RX + bx * 8 + 8, RY + by * 8 + 8, bw * 8 - 16, bh * 8 - 24);
                    b.loadTiles(ImgDirt);
                    _decorations.add(b);
                }
            }

            if (Spawners)
            {
                //Finally actually add the spawner
                Spawner sp = new Spawner(RX + sx * 8, RY + sy * 8, _bigGibs, _enemies, _enemyBullets, _littleGibs, _player);
                _spawners.add(sp);

                //Then create a dedicated camera to watch the spawner
                _hud.add(new FlxSprite(3 + (_spawners.length - 1) * 16, 3, ImgMiniFrame));
                FlxCamera camera = new FlxCamera(10 + (_spawners.length - 1) * 32, 10, 24, 24, 1);
                camera.follow(sp);
                FlxG.addCamera(camera);
            }
        }
Beispiel #12
0
        override public void create()
        {
            base.create();

            Lemonade_Globals.totalCoins = Lemonade_Globals.calculateTotalCoins();

            Console.WriteLine("Total coins = {0}", Lemonade_Globals.totalCoins);

                        #if __ANDROID__
            FlxG.BUILD_TYPE = FlxG.BUILD_TYPE_OUYA;
                        #endif

            FlxTilemap bgMap = new FlxTilemap();
            bgMap.auto        = FlxTilemap.STRING;
            bgMap.indexOffset = -1;
            bgMap.loadTMXMap("Lemonade/levels/slf2/newyork/newyork_intro.tmx", "map", "bg", FlxXMLReader.TILES, FlxG.Content.Load <Texture2D>("Lemonade/bgtiles_newyork"), 20, 20);
            bgMap.boundingBoxOverride = false;
            bgMap.setScrollFactors(1, 1);
            add(bgMap);

            bgMap             = new FlxTilemap();
            bgMap.auto        = FlxTilemap.STRING;
            bgMap.indexOffset = -1;
            bgMap.loadTMXMap("Lemonade/levels/slf2/newyork/newyork_intro.tmx", "map", "bg2", FlxXMLReader.TILES, FlxG.Content.Load <Texture2D>("Lemonade/bgtiles_newyork"), 20, 20);
            bgMap.boundingBoxOverride = false;
            bgMap.setScrollFactors(1, 1);
            add(bgMap);

            FlxTilemap bgMap3 = new FlxTilemap();
            bgMap3.auto        = FlxTilemap.STRING;
            bgMap3.indexOffset = -1;
            bgMap3.loadTMXMap("Lemonade/levels/slf2/newyork/newyork_intro.tmx", "map", "stars", FlxXMLReader.TILES, FlxG.Content.Load <Texture2D>("Lemonade/bgtiles_newyork"), 20, 20);
            bgMap3.boundingBoxOverride = false;
            bgMap3.setScrollFactors(0.5f, 0.5f);
            add(bgMap3);

            FlxTilemap bgMap4 = new FlxTilemap();
            bgMap4.auto        = FlxTilemap.STRING;
            bgMap4.indexOffset = -1;
            bgMap4.loadTMXMap("Lemonade/levels/slf2/newyork/newyork_intro.tmx", "map", "city", FlxXMLReader.TILES, FlxG.Content.Load <Texture2D>("Lemonade/bgtiles_newyork"), 20, 20);
            bgMap4.boundingBoxOverride = false;
            bgMap4.setScrollFactors(1, 1);
            add(bgMap4);

            follower         = new FlxSprite(0, -100);
            follower.visible = false;
            add(follower);
            follower.velocity.Y = 450;

            FlxG.follow(follower, 20.0f);
            FlxG.followBounds(0, 0, int.MaxValue, 2000);

            FlxText text1 = new FlxText(0, FlxG.height / 2 - 50, FlxG.width, "Initials\nVideo\nGames\nPresents");
            text1.setFormat(FlxG.Content.Load <SpriteFont>("Lemonade/SMALL_PIXEL"), 2, Lemonade_Globals.GAMEBOY_COLOR_4, FlxJustification.Center, Lemonade_Globals.GAMEBOY_COLOR_1);
            text1.setScrollFactors(1.5f, 1.5f);

            add(text1);

            credits = new FlxText(0, FlxG.height / 2 - 100, FlxG.width, "A Game by\nShane Brouwer");
            credits.setFormat(FlxG.Content.Load <SpriteFont>("Lemonade/SMALL_PIXEL"), 2, Lemonade_Globals.GAMEBOY_COLOR_4, FlxJustification.Center, Lemonade_Globals.GAMEBOY_COLOR_1);
            credits.setScrollFactors(0, 0);
            credits.visible = false;
            add(credits);

            string ins = "Press X to Continue";
                        #if __ANDROID__
            ins = "Press O to Continue";
                        #endif

            instruction = new FlxText(0, FlxG.height / 1.3f, FlxG.width, ins);
            instruction.setFormat(FlxG.Content.Load <SpriteFont>("Lemonade/SMALL_PIXEL"), 2, Lemonade_Globals.GAMEBOY_COLOR_4, FlxJustification.Center, Lemonade_Globals.GAMEBOY_COLOR_1);
            instruction.setScrollFactors(0, 0);
            instruction.visible = false;
            add(instruction);

            tween          = new Tweener(FlxG.height / 1.3f, FlxG.height / 1.2f, TimeSpan.FromSeconds(0.67f), XNATweener.Cubic.EaseInOut);
            tween.PingPong = true;
            tween.Start();

            // play some music
            FlxG.playMp3("Lemonade/music/Beyond", 0.75f);

            rain = new FlxGroup();
            for (int i = 0; i < 150; i++)
            {
                FlxSprite rainDrop = new FlxSprite((FlxU.random() * FlxG.width), -200 + (FlxU.random() * 1000));
                rainDrop.loadGraphic("Lemonade/rain", true, false, 2, 2);
                rainDrop.frame      = (int)FlxU.random(0, 6);
                rainDrop.velocity.Y = FlxU.random(350, 400);
                rain.add(rainDrop);
            }
            add(rain);

            splashes = new FlxEmitter();
            splashes.createSprites("Lemonade/rain", 150, true, 0.0f, 0.0f);
            splashes.setXSpeed(-25, 25);
            splashes.setYSpeed(-30, 0);
            splashes.gravity = 1.0f;
            add(splashes);
        }
Beispiel #13
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);
        }
Beispiel #14
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);
        }
Beispiel #15
0
        public override void create()
        {
            //Kick the framerate back up
            FlxG.Framerate = 60;
            //FlxG.flashFramerate = 60;

            //Let's setup our elevator, for some wonderful crate bashing goodness
            elevator = new FlxSprite((FlxG.width / 2) - 100, 250, elevatorPNG);
            //Make it able to collide, and make sure it's not tossed around
            elevator.Solid = elevator.Immovable = true;
            //And add it to the state
            add(elevator);

            //Now lets get some crates to smash around, normally I would use an emitter for this
            //kind of scene, but for this demo I wanted to use regular sprites
            //(See ParticlesDemo for an example of an emitter with colliding particles)
            //We'll need a group to place everything in - this helps a lot with collisions
            crateStormGroup = new FlxGroup();
            for (int i = 0; i < numCrates; i++)
            {
                crate = new FlxSprite((FlxG.random() * 200) + 100, 20);
                crate.loadRotatedGraphic(cratePNG, 16, 0);        //This loads in a graphic, and 'bakes' some rotations in so we don't waste resources computing real rotations later
                crate.AngularVelocity = FlxG.random() * 50 - 150; //Make it spin a tad
                crate.Acceleration.Y  = 300;                      //Gravity
                crate.Acceleration.X  = -50;                      //Some wind for good measure
                crate.MaxVelocity.Y   = 500;                      //Don't fall at 235986mph
                crate.MaxVelocity.X   = 200;                      //"      fly  "  "
                crate.Elasticity      = FlxG.random();            //Let's make them all bounce a little bit differently
                crateStormGroup.add(crate);
            }
            add(crateStormGroup);
            //And another group, this time - Red crates
            crateStormGroup2 = new FlxGroup();
            for (int i = 0; i < numCrates; i++)
            {
                crate = new FlxSprite((FlxG.random() * 200) + 100, 20);
                crate.loadRotatedGraphic(cratePNG, 16, 1);
                crate.AngularVelocity = FlxG.random() * 50 - 150;
                crate.Acceleration.Y  = 300;
                crate.Acceleration.X  = 50;
                crate.MaxVelocity.Y   = 500;
                crate.MaxVelocity.X   = 200;
                crate.Elasticity      = FlxG.random();
                crateStormGroup2.add(crate);
            }
            add(crateStormGroup2);

            //Now what we're going to do here is add both of those groups to a new containter group
            //This is useful if you had something like, coins, enemies, special tiles, etc.. that would all need
            //to check for overlaps with something like a player.
            crateStormMegaGroup = new FlxGroup();
            crateStormMegaGroup.add(crateStormGroup);
            crateStormMegaGroup.add(crateStormGroup2);

            //Cute little flixel logo that will ride the elevator
            flixelRider                = new FlxSprite((FlxG.width / 2) - 13, 0, flixelRiderPNG);
            flixelRider.Solid          = flixelRider.Visible = flixelRider.Exists = false;    //But we don't want him on screen just yet...
            flixelRider.Acceleration.Y = 800;
            add(flixelRider);

            //This is for the text at the top of the screen
            topText = new FlxText(0, 2, FlxG.width, "Welcome");
            topText.setAlignment("center");
            add(topText);

            //Lets make a bunch of buttons! YEAH!!!
            crateStorm = new FlxButton(2, FlxG.height - 22, "Crate Storm", onCrateStorm);
            add(crateStorm);
            flxRiderButton = new FlxButton(82, FlxG.height - 22, "Flixel Rider", onFlixelRider);
            add(flxRiderButton);
            crateStormG1 = new FlxButton(162, FlxG.height - 22, "Blue Group", onBlue);
            add(crateStormG1);
            crateStormG2 = new FlxButton(242, FlxG.height - 22, "Red Group", onRed);
            add(crateStormG2);
            groupCollision = new FlxButton(202, FlxG.height - 42, "Collide Groups", onCollideGroups);
            add(groupCollision);
            quitButton = new FlxButton(320, FlxG.height - 22, "Quit", onQuit);
            add(quitButton);

            //And lets get the flixel cursor visible again
            FlxG.mouse.show();
            //Mouse.hide();
        }
Beispiel #16
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);
        }
Beispiel #17
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);
        }
        override public void create()
        {
            FlxG.Framerate = 60;
            //FlxG.flashFramerate = 60;

            //Here we actually initialize out emitter
            //The parameters are        X   Y                Size (Maximum number of particles the emitter can store)
            theEmitter = new FlxEmitter(10, FlxG.height / 2, 200);

            //Now by default the emitter is going to have some properties set on it and can be used immediately
            //but we're going to change a few things.

            //First this emitter is on the side of the screen, and we want to show off the movement of the particles
            //so lets make them launch to the right.
            theEmitter.setXSpeed(100, 200);

            //and lets funnel it a tad
            theEmitter.setYSpeed(-50, 50);

            //Let's also make our pixels rebound off surfaces
            theEmitter.bounce = 0.8f;

            //Now let's add the emitter to the state.
            add(theEmitter);

            //Now it's almost ready to use, but first we need to give it some pixels to spit out!
            //Lets fill the emitter with some white pixels
            for (int i = 0; i < theEmitter.maxSize / 2; i++)
            {
                whitePixel = new FlxParticle();
                whitePixel.makeGraphic(2, 2, new Color(0xFF, 0xFF, 0xFF));
                whitePixel.Visible = false;                 //Make sure the particle doesn't show up at (0, 0)
                theEmitter.add(whitePixel);
                whitePixel = new FlxParticle();
                whitePixel.makeGraphic(1, 1, new Color(0xFF, 0xFF, 0xFF));
                whitePixel.Visible = false;
                theEmitter.add(whitePixel);
            }

            //Now let's setup some buttons for messing with the emitter.
            collisionButton = new FlxButton(0, FlxG.height - 22, "Collision", onCollision);
            add(collisionButton);
            gravityButton = new FlxButton(80, FlxG.height - 22, "Gravity", onGravity);
            add(gravityButton);
            quitButton = new FlxButton(FlxG.width - 80, FlxG.height - 22, "Quit", onQuit);
            add(quitButton);

            //I'll just leave this here
            topText = new FlxText(0, 2, FlxG.width, "Welcome");
            topText.setAlignment("center");
            add(topText);

            //Lets setup some walls for our pixels to collide against
            collisionGroup = new FlxGroup();
            wall           = new FlxSprite(100, (FlxG.height / 2) - 50);
            wall.makeGraphic(10, 100, new Color(0xFF, 0xFF, 0xFF, 0x50)); //Make it darker - easier on the eyes :)
            wall.Visible   = wall.Solid = false;                          //Set both the visibility AND the solidity to false, in one go
            wall.Immovable = true;                                        //Lets make sure the pixels don't push out wall away! (though it does look funny)
            collisionGroup.add(wall);
            //Duplicate our wall but this time it's a floor to catch gravity affected particles
            floor = new FlxSprite(10, 267);
            floor.makeGraphic((uint)FlxG.width - 20, 10, new Color(0xFF, 0xFF, 0xFF, 0x50));
            floor.Visible   = floor.Solid = false;
            floor.Immovable = true;
            collisionGroup.add(floor);

            //Please note that this demo makes the walls themselves not collide, for the sake of simplicity.
            //Normally you would make the particles have solid = true or false to make them collide or not on creation,
            //because in a normal environment your particles probably aren't going to change solidity at a mouse
            //click. If they did, you would probably be better suited with emitter.setAll("solid", true)
            //I just don't feel that setAll is applicable here(Since I would still have to toggle the walls anyways)

            //Don't forget to add the group to the state(Like I did :P)
            add(collisionGroup);

            //Now lets set our emitter free.
            //Params:        Explode, Particle Lifespan, Emit rate(in seconds)
            theEmitter.start(false, 3, .01f);

            //Let's re show the cursors
            FlxG.mouse.show();
            //Mouse.hide();
        }
		public override void create()
		{
			//Kick the framerate back up
			FlxG.Framerate = 60;
			//FlxG.flashFramerate = 60;

			//Let's setup our elevator, for some wonderful crate bashing goodness
			elevator = new FlxSprite((FlxG.width / 2) - 100, 250, elevatorPNG);
			//Make it able to collide, and make sure it's not tossed around
			elevator.Solid = elevator.Immovable = true;
			//And add it to the state
			add(elevator);

			//Now lets get some crates to smash around, normally I would use an emitter for this
			//kind of scene, but for this demo I wanted to use regular sprites 
			//(See ParticlesDemo for an example of an emitter with colliding particles)
			//We'll need a group to place everything in - this helps a lot with collisions
			crateStormGroup = new FlxGroup();
			for (int i = 0; i < numCrates; i++) {
				crate = new FlxSprite((FlxG.random() * 200) + 100, 20);
				crate.loadRotatedGraphic(cratePNG, 16, 0); //This loads in a graphic, and 'bakes' some rotations in so we don't waste resources computing real rotations later
				crate.AngularVelocity = FlxG.random() * 50-150; //Make it spin a tad
				crate.Acceleration.Y = 300; //Gravity
				crate.Acceleration.X = -50; //Some wind for good measure
				crate.MaxVelocity.Y = 500; //Don't fall at 235986mph
				crate.MaxVelocity.X = 200; //"      fly  "  "
				crate.Elasticity = FlxG.random(); //Let's make them all bounce a little bit differently
				crateStormGroup.add(crate);
			}
			add(crateStormGroup);
			//And another group, this time - Red crates
			crateStormGroup2 = new FlxGroup();
			for (int i = 0; i < numCrates; i++) {
				crate = new FlxSprite((FlxG.random() * 200) + 100, 20);
				crate.loadRotatedGraphic(cratePNG, 16, 1);
				crate.AngularVelocity = FlxG.random() * 50-150;
				crate.Acceleration.Y = 300;
				crate.Acceleration.X = 50;
				crate.MaxVelocity.Y = 500;
				crate.MaxVelocity.X = 200;
				crate.Elasticity = FlxG.random();
				crateStormGroup2.add(crate);
			}
			add(crateStormGroup2);

			//Now what we're going to do here is add both of those groups to a new containter group
			//This is useful if you had something like, coins, enemies, special tiles, etc.. that would all need
			//to check for overlaps with something like a player.
			crateStormMegaGroup = new FlxGroup ();
			crateStormMegaGroup.add(crateStormGroup);
			crateStormMegaGroup.add(crateStormGroup2);

			//Cute little flixel logo that will ride the elevator
			flixelRider = new FlxSprite((FlxG.width / 2) - 13, 0, flixelRiderPNG);
			flixelRider.Solid = flixelRider.Visible = flixelRider.Exists = false; //But we don't want him on screen just yet...
			flixelRider.Acceleration.Y = 800;
			add(flixelRider);

			//This is for the text at the top of the screen
			topText = new FlxText(0, 2, FlxG.width, "Welcome");
			topText.setAlignment("center");
			add(topText);

			//Lets make a bunch of buttons! YEAH!!!
			crateStorm = new FlxButton(2, FlxG.height - 22, "Crate Storm", onCrateStorm);
			add(crateStorm);
			flxRiderButton = new FlxButton(82, FlxG.height - 22, "Flixel Rider", onFlixelRider);
			add(flxRiderButton);
			crateStormG1 = new FlxButton(162, FlxG.height - 22, "Blue Group", onBlue);
			add(crateStormG1);
			crateStormG2 = new FlxButton(242, FlxG.height - 22, "Red Group", onRed);
			add(crateStormG2);
			groupCollision = new FlxButton(202, FlxG.height - 42, "Collide Groups", onCollideGroups);
			add(groupCollision);
			quitButton = new FlxButton(320, FlxG.height - 22, "Quit", onQuit);
			add(quitButton);

			//And lets get the flixel cursor visible again
			FlxG.mouse.show();
			//Mouse.hide();
		}
        //private FlxVirtualPad _pad;

        public override void create()
        {
            //		FlxG.mouse.hide();

            /*_sfxCount = new FlxSound().loadEmbedded(SndCount, false, false, FlxSound.SFX);*/

            /*
             * _pad = new FlxVirtualPad(FlxVirtualPad.DPAD_FULL, FlxVirtualPad.A_B);
             * _pad.Alpha = 0.5f;
             */
            //		if(Gdx.app.getType() == ApplicationType.Desktop || MenuState.attractMode)
            //			_pad.visible = false;

            //Here we are creating a pool of 100 little metal bits that can be exploded.
            //We will recycle the crap out of these!
            _littleGibs = new FlxEmitter();
            _littleGibs.setXSpeed(-150, 150);
            _littleGibs.setYSpeed(-200, 0);
            _littleGibs.setRotation(-720, -720);
            _littleGibs.gravity = 350;
            _littleGibs.bounce  = 0.5f;
            _littleGibs.makeParticles(ImgGibs, 100, 10, true, 0.5f);

            //Next we create a smaller pool of larger metal bits for exploding.
            _bigGibs = new FlxEmitter();
            _bigGibs.setXSpeed(-200, 200);
            _bigGibs.setYSpeed(-300, 0);
            _bigGibs.setRotation(-720, -720);
            _bigGibs.gravity = 350;
            _bigGibs.bounce  = 0.35f;
            _bigGibs.makeParticles(ImgSpawnerGibs, 50, 20, true, 0.5f);

            //Then we'll set up the rest of our object groups or pools
            _blocks       = new FlxGroup();
            _decorations  = new FlxGroup();
            _enemies      = new FlxGroup();
            _spawners     = new FlxGroup();
            _hud          = new FlxGroup();
            _enemyBullets = new FlxGroup();
            _bullets      = new FlxGroup();

            //Now that we have references to the bullets and metal bits,
            //we can create the player object.
            _player = new Player(316, 300, _bullets, _littleGibs /*, _pad*/);

            //This refers to a custom function down at the bottom of the file
            //that creates all our level geometry with a total size of 640x480.
            //This in turn calls buildRoom() a bunch of times, which in turn
            //is responsible for adding the spawners and spawn-cameras.
            generateLevel();

            //Add bots and spawners after we add blocks to the state,
            //so that they're drawn on top of the level, and so that
            //the bots are drawn on top of both the blocks + the spawners.
            add(_spawners);
            add(_littleGibs);
            add(_bigGibs);
            add(_blocks);
            add(_decorations);
            add(_enemies);

            //Then we add the player and set up the scrolling camera,
            //which will automatically set the boundaries of the world.
            add(_player);
            FlxG.camera.setBounds(0, 0, 640, 640, true);
            FlxG.camera.follow(_player, FlxCamera.StylePlatformer);

            //We add the bullets to the scene here,
            //so they're drawn on top of pretty much everything
            add(_enemyBullets);
            add(_bullets);
            add(_hud);

            //Finally we are going to sort things into a couple of helper groups.
            //We don't add these groups to the state, we just use them for collisions later!
            _hazards = new FlxGroup();
            _hazards.add(_enemyBullets);
            _hazards.add(_spawners);
            _hazards.add(_enemies);
            _objects = new FlxGroup();
            _objects.add(_enemyBullets);
            _objects.add(_bullets);
            _objects.add(_enemies);
            _objects.add(_player);
            _objects.add(_littleGibs);
            _objects.add(_bigGibs);

            //From here on out we are making objects for the HUD,
            //that is, the player score, number of spawners left, etc.
            //First, we'll create a text field for the current score
            _score = new FlxText(FlxG.width / 4, 0, FlxG.width / 2);

            /*
             * if(Gdx.app.getType() == ApplicationType.WebGL)
             *      _score.setFormat(ImgFont20,20,0xd8eba2,"center",0x131c1b);
             * else*/
            /*_score.setFormat(null,16,0xd8eba2,"center",0x131c1b);*/
            _hud.add(_score);
            if (FlxG.scores == null)
            {
                FlxG.scores = new int[2] {
                    0, 0
                };
            }

            //Then for the player's highest and last scores
            if (FlxG.score > (int)FlxG.scores.GetValue(0))
            {
                FlxG.scores.SetValue(0, FlxG.score);
            }
            if ((int)FlxG.scores.GetValue(0) != 0)
            {
                _score2 = new FlxText(FlxG.width / 2, 0, FlxG.width / 2);
                //_score2.setFormat(null,8,0xd8eba2,"right",_score.getShadow());
                _hud.add(_score2);
                _score2.text = "HIGHEST: " + FlxG.scores.GetValue(0) + "\nLAST: " + FlxG.score;
            }
            FlxG.score  = 0;
            _scoreTimer = 0;

            //Then we create the "gun jammed" notification
            _gunjam = new FlxGroup();
            _gunjam.add(new FlxSprite(0, FlxG.height - 22).makeGraphic((uint)FlxG.width, 24, Color.Orange));

            /*
             * if(Gdx.app.getType() == ApplicationType.WebGL)
             *      _gunjam.add(new FlxText(0,FlxG.height-22,FlxG.width,"GUN IS JAMMED").setFormat(ImgFont20,20,0xd8eba2,"center"));
             * else*/
            _gunjam.add(new FlxText(0, FlxG.height - 22, FlxG.width, "GUN IS JAMMED"));       /*.setFormat(null,16,0xd8eba2,"center"));*/
            _gunjam.Visible = false;
            _hud.add(_gunjam);

            //After we add all the objects to the HUD, we can go through
            //and set any property we want on all the objects we added
            //with this sweet function.  In this case, we want to set
            //the scroll factors to zero, to make sure the HUD doesn't
            //wiggle around while we play.
            _hud.SetAll("ScrollFactor", new FlxPoint(0, 0));
            _hud.SetAll("Cameras", new List <FlxCamera> {
                FlxG.camera
            });

            /*FlxG.playMusic(SndMode);*/
            FlxG.flash(Color.White);
            _fading = false;

            //Debugger Watch examples
            FlxG.watch(_player, "x");
            FlxG.watch(_player, "y");
            //FlxG.watch(FlxG.class,"score");
        }
        public void buildActor(string actor, int xPos, int yPos)
        {
            if (actor == "andre")
            {
                andre                   = new Andre(xPos, yPos);
                andre.control           = FlxPlatformActor.Controls.player;
                andre.ControllingPlayer = PlayerIndex.One;
                actors.add(andre);
            }
            else if (actor == "liselot")
            {
                liselot                   = new Liselot(xPos, yPos);
                liselot.control           = FlxPlatformActor.Controls.player;
                liselot.ControllingPlayer = PlayerIndex.One;
                actors.add(liselot);
            }
            else if (actor == "army")
            {
                army                   = new Army(xPos, yPos);
                army.control           = FlxPlatformActor.Controls.player;
                army.ControllingPlayer = PlayerIndex.One;
                actors.add(army);
                //army.startPlayingBack();
            }
            else if (actor == "chef")
            {
                chef                   = new Chef(xPos, yPos);
                chef.control           = FlxPlatformActor.Controls.player;
                chef.ControllingPlayer = PlayerIndex.One;
                actors.add(chef);
                //chef.startPlayingBack();
            }
            else if (actor == "inspector")
            {
                inspector                   = new Inspector(xPos, yPos);
                inspector.control           = FlxPlatformActor.Controls.player;
                inspector.ControllingPlayer = PlayerIndex.One;
                actors.add(inspector);
                //inspector.startPlayingBack();
            }
            else if (actor == "worker")
            {
                worker                   = new Worker(xPos, yPos);
                worker.control           = FlxPlatformActor.Controls.player;
                worker.ControllingPlayer = PlayerIndex.One;
                actors.add(worker);
                //worker.startPlayingBack();
            }
            else if (actor == "trampoline")
            {
                xPos -= 2;
                yPos -= 2;

                trampoline = new Trampoline(xPos, yPos);
                trampolines.add(trampoline);
            }
            else if (actor == "coin")
            {
                Coin coin = new Coin(xPos, yPos, false);
                coins.add(coin);
            }

            else if (actor == "largeCrate")
            {
                largeCrate = new LargeCrate(xPos, yPos);
                levelItems.add(largeCrate);
            }
            else if (actor == "smallCrate")
            {
                smallCrate = new SmallCrate(xPos, yPos);
                smallCrates.add(smallCrate);
            }
            else if (actor == "exit")
            {
                yPos -= 90;
                exit  = new Exit(xPos, yPos);
                add(exit);
            }
            else if (actor == "spike_up")
            {
                spike = new Spike(xPos, yPos, 0);
                hazards.add(spike);
            }
            else if (actor == "spike_right")
            {
                spike = new Spike(xPos, yPos, 1);
                hazards.add(spike);
            }
            else if (actor == "spike_down")
            {
                spike = new Spike(xPos, yPos, 2);
                hazards.add(spike);
            }
            else if (actor == "spike_left")
            {
                spike = new Spike(xPos, yPos, 3);
                hazards.add(spike);
            }
            else if (actor == "rampLeft")
            {
                ramp = new Ramp(xPos, yPos, FlxRamp.LOW_SIDE_LEFT);
                ramps.add(ramp);
            }
            else if (actor == "rampRight")
            {
                ramp = new Ramp(xPos, yPos, FlxRamp.LOW_SIDE_RIGHT);
                ramps.add(ramp);
            }
            else if (actor == "plant1")
            {
                Plant plant = new Plant(xPos, yPos - 90, 1);
                hazards.add(plant);
            }
            else if (actor == "plant2")
            {
                Plant plant = new Plant(xPos, yPos - 90, 2);
                hazards.add(plant);
            }
            else if (actor == "filing1")
            {
                FilingCabinet filing = new FilingCabinet(xPos, yPos - 70, 1);
                hazards.add(filing);
            }
            else if (actor == "filing2")
            {
                FilingCabinet filing = new FilingCabinet(xPos, yPos - 40, 2);
                hazards.add(filing);
            }
        }
		override public void create()
		{
			FlxG.Framerate = 60;
			//FlxG.flashFramerate = 60;

			//Here we actually initialize out emitter
			//The parameters are        X   Y                Size (Maximum number of particles the emitter can store)
			theEmitter = new FlxEmitter(10, FlxG.height / 2, 200);

			//Now by default the emitter is going to have some properties set on it and can be used immediately
			//but we're going to change a few things.

			//First this emitter is on the side of the screen, and we want to show off the movement of the particles
			//so lets make them launch to the right.
			theEmitter.setXSpeed(100, 200);

			//and lets funnel it a tad
			theEmitter.setYSpeed( -50, 50);

			//Let's also make our pixels rebound off surfaces
			theEmitter.bounce = 0.8f;

			//Now let's add the emitter to the state.
			add(theEmitter);

			//Now it's almost ready to use, but first we need to give it some pixels to spit out!
			//Lets fill the emitter with some white pixels
			for (int i = 0; i < theEmitter.maxSize/2; i++) {
				whitePixel = new FlxParticle();
				whitePixel.makeGraphic(2, 2, new Color(0xFF,0xFF,0xFF));
				whitePixel.Visible = false; //Make sure the particle doesn't show up at (0, 0)
				theEmitter.add(whitePixel);
				whitePixel = new FlxParticle();
				whitePixel.makeGraphic(1, 1, new Color(0xFF,0xFF,0xFF));
				whitePixel.Visible = false;
				theEmitter.add(whitePixel);
			}

			//Now let's setup some buttons for messing with the emitter.
			collisionButton = new FlxButton(0, FlxG.height - 22, "Collision", onCollision);
			add(collisionButton);
			gravityButton = new FlxButton(80, FlxG.height - 22, "Gravity", onGravity);
			add(gravityButton);
			quitButton = new FlxButton(FlxG.width-80, FlxG.height - 22, "Quit", onQuit);
			add(quitButton);

			//I'll just leave this here
			topText = new FlxText(0, 2, FlxG.width, "Welcome");
			topText.setAlignment("center");
			add(topText);

			//Lets setup some walls for our pixels to collide against
			collisionGroup = new FlxGroup();
			wall= new FlxSprite(100, (FlxG.height/2)-50);
			wall.makeGraphic(10, 100, new Color(0xFF,0xFF,0xFF,0x50));//Make it darker - easier on the eyes :)
			wall.Visible = wall.Solid = false;//Set both the visibility AND the solidity to false, in one go
			wall.Immovable = true;//Lets make sure the pixels don't push out wall away! (though it does look funny)
			collisionGroup.add(wall);
			//Duplicate our wall but this time it's a floor to catch gravity affected particles
			floor = new FlxSprite(10, 267);
			floor.makeGraphic((uint)FlxG.width - 20, 10, new Color(0xFF,0xFF,0xFF,0x50));
			floor.Visible = floor.Solid = false;
			floor.Immovable = true;
			collisionGroup.add(floor);

			//Please note that this demo makes the walls themselves not collide, for the sake of simplicity.
			//Normally you would make the particles have solid = true or false to make them collide or not on creation,
			//because in a normal environment your particles probably aren't going to change solidity at a mouse 
			//click. If they did, you would probably be better suited with emitter.setAll("solid", true)
			//I just don't feel that setAll is applicable here(Since I would still have to toggle the walls anyways)

			//Don't forget to add the group to the state(Like I did :P)
			add(collisionGroup);

			//Now lets set our emitter free.
			//Params:        Explode, Particle Lifespan, Emit rate(in seconds)
			theEmitter.start(false, 3, .01f);

			//Let's re show the cursors
			FlxG.mouse.show();
			//Mouse.hide();
		}
        override public void create()
        {
            FlxG.backColor = FlxColor.ToColor("dedbc3");
            base.create();

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

            charactersGrp   = new FlxGroup();
            blocksGrp       = new FlxGroup();
            movingBlocksGrp = new FlxGroup();
            doors           = new FlxGroup();
            crates          = new FlxGroup();


            //Dictionary<string,string> levelAttrs = FlxXMLReader.readAttributesFromOelFile("ogmo/level1.oel", "level/grid");
            //FlxTilemap tiles = new FlxTilemap();
            //tiles.useExtraMiddleTiles = false;
            //tiles.auto = FlxTilemap.AUTO;
            //tiles.indexOffset = -1;
            //tiles.loadMap(levelAttrs["grid"], FlxG.Content.Load<Texture2D>("level1_tiles"), 10, 10);
            //tiles.setScrollFactors(0, 0);
            //tiles.boundingBoxOverride = true;

            //blocksGrp.add(tiles);

            List <Dictionary <string, string> > lblocks = FlxXMLReader.readNodesFromOelFile("ogmo/level1.oel", "level/grid");

            foreach (Dictionary <string, string> nodes in lblocks)
            {
                FarTileblock t = new FarTileblock(Convert.ToInt32(nodes["x"]) + (Convert.ToInt32(nodes["w"]) / 2), Convert.ToInt32(nodes["y"]) + (Convert.ToInt32(nodes["h"]) / 2), Convert.ToInt32(nodes["w"]), Convert.ToInt32(nodes["h"]), _world);
                t.auto = FlxTilemap.AUTO;
                t.loadTiles("level1_tiles", 10, 10, 0);
                blocksGrp.add(t);
                t._body.BodyType = BodyType.Static;


                FlxTileblock t2 = new FlxTileblock(Convert.ToInt32(nodes["x"]), Convert.ToInt32(nodes["y"]), Convert.ToInt32(nodes["w"]), Convert.ToInt32(nodes["h"]));
                t2.auto = FlxTilemap.AUTO;
                t2.loadTiles("level1_tiles", 10, 10, 0);
                blocksGrp.add(t2);
            }

            List <Dictionary <string, string> > blocks = FlxXMLReader.readNodesFromOelFile("ogmo/level1.oel", "level/tileblocks");

            foreach (Dictionary <string, string> nodes in blocks)
            {
                if (nodes["Name"] == "elevator")
                {
                    MovingBlock block = new MovingBlock(Convert.ToInt32(nodes["x"]), Convert.ToInt32(nodes["y"]));
                    block.loadGraphic("level1_specialBlock", false, true, 40, 20);
                    movingBlocksGrp.add(block);

                    FlxPath xpath = new FlxPath(null);
                    xpath.add(Convert.ToInt32(nodes["x"]) + 20, Convert.ToInt32(nodes["y"]) + 10);
                    xpath.addPointsUsingStrings(nodes["pathNodesX"], nodes["pathNodesY"], 20, 10);
                    block.followPath(xpath, 80, FlxObject.PATH_FORWARD, false);
                }
                if (nodes["Name"] == "door")
                {
                    Door door = new Door(Convert.ToInt32(nodes["x"]), Convert.ToInt32(nodes["y"]) - 100);
                    doors.add(door);
                }
                //foreach (var item in nodes)
                //{
                //    Console.WriteLine("{0} {1}", item.Key, item.Value);
                //}
            }
            //bat = new Bat(x, y);
            //actors.add(bat);
            //Console.WriteLine("Building a bat {0} {1} {2} {3}", x, y, PathNodesX, PathNodesY);

            //if (PathNodesX != "" && PathNodesY != "")
            //{
            //    Console.WriteLine("Building a path {0} {1} {2}", PathNodesX, PathNodesY, PathCornering);

            //    FlxPath xpath = new FlxPath(null);
            //    xpath.add(x, y);
            //    xpath.addPointsUsingStrings(PathNodesX, PathNodesY);
            //    bat.followPath(xpath, PathSpeed, PathType, false);
            //    bat.pathCornering = PathCornering;


            //}



            Andre andre = new Andre(0, 0);

            charactersGrp.add(andre);

            Liselot liselot = new Liselot(40, 40);

            charactersGrp.add(liselot);

            Army army = new Army(30, 20);

            charactersGrp.add(army);

            Inspector inspector = new Inspector(50, 50);

            charactersGrp.add(inspector);

            Worker worker = new Worker(60, 60);

            charactersGrp.add(worker);

            Chef chef = new Chef(100, 30);

            charactersGrp.add(chef);


            FlxTileblock bg = new FlxTileblock(0, 0, 240, 800);

            bg.auto = FlxTileblock.RANDOM;
            bg.loadTiles("level1_shelfTile", 80, 80, 0);
            add(bg);

            bg      = new FlxTileblock(640, 0, 240, 800);
            bg.auto = FlxTileblock.RANDOM;
            bg.loadTiles("level1_shelfTile", 80, 80, 0);
            add(bg);

            for (int i = 0; i < 5; i++)
            {
                SmallCrate c = new SmallCrate((int)FlxU.random(0, FlxG.width), (int)FlxU.random(0, FlxG.height - 100));
                crates.add(c);
            }

            for (int i = 0; i < 5; i++)
            {
                Bottle b = new Bottle((int)FlxU.random(0, FlxG.width), (int)FlxU.random(0, FlxG.height - 100));
                crates.add(b);
            }
            for (int i = 0; i < 55; i++)
            {
                Fruit f = new Fruit((int)FlxU.random(0, FlxG.width), (int)FlxU.random(0, FlxG.height - 100), _world);
                f._body.ApplyLinearImpulse(new Vector2(20, 2120));


                crates.add(f);
            }


            add(doors);
            add(charactersGrp);
            add(blocksGrp);
            add(movingBlocksGrp);
            add(crates);

            FlxG.showHud();
            FlxG.setHudTextPosition(1, FlxG.width / 2, 10);
            FlxG.setHudTextScale(1, 3);
        }
Beispiel #24
0
        override public void create()
        {
            base.create();

            Lemonade_Globals.totalCoins = Lemonade_Globals.calculateTotalCoins();

            FlxTilemap bgMap = new FlxTilemap();

            bgMap.auto        = FlxTilemap.STRING;
            bgMap.indexOffset = -1;
            bgMap.loadTMXMap("Lemonade/levels/slf2/newyork/newyork_intro.tmx", "map", "bg", FlxXMLReader.TILES, FlxG.Content.Load <Texture2D>("Lemonade/bgtiles_newyork"), 20, 20);
            bgMap.boundingBoxOverride = false;
            bgMap.setScrollFactors(1, 1);
            add(bgMap);

            bgMap             = new FlxTilemap();
            bgMap.auto        = FlxTilemap.STRING;
            bgMap.indexOffset = -1;
            bgMap.loadTMXMap("Lemonade/levels/slf2/newyork/newyork_intro.tmx", "map", "bg2", FlxXMLReader.TILES, FlxG.Content.Load <Texture2D>("Lemonade/bgtiles_newyork"), 20, 20);
            bgMap.boundingBoxOverride = false;
            bgMap.setScrollFactors(1, 1);
            add(bgMap);

            FlxTilemap bgMap3 = new FlxTilemap();

            bgMap3.auto        = FlxTilemap.STRING;
            bgMap3.indexOffset = -1;
            bgMap3.loadTMXMap("Lemonade/levels/slf2/newyork/newyork_intro.tmx", "map", "stars", FlxXMLReader.TILES, FlxG.Content.Load <Texture2D>("Lemonade/bgtiles_newyork"), 20, 20);
            bgMap3.boundingBoxOverride = false;
            bgMap3.setScrollFactors(0.5f, 0.5f);
            add(bgMap3);

            FlxTilemap bgMap4 = new FlxTilemap();

            bgMap4.auto        = FlxTilemap.STRING;
            bgMap4.indexOffset = -1;
            bgMap4.loadTMXMap("Lemonade/levels/slf2/newyork/newyork_intro.tmx", "map", "city", FlxXMLReader.TILES, FlxG.Content.Load <Texture2D>("Lemonade/bgtiles_newyork"), 20, 20);
            bgMap4.boundingBoxOverride = false;
            bgMap4.setScrollFactors(1, 1);
            add(bgMap4);

            follower         = new FlxSprite(400, 1500);
            follower.visible = false;
            add(follower);
            follower.velocity.Y = this.speed;

            FlxG.follow(follower, 20.0f);
            FlxG.followBounds(0, 0, int.MaxValue, 2000);

            int textSize = 2;

                        #if __ANDROID__
            textSize = 4;
                        #endif


            heading = new FlxText(0, 50, FlxG.width, "Collection Incomplete");
            heading.setFormat(FlxG.Content.Load <SpriteFont>("Lemonade/SMALL_PIXEL"), textSize, Lemonade_Globals.GAMEBOY_COLOR_4, FlxJustification.Center, Lemonade_Globals.GAMEBOY_COLOR_1);
            heading.setScrollFactors(0, 0);
            add(heading);



            string howWellDidYouGo = "Collected " + Lemonade_Globals.coins.ToString() + "\nfrom " + Lemonade_Globals.totalCoins.ToString() + " Coins ";
            credits = new FlxText(0, FlxG.height / 1.75f, FlxG.width, howWellDidYouGo);
            credits.setFormat(FlxG.Content.Load <SpriteFont>("Lemonade/SMALL_PIXEL"), textSize, Lemonade_Globals.GAMEBOY_COLOR_4, FlxJustification.Center, Lemonade_Globals.GAMEBOY_COLOR_1);
            credits.setScrollFactors(0, 0);
            credits.visible = false;
            add(credits);

            string ins = "Press X to Continue";
#if __ANDROID__
            ins = "Press O to Continue";
#endif

            instruction = new FlxText(0, FlxG.height / 1.3f, FlxG.width, ins);
            instruction.setFormat(FlxG.Content.Load <SpriteFont>("Lemonade/SMALL_PIXEL"), textSize, Lemonade_Globals.GAMEBOY_COLOR_4, FlxJustification.Center, Lemonade_Globals.GAMEBOY_COLOR_1);
            instruction.setScrollFactors(0, 0);
            instruction.visible = false;
            add(instruction);

            if (Lemonade_Globals.coins == Lemonade_Globals.totalCoins)
            {
                heading.setFormat(FlxG.Content.Load <SpriteFont>("Lemonade/SMALL_PIXEL"), textSize, Lemonade_Globals.GAMEBOY_COLOR_4, FlxJustification.Center, Lemonade_Globals.GAMEBOY_COLOR_1);
                heading.text = "Complete Collection!!\nThe Lemonade Factory is saved.";
                instruction.setFormat(FlxG.Content.Load <SpriteFont>("Lemonade/SMALL_PIXEL"), textSize, Lemonade_Globals.GAMEBOY_COLOR_4, FlxJustification.Center, Lemonade_Globals.GAMEBOY_COLOR_1);


                string ins2 = "Press X to Continue";
#if __ANDROID__
                ins2 = "Press O to Continue";
#endif

                instruction.text = ins2;

                //FlxU.openURL("http://initials.itch.io/slf2/download/Y9wdBOHe7a92Qpo9t5UJdz05HhZR5p10F0L6wfdP");
            }

            tween          = new Tweener(FlxG.height / 1.3f, FlxG.height / 1.2f, TimeSpan.FromSeconds(0.67f), XNATweener.Cubic.EaseInOut);
            tween.PingPong = true;
            tween.Start();

            // play some music
            FlxG.playMp3("Lemonade/music/March", 0.75f);

            rain = new FlxGroup();
            for (int i = 0; i < 150; i++)
            {
                FlxSprite rainDrop = new FlxSprite((FlxU.random() * FlxG.width * 2), -200 + (FlxU.random() * 1000));
                rainDrop.loadGraphic("Lemonade/rain", true, false, 2, 2);
                rainDrop.frame      = (int)FlxU.random(0, 6);
                rainDrop.velocity.Y = FlxU.random(350, 400);
                rain.add(rainDrop);
            }
            add(rain);

            splashes = new FlxEmitter();
            splashes.createSprites("Lemonade/rain", 150, true, 0.0f, 0.0f);
            splashes.setXSpeed(-25, 25);
            splashes.setYSpeed(-30, 0);
            splashes.gravity = 1.0f;
            add(splashes);
        }
		//private FlxVirtualPad _pad;
		
		public override void create()
		{
	//		FlxG.mouse.hide();
			
			/*_sfxCount = new FlxSound().loadEmbedded(SndCount, false, false, FlxSound.SFX);*/
			/*
			_pad = new FlxVirtualPad(FlxVirtualPad.DPAD_FULL, FlxVirtualPad.A_B);
			_pad.Alpha = 0.5f;
			*/		
	//		if(Gdx.app.getType() == ApplicationType.Desktop || MenuState.attractMode)
	//			_pad.visible = false;

			//Here we are creating a pool of 100 little metal bits that can be exploded.
			//We will recycle the crap out of these!
			_littleGibs = new FlxEmitter();
			_littleGibs.setXSpeed(-150,150);
			_littleGibs.setYSpeed(-200,0);
			_littleGibs.setRotation(-720,-720);
			_littleGibs.gravity = 350;
			_littleGibs.bounce = 0.5f;
			_littleGibs.makeParticles(ImgGibs,100,10,true,0.5f);

			//Next we create a smaller pool of larger metal bits for exploding.
			_bigGibs = new FlxEmitter();
			_bigGibs.setXSpeed(-200,200);
			_bigGibs.setYSpeed(-300,0);
			_bigGibs.setRotation(-720,-720);
			_bigGibs.gravity = 350;
			_bigGibs.bounce = 0.35f;
			_bigGibs.makeParticles(ImgSpawnerGibs,50,20,true,0.5f);

			//Then we'll set up the rest of our object groups or pools
			_blocks = new FlxGroup();
			_decorations = new FlxGroup();
			_enemies = new FlxGroup();
			_spawners = new FlxGroup();
			_hud = new FlxGroup();
			_enemyBullets = new FlxGroup();
			_bullets = new FlxGroup();

			//Now that we have references to the bullets and metal bits,
			//we can create the player object.
			_player = new Player(316,300,_bullets,_littleGibs/*, _pad*/);

			//This refers to a custom function down at the bottom of the file
			//that creates all our level geometry with a total size of 640x480.
			//This in turn calls buildRoom() a bunch of times, which in turn
			//is responsible for adding the spawners and spawn-cameras.
			generateLevel();

			//Add bots and spawners after we add blocks to the state,
			//so that they're drawn on top of the level, and so that
			//the bots are drawn on top of both the blocks + the spawners.
			add(_spawners);
			add(_littleGibs);
			add(_bigGibs);
			add(_blocks);
			add(_decorations);
			add(_enemies);

			//Then we add the player and set up the scrolling camera,
			//which will automatically set the boundaries of the world.
			add(_player);
			FlxG.camera.setBounds(0,0,640,640,true);
			FlxG.camera.follow(_player,FlxCamera.StylePlatformer);

			//We add the bullets to the scene here,
			//so they're drawn on top of pretty much everything
			add(_enemyBullets);
			add(_bullets);
			add(_hud);

			//Finally we are going to sort things into a couple of helper groups.
			//We don't add these groups to the state, we just use them for collisions later!
			_hazards = new FlxGroup();
			_hazards.add(_enemyBullets);
			_hazards.add(_spawners);
			_hazards.add(_enemies);
			_objects = new FlxGroup();
			_objects.add(_enemyBullets);
			_objects.add(_bullets);
			_objects.add(_enemies);
			_objects.add(_player);
			_objects.add(_littleGibs);
			_objects.add(_bigGibs);

			//From here on out we are making objects for the HUD,
			//that is, the player score, number of spawners left, etc.
			//First, we'll create a text field for the current score
			_score = new FlxText(FlxG.width/4,0,FlxG.width/2);
			/*
			if(Gdx.app.getType() == ApplicationType.WebGL)
				_score.setFormat(ImgFont20,20,0xd8eba2,"center",0x131c1b);			
			else*/
				/*_score.setFormat(null,16,0xd8eba2,"center",0x131c1b);*/
			_hud.add(_score);
			if (FlxG.scores == null) {
				FlxG.scores = new int[2] { 0,0 };
			}

			//Then for the player's highest and last scores
			if(FlxG.score > (int)FlxG.scores.GetValue(0))
				FlxG.scores.SetValue(0, FlxG.score);
			if((int)FlxG.scores.GetValue(0) != 0)
			{
				_score2 = new FlxText(FlxG.width/2,0,FlxG.width/2);
				//_score2.setFormat(null,8,0xd8eba2,"right",_score.getShadow());
				_hud.add(_score2);
				_score2.text = "HIGHEST: "+FlxG.scores.GetValue(0)+"\nLAST: "+FlxG.score;
			}
			FlxG.score = 0;
			_scoreTimer = 0;

			//Then we create the "gun jammed" notification
			_gunjam = new FlxGroup();
			_gunjam.add(new FlxSprite(0,FlxG.height-22).makeGraphic((uint)FlxG.width,24,Color.Orange));
			/*
			if(Gdx.app.getType() == ApplicationType.WebGL)
				_gunjam.add(new FlxText(0,FlxG.height-22,FlxG.width,"GUN IS JAMMED").setFormat(ImgFont20,20,0xd8eba2,"center"));
			else*/
			_gunjam.add(new FlxText(0,FlxG.height-22,FlxG.width,"GUN IS JAMMED"));/*.setFormat(null,16,0xd8eba2,"center"));*/
			_gunjam.Visible = false;
			_hud.add(_gunjam);

			//After we add all the objects to the HUD, we can go through
			//and set any property we want on all the objects we added
			//with this sweet function.  In this case, we want to set
			//the scroll factors to zero, to make sure the HUD doesn't
			//wiggle around while we play.
			_hud.SetAll("ScrollFactor",new FlxPoint(0,0));
			_hud.SetAll("Cameras",new List<FlxCamera> {FlxG.camera});

			/*FlxG.playMusic(SndMode);*/
			FlxG.flash(Color.White);
			_fading = false;

			//Debugger Watch examples
			FlxG.watch(_player,"x");
			FlxG.watch(_player,"y");
			//FlxG.watch(FlxG.class,"score");
		}
        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);
            }
        }
Beispiel #27
0
        override public void create()
        {
            base.create();

            FlxG.playMp3("Lemonade/music/AmbulanceCalls", 0.5f);

            block             = new FlxTileblock(0, 0, FlxG.width + 20, FlxG.height + 20);
            block.auto        = FlxTileblock.FRAMENUMBER;
            block.frameNumber = 6;
            block.setScrollFactors(0, 0);
            block.loadTiles(FlxG.Content.Load <Texture2D>("Lemonade/fade"), 20, 20, 0);

            add(block);

            icons    = new FlxGroup();
            tweeners = new List <Vector3Tweener>();

            for (int i = 0; i < 6; i++)
            {
                int offsetX  = 75;
                int offsetY  = 0;
                int offsetY2 = 0;

                                #if __ANDROID__
                offsetX  = 400;
                offsetY  = 100;
                offsetY2 = 120;
                                #endif

                FlxSprite p1 = new FlxSprite(0 + (i * 36) + offsetX, 12);
                p1.loadGraphic("Lemonade/illustration/people", true, false, 302, 640);
                p1.frame = i;
                icons.add(p1);
                tweeners.Add(new Vector3Tweener(new Vector3(-100 + (i * 36) + offsetX, -290 + offsetY2, 0.1f), new Vector3(12 + offsetY + offsetX, 100, 1), 0.45f, Bounce.EaseOut));
            }

            foreach (var item in tweeners)
            {
                item.Pause();
            }

            add(icons);

            switch (Lemonade_Globals.location)
            {
            case "warehouse":
                selected = 0;
                break;

            case "military":
                selected = 1;
                break;

            case "newyork":
                selected = 2;
                break;

            case "sydney":
                selected = 3;
                break;

            case "management":
                selected = 4;
                break;

            case "factory":
                selected = 5;
                break;

            default:
                selected = 0;
                break;
            }
            tweeners[selected].Play();

            timer = 5.0f;

            t1 = new FlxText(0, FlxG.height - 72, FlxG.width);
            t1.setFormat(null, 2, Lemonade_Globals.GAMEBOY_COLOR_1, FlxJustification.Center, Lemonade_Globals.GAMEBOY_COLOR_4);
            add(t1);

            t2 = new FlxText(0, 3, FlxG.width);
            t2.setFormat(null, 2, Lemonade_Globals.GAMEBOY_COLOR_1, FlxJustification.Center, Lemonade_Globals.GAMEBOY_COLOR_4);
            add(t2);
        }
        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);
        }
Beispiel #29
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);
        }