Пример #1
0
        public Coin(int xPos, int yPos, bool Outline)
            : base(xPos, yPos)
        {
            if (Outline)
            {
                loadGraphic("Lemonade/GoldCoinGameboyWithOutline", true, false, 32, 32);
            }
            else
            {
                loadGraphic("Lemonade/GoldCoinGameboy", true, false, 32, 32);
            }

            addAnimation("animation", new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 4 }, (int)FlxU.random(4, 8), true);
            play("animation");

            width  = 16;
            height = 16;
            setOffset(8, 8);

            fanfare = new FlxEmitter();
            fanfare.createSprites("Lemonade/bubble", 8, true, 0.0f, 0.0f);
            fanfare.setXSpeed(-100, 100);
            fanfare.setYSpeed(-100, 100);
            fanfare.gravity = 5;
            fanfare.delay   = 3.0f;

            tween          = new XNATweener.Tweener(-25, 25, FlxU.random(0.8f, 1.2f), XNATweener.Quadratic.EaseInOut);
            tween.PingPong = true;
            tween.Start();
        }
Пример #2
0
        public override void create()
        {
            _timer  = 0;
            _fading = false;
            FlxG.flash(Color.White);

            //Gibs emitted upon death
            FlxEmitter gibs = new FlxEmitter(0, -50);

            gibs.setSize((uint)FlxG.width, 0);
            gibs.setXSpeed();
            gibs.setYSpeed(0, 100);
            gibs.setRotation(-360, 360);
            gibs.gravity = 80;
            gibs.makeParticles(ImgGibs, 800, 32, true, 0);
            add(gibs);
            gibs.start(false, 0, 0.005f);

            FlxText text = new FlxText(0, FlxG.height / 2 - 35, FlxG.width, "VICTORY\n\nSCORE: " + FlxG.score);

            /*
             * if(Gdx.app.getType() == ApplicationType.WebGL)
             *      text.setFormat(ImgFont20,20,0xd8eba2,"center");
             * else
             *      text.setFormat(null,16,0xd8eba2,"center");*/
            add(text);
        }
        public override void destroy()
        {
            base.destroy();

            _blocks       = null;
            _decorations  = null;
            _bullets      = null;
            _player       = null;
            _enemies      = null;
            _spawners     = null;
            _enemyBullets = null;
            _littleGibs   = null;
            _bigGibs      = null;
            _hud          = null;
            _gunjam       = null;

            //meta groups, to help speed up collisions
            _objects = null;
            _hazards = null;

            //HUD/User Interface stuff
            _score  = null;
            _score2 = null;

            //_pad = null;
        }
Пример #4
0
        //This is the constructor for the enemy class.  Because we are
        //recycling enemies, we don't want our constructor to have any
        //required parameters.
        public Enemy() : base()
        {
            loadRotatedGraphic(ImgBot, 64, 0, false, true);

            //We want the enemy's "hit box" or actual size to be
            //smaller than the enemy graphic itself, just by a few pixels.
            Width  = 12;
            Height = 12;
            centerOffsets();

            //Here we are setting up the jet particles
            // that shoot out the back of the ship.
            _jets = new FlxEmitter();
            _jets.setRotation();
            //_jets.MakeParticles(ImgJet,15,0,false,0);

            //These parameters help control the ship's
            //speed and direction during the update() loop.
            MaxAngular      = 120;
            AngularDrag     = 400;
            Drag.X          = 35;
            _thrust         = 0;
            _playerMidpoint = new FlxPoint();

            _sfxExplode = new FlxSound().loadEmbedded(SndExplode, false, false);
            _sfxHit     = new FlxSound().loadEmbedded(SndHit, false, false);
            _sfxJet     = new FlxSound().loadEmbedded(SndJet, false, false);
        }
		public override void destroy()
		{
			base.destroy();
			gibs = null;
			/*playButton = null;*/
			title1 = null;
			title2 = null;
		}
