public void makeCave2(float Scroll, Color Col) { FlxCaveGeneratorExt caveExt = new FlxCaveGeneratorExt(150, 140, 0.45f, 5); string[,] caveLevel = caveExt.generateCaveLevel(); //Optional step to print cave to the console. //caveExt.printCave(caveLevel); string newMap = caveExt.convertMultiArrayStringToString(caveLevel); //Create a tilemap and assign the cave map. tiles = new FlxTilemap(); tiles.auto = FlxTilemap.STRING; tiles.loadMap(newMap, FlxG.Content.Load <Texture2D>("flixel/autotiles_16x16"), 16, 16); tiles.setScrollFactors(Scroll, Scroll); tiles.color = Col; add(tiles); }
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.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); }
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); }
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); }
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); }