override public void create() { FlxG.resetHud(); FlxG.showHud(); FlxG.backColor = Color.LightGray; base.create(); string levelData = FlxU.randomString(10); FlxG.log("levelData: " + levelData); makeCave(0.1f, Color.Black); makeCave(0.5f, new Color(0.98f, 1.0f, 0.95f)); makeCave2(1.0f, Color.Green); spaceShip = new FlxSprite(60, 60); spaceShip.loadGraphic(FlxG.Content.Load <Texture2D>("flixel/surt/spaceship_32x32"), true, false, 32, 32); spaceShip.addAnimation("Static", new int[] { 0 }, 36, true); spaceShip.addAnimation("Transform", new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39 }, 36, false); spaceShip.play("Static"); spaceShip.setDrags(1100, 1100); add(spaceShip); FlxG.follow(spaceShip, 10.0f); FlxG.followBounds(0, 0, 50 * 16, 40 * 16); }
override public void create() { base.create(); FlxG.hideHud(); FlxG.resetHud(); robot = new FlxSprite(60, 60); robot.loadGraphic("flixel/surt/race_or_die", true, false, 64, 64); robot.addAnimation("static", new int[] { 0 }, 12, true); robot.play("static"); robot.angle = 0; robot.width = 32; robot.height = 32; robot.setOffset(12, 12); robot.health = 100; robot.alpha = 0.1f; add(robot); bar = new FlxBar(30, 30, FlxBar.FILL_LEFT_TO_RIGHT, 100, 10, robot, "rad", 0, 100, true); add(bar); bar2 = new FlxBar(60, 90, FlxBar.FILL_LEFT_TO_RIGHT, 20, 2, null, "health", 0, 100, false); bar2.loadCustomEmptyGraphic("flixel/initials/healthBar"); bar2.emptyBar.offset.X = 2; bar2.emptyBar.offset.Y = 3; add(bar2); }
override public void create() { base.create(); FlxSprite robot = new FlxSprite(0, 0); robot.loadGraphic("flixel/surt/race_or_die", true, false, 64, 64); robot.addAnimation("static", new int[] { 7 }, 0, true); robot.play("static"); add(robot); robot.angle = 210; robot.setVelocityFromAngle(100); robot = new FlxSprite(200, 0); robot.loadGraphic("flixel/surt/race_or_die", true, false, 64, 64); robot.addAnimation("static", new int[] { 10 }, 0, true); robot.play("static"); add(robot); robot.setVelocity(-30, 100); robot.setAngleFromVelocity(); }
override public void create() { base.create(); for (int i = 0; i < 40; i++) { for (int y = 0; y < 40; y++) { 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"); add(x); } } FlxTilemap t = new FlxTilemap(); string map = "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0\n"; map += "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0\n"; map += "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0\n"; map += "0,0,1,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0\n"; map += "0,0,1,0,0,0,0,1,0,1,0,1,0,0,0,1,0,1,0,0,0,1,0,1,1,1,1,1,0,1,1,1,0,0,0,0,0\n"; map += "0,0,1,0,0,0,0,1,0,1,0,1,1,0,0,1,0,1,1,0,0,1,0,1,0,0,0,0,0,1,0,0,1,0,0,0,0\n"; map += "0,0,1,0,1,0,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,1,0,0,0,0,1,1,1,1,0,0,0,0\n"; map += "0,0,1,0,1,0,0,1,0,1,0,1,0,0,1,1,0,1,0,0,1,1,0,1,0,0,0,0,0,1,0,1,0,0,0,0,0\n"; map += "0,0,0,1,0,1,1,0,0,1,0,1,0,0,0,1,0,1,0,0,0,1,0,1,1,1,1,0,0,1,0,0,1,0,0,0,0\n"; map += "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0\n"; map += "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0\n"; map += "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0\n"; map += "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0\n"; map += "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0\n"; map += "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0\n"; map += "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0\n"; map += "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0\n"; map += "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0\n"; map += "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0\n"; map += "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0\n"; map += "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0\n"; map += "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0\n"; map += "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0\n"; map += "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0\n"; map += "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0\n"; t.auto = FlxTilemap.AUTO; t.loadMap(map, FlxG.Content.Load <Texture2D>("autotilesIsland"), 8, 8); add(t); }
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); }
private void setupPlayer() { player = new FlxSprite(64, 220); player.loadGraphic(ImgSpaceman, true, true, 16); //bounding box tweaks player.Width = 14; player.Height = 14; player.Offset.X = 1; player.Offset.Y = 1; //basic player physics player.Drag.X = 640; player.Acceleration.Y = 420; player.MaxVelocity.X = 80; player.MaxVelocity.Y = 200; //animations player.addAnimation("idle", new int[] { 0 }); player.addAnimation("run", new int[] { 1, 2, 3, 0 }, 12); player.addAnimation("jump", new int[] { 4 }); add(player); }
public override void create() { base.create(); //FlxG.addCamera(new FlxCamera(50, 50, 500, 500)); //defaultLogo = new FlxSprite(FlxG.width / 2, FlxG.height / 2); ////defaultLogo.scaling = new FlxPoint(10, 10); //this.add(defaultLogo); //block = new FlxSprite(0, 0); //block.makeGraphic(100, 100, FlxColor.CYAN); //this.add(block); //block2 = new FlxSprite(100, 0); //block2.makeGraphic(100, 100, FlxColor.GREEN); //this.add(block2); //block3 = new FlxSprite(0, 100); //block3.makeGraphic(100, 100, FlxColor.INDIGO); //block3.drawLine(0, 0, 99, 99, FlxColor.BLACK, 1); //this.add(block3); //block4 = new FlxSprite(100, 100); //block4.makeGraphic(100, 100, FlxColor.PINK); //this.add(block4); background = new FlxSprite(0, 0, FlxS.ContentManager.Load <Texture2D>("bg")); this.add(background); megaman = new FlxSprite(50, 150); //megaman.loadGraphic(FlxS.ContentManager.Load<Texture2D>("megaman_run_test"), true, false, 49, 49); megaman.loadGraphic(FlxS.ContentManager.Load <Texture2D>("megaman_run"), true, false, 49, 49); megaman.addAnimation("run", new[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1 }, 12); megaman.play("run", true); this.add(megaman); //FlxG.playMusic(FlxS.ContentManager.Load<SoundEffect>("applause")); //FlxG.play(FlxS.ContentManager.Load<SoundEffect>("background")); // change content processor to soundeffect //DoFlash(); DoQuake(); }
override public void create() { FlxG.hideHud(); FlxG.backColor = Color.LightGray; base.create(); makeCave2(1.0f, Color.Green); logo = new FlxSprite(360, 360); logo.loadGraphic("flixel/surt/race_or_die", true, false, 64, 64); logo.addAnimation("Static", new int[] { 8 }, 0, true); logo.play("Static"); logo.setDrags(5, 5); add(logo); FlxG.follow(logo, 10.0f); FlxG.followBounds(0, 0, 150 * 16, 140 * 16); velValue = 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); }
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); }
override public void create() { base.create(); FlxG.resetHud(); makeCave(1.0f, Color.White); FlxSprite avatar = new FlxSprite(0, FlxG.height - 64); avatar.loadGraphic(FlxG.Content.Load <Texture2D>("flixel/surt/race_or_die"), true, false, 64, 64); avatar.addAnimation("Static", new int[] { 2 }, 0, true); avatar.play("Static"); avatar.setScrollFactors(0, 0); add(avatar); p = new FlxPath(null); addPathPointWithMarker(40.0f, 40.0f, 0); addPathPointWithMarker(522.67800098f, 342.106739267f, 1); addPathPointWithMarker(582.8467536f, 603.25142048f, 2); addPathPointWithMarker(531.13384868f, 263.27163512f, 3); addPathPointWithMarker(1447.02681801f, 449.15789055f, 4); addPathPointWithMarker(1201.74908191f, 528.33347167f, 5); addPathPointWithMarker(147.07640576f, 672.46462447f, 6); addPathPointWithMarker(199.62346884f, 584.58110087f, 7); addPathPointWithMarker(108.19931517f, 355.52333218f, 8); addPathPointWithMarker(698.584671041f, 174.70156601f, 9); for (int i = 0; i < 9; i++) { FlxLine line = new FlxLine(0, 0, new Vector2(p.nodes[i].X, p.nodes[i].Y), new Vector2(p.nodes[i + 1].X, p.nodes[i + 1].Y), Color.White, 2); add(line); } car = new FlxSprite(40, 40); car.loadGraphic(FlxG.Content.Load <Texture2D>("flixel/surt/race_or_die"), true, false, 64, 64); //car.addAnimation("Static", new int[] { 8 }, 0, true); //car.play("Static"); car.frame = 8; car.setDrags(5, 5); add(car); car.path = p; car.pathCornering = 5.0f; car.pathAngleOffset = 180; //car.pathSpeed = 500.0f; car.followPath(p, 250.0f, FlxSprite.PATH_LOOP_FORWARD, true); FlxG.follow(car, 5.0f); FlxG.followBounds(0, 0, 100 * 16, 100 * 16); for (int i = 0; i < 7; i++) { p = new FlxPath(null); p.add(40.0f, 40.0f); p.add(522.67800098f + FlxU.random(1, 100), 342.106739267f + FlxU.random(1, 100)); p.add(582.8467536f, 603.25142048f + FlxU.random(1, 1200)); p.add(531.13384868f, 263.27163512f + FlxU.random(1, 1200)); p.add(1447.02681801f, 449.15789055f + FlxU.random(1, 1200)); p.add(1201.74908191f, 528.33347167f + FlxU.random(1, 1200)); p.add(147.07640576f, 672.46462447f + FlxU.random(1, 1200)); p.add(199.62346884f, 584.58110087f + FlxU.random(1, 1200)); p.add(108.19931517f, 355.52333218f + FlxU.random(1, 1200)); p.add(698.584671041f, 174.70156601f + FlxU.random(1, 2100)); car = new FlxSprite(40, 40); car.loadGraphic(FlxG.Content.Load <Texture2D>("flixel/surt/race_or_die"), true, false, 64, 64); //car.addAnimation("Static", new int[] { 8 }, 0, true); //car.play("Static"); car.frame = 6 + i; car.setDrags(5, 5); add(car); car.path = p; car.pathCornering = 5.0f; car.pathAngleOffset = 180; //car.pathSpeed = 500.0f; car.followPath(p, 50.0f + (i * 30), FlxSprite.PATH_LOOP_FORWARD, true); } }
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); }