Пример #6
0
 public override void destroy()
 {
     base.destroy();
     _bots       = null;
     _botGibs    = null;
     _botBullets = null;
     _gibs       = null;
     _player     = null;
 }
Пример #7
0
        //Each time an Enemy is recycled (in this game, by the Spawner object)
        //we call init() on it afterward.  That allows us to set critical parameters
        //like references to the player object and the ship's new position.
        public void init(int xPos, int yPos, FlxGroup Bullets, FlxEmitter Gibs, Player ThePlayer)
        {
            _player  = ThePlayer;
            _bullets = Bullets;
            _gibs    = Gibs;

            reset(xPos - Width / 2, yPos - Height / 2);
            Angle      = angleTowardPlayer();
            Health     = 2;             //Enemies take 2 shots to kill
            _timer     = 0;
            _shotClock = 0;
        }
Пример #8
0
        //Called by flixel to help clean up memory.

        public override void destroy()
        {
            base.destroy();

            _player  = null;
            _bullets = null;
            _gibs    = null;

            _jets.destroy();
            _jets = null;

            _playerMidpoint = null;
        }
Пример #9
0
        //This is the player object class.  Most of the comments I would put in here
        //would be near duplicates of the Enemy class, so if you're confused at all
        //I'd recommend checking that out for some ideas!
        public Player(int x, int y, FlxGroup Bullets, FlxEmitter Gibs /*, FlxVirtualPad pad*/) : base(x, y)
        {
            loadGraphic(ImgSpaceman, true, true, 8);
            _restart = 0;

            //bounding box tweaks
            Width    = 6;
            Height   = 7;
            Offset.X = 1;
            Offset.Y = 1;

            /*
             * _pad = pad;
             * _pad.buttonA.onDown = new IFlxButton(){ public void callback(){jump();}};
             */
            //basic player physics
            int runSpeed = 80;

            Drag.X         = runSpeed * 8;
            Acceleration.Y = 420;
            _jumpPower     = 200;
            MaxVelocity.X  = runSpeed;
            MaxVelocity.Y  = _jumpPower;

            //animations
            addAnimation("idle", new int[] { 0 });
            addAnimation("run", new int[] { 1, 2, 3, 0 }, 12);
            addAnimation("jump", new int[] { 4 });
            addAnimation("idle_up", new int[] { 5 });
            addAnimation("run_up", new int[] { 6, 7, 8, 5 }, 12);
            addAnimation("jump_up", new int[] { 9 });
            addAnimation("jump_down", new int[] { 10 });

            //bullet stuff
            _bullets = Bullets;
            _gibs    = Gibs;

            _sfxExplode  = new FlxSound().loadEmbedded(SndExplode, false, false);
            _sfxExplode2 = new FlxSound().loadEmbedded(SndExplode2, false, false);
            _sfxHurt     = new FlxSound().loadEmbedded(SndHurt, false, false);
            _sfxJam      = new FlxSound().loadEmbedded(SndJam, false, false);
            _sfxJump     = new FlxSound().loadEmbedded(SndJump, false, false);
            _sfxLand     = new FlxSound().loadEmbedded(SndLand, false, false);
        }
Пример #10
0
        public Spawner(int x, int y, FlxEmitter Gibs, FlxGroup Bots, FlxGroup BotBullets, FlxEmitter BotGibs, Player ThePlayer) : base(x, y)
        {
            loadGraphic(ImgSpawner, true);
            _gibs       = Gibs;
            _bots       = Bots;
            _botBullets = BotBullets;
            _botGibs    = BotGibs;
            _player     = ThePlayer;
            _timer      = FlxG.random() * 20;
            _open       = false;
            Health      = 8;

            addAnimation("open", new int[] { 1, 2, 3, 4, 5 }, 40, false);
            addAnimation("close", new int[] { 4, 3, 2, 1, 0 }, 40, false);
            addAnimation("dead", new int[] { 6 });

            _sfxExplode  = new FlxSound().loadEmbedded(SndExplode, false, false);
            _sfxExplode2 = new FlxSound().loadEmbedded(SndExplode2, false, false);
            _sfxHit      = new FlxSound().loadEmbedded(SndHit, false, false);
        }
