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 overlapped(FlxObject obj) { base.overlapped(obj); if (canLoseLeaves > 10) { _leaves.start(true, 4.0f, 0); canLoseLeaves = 0; } }
protected bool trampolinesOverlap(object Sender, FlxSpriteCollisionEvent e) { if (e.Object1.dead == false) { bubbleParticle.at(e.Object1); bubbleParticle.start(true, 0, 30); } e.Object1.overlapped(e.Object2); e.Object2.overlapped(e.Object1); return(true); }
public override void kill() { fanfare.at(this); fanfare.start(true, 1.0f, 20); x = -100; y = -100; this.dead = true; //base.kill(); }
//Called to kill the enemy. A cool sound is played, //the jets are turned off, bits are exploded, and points are rewarded. public override void kill() { if (!Alive) { return; } _sfxExplode.play(true); base.kill(); flicker(0); _jets.kill(); _gibs.at(this); _gibs.start(true, 3, 0, 20); FlxG.score += 200; }
public void pulse(string Name, uint Frame, int FrameIndex) { string info = "Current animation: " + Name + " Frame: " + Frame + " FrameIndex: " + FrameIndex; FlxG.setHudText(1, info); FlxG.setHudTextScale(1, 3); if (Name == "transform" && Frame == 39) { FlxG.flash.start(Color.White); } // Lets say you want to fire some jets on the fifth frame of any animation if (Frame == 5) { jets.start(); } // Fire jets at the fifth frame of reverse. if (Name == "reverse" && FrameIndex == 5) { jets.start(); } }
public override void kill() { if (!Alive) { return; } Solid = false; _sfxExplode.play(true); _sfxExplode2.play(true); base.kill(); flicker(0); Exists = true; Visible = false; Velocity.make(); Acceleration.make(); FlxG.camera.shake(0.005f, 0.35f); FlxG.camera.Flash(Color.White, 0.35f); if (_gibs != null) { _gibs.at(this); _gibs.start(true, 5, 0, 50); } }
//This is the main flixel update function or loop function. //Most of the enemy's logic or behavior is in this function here. public override void update() { //Then, rotate toward that angle. //We could rotate instantly toward the player by simply calling: //angle = angleTowardPlayer(); //However, we want some less predictable, more wobbly behavior. float da = angleTowardPlayer(); if (da < Angle) { AngularAcceleration = -AngularDrag; } else if (da > Angle) { AngularAcceleration = AngularDrag; } else { AngularAcceleration = 0; } //Figure out if we want the jets on or not. _timer += FlxG.elapsed; if (_timer > 8) { _timer = 0; } bool jetsOn = _timer < 6; //Set the bot's movement speed and direction //based on angle and whether the jets are on. _thrust = FlxU.computeVelocity(_thrust, (jetsOn?90:0), Drag.X, 60); FlxU.rotatePoint(0, (int)_thrust, 0, 0, Angle, Velocity); //Shooting - three shots every few seconds if (onScreen()) { bool shoot = false; float os = _shotClock; _shotClock += FlxG.elapsed; if ((os < 4.0) && (_shotClock >= 4.0)) { _shotClock = 0; shoot = true; } else if ((os < 3.5) && (_shotClock >= 3.5)) { shoot = true; } else if ((os < 3.0) && (_shotClock >= 3.0)) { shoot = true; } //If we rolled over one of those time thresholds, //shoot a bullet out along the angle we're currently facing. if (shoot) { //First, recycle a bullet from the bullet pile. //If there are none, recycle will automatically create one for us. EnemyBullet b = (EnemyBullet)_bullets.recycle(typeof(EnemyBullet)); //Then, shoot it from our midpoint out along our angle. b.shoot(getMidpoint(_tagPoint), Angle); } } //Then call FlxSprite's update() function, to automate // our motion and animation and stuff. base.update(); //Finally, update the jet particles shooting out the back of the ship. if (jetsOn) { if (!_jets.on) { //If they're supposed to be on and they're not, //turn em on and play a little sound. _jets.start(false, 0.5f, 0.01f); if (onScreen()) { _sfxJet.play(true); } } //Then, position the jets at the center of the Enemy, //and point the jets the opposite way from where we're moving. _jets.at(this); _jets.setXSpeed(-Velocity.X - 30, -Velocity.X + 30); _jets.setYSpeed(-Velocity.Y - 30, -Velocity.Y + 30); } else //If jets are supposed to be off, just turn em off. { _jets.on = false; } //Finally, update the jet emitter and all its member sprites. _jets.update(); }
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 update() { if (FlxG.keys.justPressed(Keys.Q)) { FlxG.bloom.Visible = !FlxG.bloom.Visible; FlxG.bloom.usePresets = true; follower.velocity.Y += 1450; } if (FlxG.keys.ONE) { FlxG.bloom.Settings = BloomPostprocess.BloomSettings.PresetSettings[1]; } if (FlxG.keys.TWO) { FlxG.bloom.Settings = BloomPostprocess.BloomSettings.PresetSettings[2]; } if (FlxG.keys.THREE) { FlxG.bloom.Settings = BloomPostprocess.BloomSettings.PresetSettings[3]; } if (FlxG.keys.FOUR) { FlxG.bloom.Settings = BloomPostprocess.BloomSettings.PresetSettings[4]; } if (FlxG.keys.FIVE) { FlxG.bloom.Settings = BloomPostprocess.BloomSettings.PresetSettings[5]; } if (FlxG.keys.SIX) { FlxG.bloom.Settings = BloomPostprocess.BloomSettings.PresetSettings[6]; } if (FlxG.keys.SEVEN) { FlxG.bloom.Settings = BloomPostprocess.BloomSettings.PresetSettings[7]; } foreach (FlxSprite item in rain.members) { if (item.y > 2000) { splashes.at(item); splashes.start(true, 0.0f, 10); item.y = 1200; } } base.update(); if (instruction.visible) { if (tween.hasEnded) { FlxG.play("Lemonade/sfx/cw_sound09", 0.75f, false); } } tween.Update(FlxG.elapsedAsGameTime); instruction.y = tween.Position; if (follower.y > 2100) { credits.visible = true; } if (follower.y > 2300) { instruction.visible = true; } if (((follower.y > int.MaxValue && follower.x == 0) || (FlxG.keys.justPressed(Keys.X) && follower.y > 100) || (FlxG.gamepads.isNewButtonPress(Buttons.A) && follower.y > 100) || (FlxControl.ACTIONJUSTPRESSED && follower.y > 100)) && (FlxG.transition.members[0] as FlxSprite).scale < 0.001f) { if (Lemonade_Globals.coins == Lemonade_Globals.totalCoins) { #if !__ANDROID__ FlxU.openURL("http://initials.itch.io/slf2/download/Y9wdBOHe7a92Qpo9t5UJdz05HhZR5p10F0L6wfdP"); #endif } follower.velocity.X = -250; } if (follower.x < 0) { FlxG.transition.startFadeOut(0.15f, -90, 150); follower.x = 1; follower.velocity.X = 1; } if (FlxG.transition.complete) { FlxG.state = new IntroState(); FlxG.transition.resetAndStop(); return; } }
override public void update() { if (FlxG.keys.justPressed(Keys.Q)) { FlxG.bloom.Visible = !FlxG.bloom.Visible; FlxG.bloom.usePresets = true; follower.velocity.Y += 1450; } if (FlxG.keys.ONE) { FlxG.bloom.Settings = BloomPostprocess.BloomSettings.PresetSettings[1]; } if (FlxG.keys.TWO) { FlxG.bloom.Settings = BloomPostprocess.BloomSettings.PresetSettings[2]; } if (FlxG.keys.THREE) { FlxG.bloom.Settings = BloomPostprocess.BloomSettings.PresetSettings[3]; } if (FlxG.keys.FOUR) { FlxG.bloom.Settings = BloomPostprocess.BloomSettings.PresetSettings[4]; } if (FlxG.keys.FIVE) { FlxG.bloom.Settings = BloomPostprocess.BloomSettings.PresetSettings[5]; } if (FlxG.keys.SIX) { FlxG.bloom.Settings = BloomPostprocess.BloomSettings.PresetSettings[6]; } if (FlxG.keys.SEVEN) { FlxG.bloom.Settings = BloomPostprocess.BloomSettings.PresetSettings[7]; } foreach (FlxSprite item in rain.members) { int rainOffset = 0; #if __ANDROID__ rainOffset = 50; #endif if (item.y > 2000 - rainOffset) { splashes.at(item); splashes.start(true, 0.0f, 10); item.y = 1200; } } base.update(); if (instruction.visible) { if (tween.hasEnded) { FlxG.play("Lemonade/sfx/cw_sound09", 0.75f, false); } } tween.Update(FlxG.elapsedAsGameTime); instruction.y = tween.Position; if (follower.y > 2100) { credits.visible = true; } if (follower.y > 2300) { credits.text = "Pixel Art by\nMiguelito"; } if (follower.y > 2500) { credits.text = "Dithering Expert\nAndrio"; } if (follower.y > 2700) { credits.text = "Super"; } if (follower.y > 2900) { credits.text = "Lemonade"; } if (follower.y > 3000) { credits.text = "Factory"; } if (follower.y > 3100) { credits.scale = 5; credits.text = "1989"; } if (follower.y > 3200) { credits.scale = 2; #if __ANDROID__ credits.scale = 4; #endif credits.text = "Super Lemonade\nFactory 1989"; } if (follower.y > 3300) { instruction.visible = true; } if (((follower.y > int.MaxValue && follower.x == 0) || (FlxG.keys.justPressed(Keys.X) && follower.y > 100) || (FlxG.gamepads.isNewButtonPress(Buttons.A) && follower.y > 100) || (FlxControl.ACTIONJUSTPRESSED && follower.y > 100)) && (FlxG.transition.members[0] as FlxSprite).scale < 0.001f) { FlxG.transition.startFadeOut(0.15f, -90, 150); follower.x = 1; } if (FlxG.transition.complete) { FlxG.level = 1; Lemonade_Globals.stateSaver = new Dictionary <string, Dictionary <string, Vector2> > { { "newyork", new Dictionary <string, Vector2>() }, { "sydney", new Dictionary <string, Vector2>() }, { "military", new Dictionary <string, Vector2>() }, { "warehouse", new Dictionary <string, Vector2>() }, { "factory", new Dictionary <string, Vector2>() }, { "management", new Dictionary <string, Vector2>() }, }; foreach (var item in Lemonade_Globals.stateSaver) { Lemonade_Globals.thisTurnProgress[item.Key] = 0; } Lemonade_Globals.levelChanges = 0; Lemonade_Globals.coins = 0; Lemonade_Globals.timeLeft = Lemonade_Globals.totalTimeAvailable = 30.1f; FlxG.state = new LevelChooserState(); return; } }
public override void update() { base.update(); if(title2.X > title1.X + title1.Width - 4) { //Once mo and de cross each other, fix their positions title2.X = title1.X + title1.Width - 4; title1.Velocity.X = 0; title2.Velocity.X = 0; //Then, play a cool sound, change their color, and blow up pieces everywhere /* FlxG.play(SndHit, 1f, false, false); */ FlxG.flash(Color.White,0.5f); FlxG.shake(0.035f,0.5f); title1.Color = Color.White; title2.Color = Color.White; gibs.start(true,5); title1.Angle = FlxG.random()*30-15; title2.Angle = FlxG.random()*30-15; //Then we're going to add the text and buttons and things that appear //If we were hip we'd use our own button animations, but we'll just recolor //the stock ones for now instead. FlxText text; text = new FlxText(FlxG.width/2-50,FlxG.height/3+39,100,"by Adam Atomic"); /*text.Alignment = "center";*/ text.Color = Color.White; add(text); /* FlxButton flixelButton = new FlxButton(FlxG.width/2-40,FlxG.height/3+54,"flixel.org",new IFlxButton(){ public void callback(){onFlixel();}}); flixelButton.setColor(0xff729954); flixelButton.label.setColor(0xffd8eba2); ModeMenuState(flixelButton); FlxButton dannyButton = new FlxButton(flixelButton.X,flixelButton.Y + 22,"music: dannyB",new IFlxButton(){ public void callback(){onDanny();}}); dannyButton.setColor(flixelButton.getColor()); dannyButton.label.setColor(flixelButton.label.getColor()); add(dannyButton); */ text = new FlxText(FlxG.width/2-40,FlxG.height/3+139,80,"X+C TO PLAY"); text.Color = Color.White; //text.setAlignment("center"); add(text); /* playButton = new FlxButton(flixelButton.X,flixelButton.Y + 82,"CLICK HERE", onPlay()); playButton.setColor(flixelButton.getColor()); playButton.label.setColor(flixelButton.label.getColor()); add(playButton); */ } //X + C were pressed, fade out and change to play state. //OR, if we sat on the menu too long, launch the attract mode instead! timer += FlxG.elapsed; if(timer >= 10) //go into demo mode if no buttons are pressed for 10 seconds attractMode = true; if(!fading && ((FlxG.keys.pressed(Keys.X) && FlxG.keys.pressed(Keys.C)) /*|| (_pad.buttonA.status == FlxButton.Pressed && _pad.buttonB.status == FlxButton.Pressed) */ || attractMode)) { fading = true; /*FlxG.play(SndHit2, 1f, false, false);*/ FlxG.flash(Color.White,0.5f); FlxG.fade(Color.Black,1, onFade); } }
override public void update() { #region cheats if (FlxG.debug == true && elapsedInState > 0.2f) { } #endregion #region pirateVersion if (Lemonade_Globals.PAID_VERSION == Lemonade_Globals.PIRATE_MODE) { if (elapsedInState > 3.0 && FlxG.level > 2) { foreach (var item in actors.members) { ((FlxPlatformActor)(item)).maxVelocity.X += 2.5f; } foreach (var mov in movingPlatforms.members) { mov.pathSpeed += 0.25f; } } } #endregion //FlxG.color(Color.MediumPurple); //FlxU.collideRamp(actors, ramps); //if (FlxG.keys.justPressed(Keys.F11)) if (FlxG.gamepads.isButtonDown(Buttons.LeftTrigger) && FlxG.debug) { if (coins.getFirstAlive() != null) { ((FlxSprite)(actors.members[0])).at(coins.getFirstAlive()); } } currentCharHud.canStart = !levelIntro.block.visible; if (currentCharHud.canStart) { ((FlxPlatformActor)(actors.members[0])).control = FlxPlatformActor.Controls.player; } else if (!currentCharHud.canStart) { ((FlxPlatformActor)(actors.members[0])).control = FlxPlatformActor.Controls.none; } if (currentCharHud.time < -0.5f) { if (Lemonade_Globals.totalTimeAvailable < -0.5f) { FlxG.state = new BaseInformationState(); } else { goToNextScheduledLevel(); } } if (Lemonade_Globals.game_version == 2) { FlxU.collide(collidableTilemap, actors); FlxU.collide(crateParticle, collidableTilemap); FlxU.collide(levelItems, collidableTilemap); FlxU.collide(smallCrates, collidableTilemap); } else { FlxU.collide(collidableTileblocks, actors); FlxU.collide(crateParticle, collidableTileblocks); FlxU.collide(levelItems, collidableTileblocks); FlxU.collide(smallCrates, collidableTileblocks); } FlxU.overlap(actors, actors, genericOverlap); FlxU.overlap(actors, trampolines, trampolinesOverlap); FlxU.overlap(actors, levelItems, genericOverlap); FlxU.overlap(actors, hazards, genericOverlap); FlxU.overlap(actors, coins, genericOverlap); FlxU.overlap(actors, smallCrates, genericOverlap); FlxU.overlap(smallCrates, trampolines, trampolinesOverlap); FlxU.collide(actors, movingPlatforms); FlxU.collide(smallCrates, levelItems); FlxU.collideOnY(smallCrates, andre); FlxU.collideOnY(smallCrates, liselot); bool andreExit = FlxU.overlap(andre, exit, exitOverlap); bool liselotExit = FlxU.overlap(liselot, exit, exitOverlap); if (andreExit && liselotExit) { levelComplete = true; } FlxU.collide(actors, levelItems); foreach (FlxObject crate in levelItems.members) { if (crate.GetType().ToString() == "Lemonade.LargeCrate") { if (((LargeCrate)(crate)).canExplode && !crate.dead) { crateParticle.at(crate); crateParticle.start(true, 0.0f, 50); crate.kill(); FlxG.play("Lemonade/sfx/cw_sound35", 0.5f, false); } } } base.update(); #if __ANDROID__ if (FlxG.pauseAction == "Exit") { #if __ANDROID__ FlxG.state = new IntroState(); #endif #if !__ANDROID__ FlxG.state = new EasyMenuState(); #endif } #endif if (FlxG.keys.justPressed(Keys.Escape) || FlxG.gamepads.isButtonDown(Buttons.Back)) { #if __ANDROID__ FlxG.state = new IntroState(); #endif #if !__ANDROID__ FlxG.state = new BaseInformationState(); #endif } if (levelComplete == true) { //andre.alpha -= 0.1f; //liselot.alpha -= 0.1f; } if (levelComplete == true && !FlxG.transition.hasStarted) { if (transitionPause == 0.0f) { FlxG.play("initials/initials_empire_tagtone4", 0.8f, false); } FlxG.pauseMp3(); andre.control = FlxPlatformActor.Controls.none; liselot.control = FlxPlatformActor.Controls.none; andre.visible = false; liselot.visible = false; transitionPause += FlxG.elapsed; if (transitionPause > 0.85f) { FlxG.transition.startFadeOut(0.05f, -90, 150); } } if (FlxG.transition.complete) { if (FlxG.level != 12) { //FlxG.level++; goToNextScheduledLevel(); Lemonade_Globals.restartMusic = false; if (Lemonade_Globals.PAID_VERSION == Lemonade_Globals.DEMO_MODE && FlxG.level >= 3) { #if __ANDROID__ FlxG.state = new IntroState(); #endif #if !__ANDROID__ FlxG.state = new BaseInformationState(); #endif FlxG.transition.resetAndStop(); return; } else { Lemonade_Globals.timeLeft = currentCharHud.time; FlxG.transition.resetAndStop(); goToNextScheduledLevel(); return; } } if (FlxG.level == 12 && Lemonade_Globals.game_version == 2) { FlxG.state = new BaseInformationState(); FlxG.transition.resetAndStop(); return; } else if (FlxG.level == 12 && Lemonade_Globals.game_version == 1) { #if __ANDROID__ FlxG.state = new IntroState(); #endif #if !__ANDROID__ FlxG.state = new BaseInformationState(); #endif FlxG.transition.resetAndStop(); return; } } if (coins.countLiving() == 0 && !FlxG.transition.hasStarted) { if (Lemonade_Globals.coins == Lemonade_Globals.totalCoins) { FlxG.state = new BaseInformationState(); return; } else { Lemonade_Globals.thisTurnProgress[Lemonade_Globals.location] = 1; foreach (var item in Lemonade_Globals.thisTurnProgress) { Console.WriteLine("This Location: {0} -- K {1} V {2}", Lemonade_Globals.location, item.Key, item.Value); } FlxG.transition.startFadeOut(0.05f, -90, 150); } } }