Пример #11
0
        /// <summary>
        /// Plant that can lose leaves
        /// </summary>
        /// <param name="xPos"></param>
        /// <param name="yPos"></param>
        /// <param name="type">Two types of plants. 1 and 2.</param>
        public Plant(int xPos, int yPos, int type)
            : base(xPos, yPos)
        {
            if (type == 1)
            {
                loadGraphic(FlxG.Content.Load <Texture2D>("Lemonade/plant1"), false, false, 10, 110);
            }
            else if (type == 2)
            {
                loadGraphic(FlxG.Content.Load <Texture2D>("Lemonade/plant2"), false, false, 13, 110);
            }

            _leaves = new FlxEmitter();
            _leaves.setSize(2, 110);
            _leaves.createSprites(FlxG.Content.Load <Texture2D>("Lemonade/leaves"), 30, true, 0.0f, 0.0f);
            _leaves.setRotation(0, 360);
            _leaves.setYSpeed(15, 85);
            _leaves.setXSpeed(-40, 40);
            _leaves.gravity = 15;
            _leaves.at(this);


            canLoseLeaves = 110;
        }
Пример #12
0
        protected override void Create()
        {
            Reg.PS = this;
            //DebugDraw = false;

            Add(new FlxSprite(0, 0, "bg"));

            _scoreDisplay           = new FlxText(0, 180, FlxG.Width);
            _scoreDisplay.Alignment = FlxTextAlign.CENTER;
            _scoreDisplay.Color     = new Color(134, 134, 150);
            Add(_scoreDisplay);
            _scoreDisplay.Text = "Press Space to Start";

            Reg.HighScore = LoadScore();

            _highScore           = new FlxText(0, 40, FlxG.Width);
            _highScore.Alignment = FlxTextAlign.CENTER;
            _highScore.Color     = new Color(134, 134, 150);
            Add(_highScore);

            if (Reg.HighScore > 0)
            {
                _highScore.Text = Reg.HighScore.ToString();
            }

            _bounceLeft = new FlxSprite(1, 17);
            _bounceLeft.LoadGraphic(Reg.GetBounceImage(FlxG.Height - 34), true, 4, FlxG.Height - 34);
            _bounceLeft.Animation.Add("flash", new int[] { 1, 0 }, 8, false);
            Add(_bounceLeft);

            _bounceRight = new FlxSprite(FlxG.Width - 5, 17);
            _bounceRight.LoadGraphic(Reg.GetBounceImage(FlxG.Height - 34), true, 4, FlxG.Height - 34);
            _bounceRight.Animation.Add("flash", new int[] { 1, 0 }, 8, false);
            Add(_bounceRight);

            _paddleLeft = new Paddle(6, 1);
            Add(_paddleLeft);

            _paddleRight = new Paddle(FlxG.Width - 15, 0);
            Add(_paddleRight);

            _spikeBottom   = new FlxSprite(0, 0, "spike");
            _spikeBottom.Y = FlxG.Height - _spikeBottom.Height;
            Add(_spikeBottom);

            _spriteTop          = new FlxSprite(0, 0, "spike");
            _spriteTop.Rotation = MathHelper.ToRadians(180);
            _spriteTop.Y        = 0;
            Add(_spriteTop);

            _player = new Player();
            Add(_player);


            _feathers = new FlxEmitter();
            _feathers.Scale.Set(2, 2);
            _feathers.KeepScaleRatio = true;
            _feathers.LoadParticles("feather", 50);
            _feathers.Velocity.Set(-10, -10, 10, 10);
            _feathers.Acceleration.Set(0, 10);
            Add(_feathers);
        }
Пример #13
0
 public override void destroy()
 {
     base.destroy();
     _bullets = null;
     _gibs    = null;
 }
Пример #14
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);
        }
Пример #15
0
        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();
        }
Пример #16
0
        //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");
        }
Пример #17
0
        override public void create()
        {
            base.create();

            Lemonade_Globals.coinsThisLevel = 0;

            Console.WriteLine("Starting Level {0} : {1}", FlxG.level, Lemonade_Globals.location);
            FlxG.transition.resetAndStop();


            FlxG._game.hud.p1HudText.x = -1000;
            FlxG._game.hud.p2HudText.x = -1000;
            FlxG._game.hud.p3HudText.x = -1000;
            FlxG._game.hud.p4HudText.x = -1000;

            FlxG._game.hud.setHudGamepadButton(FlxHud.TYPE_KEYBOARD, 0, -1000, -1000);

            FlxG.mouse.hide();

            FlxG.autoHandlePause = true;

            actors               = new FlxGroup();
            trampolines          = new FlxGroup();
            levelItems           = new FlxGroup();
            ramps                = new FlxGroup();
            smallCrates          = new FlxGroup();
            movingPlatforms      = new FlxGroup();
            hazards              = new FlxGroup();
            collidableTileblocks = new FlxGroup();
            coins                = new FlxGroup();


            //Level Adjust

            buildTileset();
            buildActors();
            buildBoxes();

            add(trampolines);
            add(levelItems);

            add(ramps);
            add(smallCrates);
            add(movingPlatforms);
            add(actors);
            add(collidableTileblocks);

            add(hazards);
            add(coins);



            //set up a little bubble particle system.

            bubbleParticle       = new FlxEmitter();
            bubbleParticle.delay = 3;
            bubbleParticle.setXSpeed(-150, 150);
            bubbleParticle.setYSpeed(-40, 100);
            bubbleParticle.setRotation(-720, 720);
            bubbleParticle.gravity = Lemonade_Globals.GRAVITY * -0.25f;
            bubbleParticle.createSprites(FlxG.Content.Load <Texture2D>("Lemonade/bubble"), 200, true, 1.0f, 0.65f);
            add(bubbleParticle);

            crateParticle       = new FlxEmitter();
            crateParticle.delay = float.MaxValue;
            crateParticle.setSize(80, 60);
            crateParticle.setXSpeed(-350, 350);
            crateParticle.setYSpeed(-200, 200);
            crateParticle.setRotation(-720, 720);
            crateParticle.gravity = Lemonade_Globals.GRAVITY;
            crateParticle.createSprites(FlxG.Content.Load <Texture2D>("Lemonade/crateShards"), 200, true, 1.0f, 0.65f);
            add(crateParticle);


            // follow.
            FlxG.followBounds(0, 0, FlxG.levelWidth, FlxG.levelHeight);

            if (Lemonade_Globals.location == "factory")
            {
                FlxG.follow(worker, LERP);
            }
            if (Lemonade_Globals.location == "management")
            {
                FlxG.follow(liselot, LERP);
            }
            if (Lemonade_Globals.location == "military")
            {
                FlxG.follow(army, LERP);
            }
            if (Lemonade_Globals.location == "newyork")
            {
                FlxG.follow(chef, LERP);
            }
            if (Lemonade_Globals.location == "warehouse")
            {
                FlxG.follow(andre, LERP);
            }
            if (Lemonade_Globals.location == "sydney")
            {
                FlxG.follow(inspector, LERP);
            }

            playSong();

            currentCharHud = new Hud(5, 5);
            add(currentCharHud);

            levelIntro = new LevelIntro();
            add(levelIntro);

            currentCharHud.time = Lemonade_Globals.timeLeft;

            foreach (FlxSprite item in actors.members)
            {
                if (Lemonade_Globals.stateSaver[Lemonade_Globals.location].ContainsKey(item.ToString()))
                {
                    try
                    {
                        item.x = Lemonade_Globals.stateSaver[Lemonade_Globals.location][item.ToString()].X;
                        item.y = Lemonade_Globals.stateSaver[Lemonade_Globals.location][item.ToString()].Y;
                    }
                    catch (Exception)
                    {
                        Console.WriteLine("State saver not working for actors.");
                    }
                }
            }
            int count = 0;

            foreach (FlxSprite item in coins.members)
            {
                if (Lemonade_Globals.stateSaver[Lemonade_Globals.location].ContainsKey(item.ToString() + count.ToString()))
                {
                    try
                    {
                        //Lemonade_Globals.stateSaver[Lemonade_Globals.location][item.ToString() + count.ToString()] = new Vector2(item.x, item.y);
                        if (item.ToString().StartsWith("Lemonade.Coin"))
                        {
                            //item.x = Lemonade_Globals.stateSaver[Lemonade_Globals.location][item.ToString() + count.ToString()].X;
                            //item.y = Lemonade_Globals.stateSaver[Lemonade_Globals.location][item.ToString() + count.ToString()].Y;
                            item.dead = Convert.ToBoolean(Lemonade_Globals.stateSaver[Lemonade_Globals.location][item.ToString() + count.ToString()].X);

                            if (Convert.ToBoolean(Lemonade_Globals.stateSaver[Lemonade_Globals.location][item.ToString() + count.ToString()].X))
                            {
                                item.x = -100;
                                item.y = -100;
                            }
                        }

                        count++;
                    }
                    catch (Exception)
                    {
                        Console.WriteLine("State saver not working for coins");
                    }
                }
            }
        }
Пример #18
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);
        }
Пример #19
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);
        }
Пример #20
0
		/*private FlxVirtualPad _pad;*/

		
		public override void create()
		{
			FlxG.width = (int)FlxG.camera.Width;// ViewportWidth;
			FlxG.resetCameras();
			
			FlxG.bgColor = Color.Black;

			//Simple use of flixel save game object.
			//Tracks number of times the game has been played.
			/*FlxSave save = new FlxSave();
			if(save.bind("Mode"))
			{
				if(save.data.get("plays", Integer.class) == null)
					save.data.put("plays", 0);
				else
					save.data.put("plays", save.data.get("plays", Integer.class) + 1);
				FlxG.log("Number of plays: "+save.data.get("plays", Integer.class));
				//save.erase();
				save.close();
			}
			*/

			//All the bits that blow up when the text smooshes together
			gibs = new FlxEmitter(FlxG.width/2-50,FlxG.height/2-10);
			gibs.setSize(100,30);
			gibs.setYSpeed(-200,-20);
			gibs.setRotation(-720,720);
			gibs.gravity = 100;
			gibs.makeParticles(ImgGibs,650,32,true,0);
			add(gibs);

			//the letters "mo"
			title1 = new FlxText(FlxG.width + 16,FlxG.height/3,64,"mo");
			/*
			if(Gdx.app.getType() == ApplicationType.WebGL)
				title1.setFormat(ImgFont40, 40);
			else 
				title1.SetSize(32);
			title1.SetColor(0x3a5c39);
			title1.Antialiasing = true;
			*/
			title1.Velocity.X = -FlxG.width;
			title1.Moves = true;
			add(title1);

			//the letters "de"
			title2 = new FlxText(-60,title1.Y,(int) title1.Width,"de");
			/*
			if(Gdx.app.getType() == ApplicationType.WebGL)
				title2.setFormat(ImgFont40, 40);
			else 
				title2.SetSize(32);

			title2.SetColor(title1.GetColor());
			title2.Antialiasing = title1.Antialiasing;
			*/
			title2.Velocity.X = FlxG.width;
			title2.Moves = true;
			add(title2);

			fading = false;
			timer = 0;
			attractMode = false;
				
			//FlxG.mouse.show(FlxS.ContentManager.Load<Texture2D>(ImgCursor),2);
			/*
			_pad = new FlxVirtualPad(FlxVirtualPad.DPAD_None, FlxVirtualPad.A_B);
			_pad.setAlpha(0.5f);

			if(Gdx.app.getType() != ApplicationType.Desktop)
				add(_pad);
				*/
		}