public FlxRecord() { vcrGroup = new FlxGroup(); // Customizable things filename = "File"; controller = PlayerIndex.One; //int xPos = 150; int yPos = 30; openSprite = new FlxSprite(130, yPos); openSprite.loadGraphic(FlxG.Content.Load <Texture2D>("flixel/vcr/open")); openSprite.setScrollFactors(0, 0); openSprite.debugName = "open"; vcrGroup.add(openSprite); openSprite.boundingBoxOverride = false; pauseSprite = new FlxSprite(230, yPos); pauseSprite.loadGraphic(FlxG.Content.Load <Texture2D>("flixel/vcr/pause")); pauseSprite.setScrollFactors(0, 0); pauseSprite.debugName = "pause"; vcrGroup.add(pauseSprite); pauseSprite.boundingBoxOverride = false; playSprite = new FlxSprite(330, yPos); playSprite.loadGraphic(FlxG.Content.Load <Texture2D>("flixel/vcr/play")); playSprite.setScrollFactors(0, 0); playSprite.debugName = "play"; vcrGroup.add(playSprite); playSprite.boundingBoxOverride = false; recordSprite = new FlxSprite(430, yPos); recordSprite.loadGraphic(FlxG.Content.Load <Texture2D>("flixel/vcr/record_on")); recordSprite.setScrollFactors(0, 0); recordSprite.debugName = "record"; vcrGroup.add(recordSprite); recordSprite.boundingBoxOverride = false; restartSprite = new FlxSprite(530, yPos); restartSprite.loadGraphic(FlxG.Content.Load <Texture2D>("flixel/vcr/restart")); restartSprite.setScrollFactors(0, 0); restartSprite.debugName = "restart"; vcrGroup.add(restartSprite); restartSprite.boundingBoxOverride = false; stopSprite = new FlxSprite(630, yPos); stopSprite.loadGraphic(FlxG.Content.Load <Texture2D>("flixel/vcr/stop")); stopSprite.setScrollFactors(0, 0); stopSprite.debugName = "stop"; vcrGroup.add(stopSprite); stopSprite.boundingBoxOverride = false; infoText = new FlxText(360, yPos, FlxG.width); infoText.boundingBoxOverride = false; }
private void addRandomObjects(int NumberToAdd, string typeOfObject, FlxGroup group) { for (int i = 0; i < NumberToAdd; i++) { Vector2 randomSpot = Registry.levelAsTilemap.getRandomTilePositionWithType(Registry.levelAsTilemap.remapGuide[15]); if (group == null) add(SpriteFactory.createObject(typeOfObject, (int)randomSpot.X, (int)randomSpot.Y)); else group.add(SpriteFactory.createObject(typeOfObject, (int)randomSpot.X, (int)randomSpot.Y)); } }
public override void create() { ImgTiles = FlxG.Content.Load<Texture2D>("Mode/tiles_all"); //load map from file string sMap; using (Stream file = TitleContainer.OpenStream("Content/" + TxtMap)) { StreamReader sr = new StreamReader(file); sMap = sr.ReadToEnd().Replace("\r", ""); sr.Close(); } //create tilemap _tilemap = new FlxTilemap(); _tilemap.collideIndex = 3; _tilemap.loadMap(sMap, ImgTiles, 8, 8); //_tilemap.loadMap(new TxtMap2,ImgTiles,8); //This is an alternate tiny map //create player and bullets _bullets = new FlxGroup(); _player = new Player((int)(_tilemap.width/2-4),(int)_tilemap.height/2-4,_bullets.members,null); for(int i = 0; i < 8; i++) _bullets.add(new Bullet()); add(_bullets); //add player and set up camera add(_player); FlxG.follow(_player,2.5f); FlxG.followAdjust(0.5f,0.0f); _tilemap.follow(); //Set the followBounds to the map dimensions //Uncomment these lines if you want to center TxtMap2 //var fx:uint = _tilemap.width/2 - FlxG.width/2; //var fy:uint = _tilemap.height/2 - FlxG.height/2; //FlxG.followBounds(fx,fy,fx,fy); //add tilemap last so it is in front, looks neat add(_tilemap); //fade in FlxG.flash.start(new Color(0x13, 0x1c, 0x1b), 1f); //The music in this mode is positional - it fades out toward the edges of the level FlxSound s = FlxG.play(SndMode,1,true); s.proximity(320,320,_player,160); }
public Spawner(int X, int Y, FlxEmitter Gibs, FlxGroup Bots, List<FlxObject> BotBullets, FlxEmitter BotGibs, Player ThePlayer) : base(X, Y) { ImgSpawner = FlxG.Content.Load<Texture2D>("Mode/spawner"); loadGraphic(ImgSpawner,true); _gibs = Gibs; _bots = Bots; _botBullets = BotBullets; _botGibs = BotGibs; _player = ThePlayer; _timer = FlxU.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}); }
override public void create() { base.create(); Registry.levelSize = Registry.getLevelSize(); FlxG.elapsedTotal = 0; add(SpriteFactory.createCave()); hero = SpriteFactory.createSprite(new Dictionary<string, string> { { "Name", "CharacterPlayerControlled" }, { "x", (((int)Registry.levelSize.X * Registry.tileSize) / 2).ToString() }, { "y", (((int)Registry.levelSize.X * Registry.tileSize) / 2).ToString() } }); createStaircase(); enemies = new FlxGroup(); addRandomObjects(5 * Registry.levelNumber, "CharacterComputerControlled", enemies); add(enemies); pickups = new FlxGroup(); addRandomObjects(55, "PickUp", pickups); add(pickups); add(hero); FlxG.follow(hero, 9); FlxG.followBounds(0, 0, (int)Registry.levelSize.X * Registry.tileSize, (int)Registry.levelSize.Y * Registry.tileSize); //FlxG.showBounds = true; //add(SpriteFactory.createTileblock(new Dictionary<string, string> { { "Name", "UIBox" }, { "x", "10" }, { "y", "10" }, { "width", "64" }, { "height", "32" } })); add(SpriteFactory.createSprite(new Dictionary<string, string> { { "Name", "MoveCounter" }, { "x", "-1" }, { "y", "-1" } })); add(battleUI = new BattleUI()); add(messageBox = new MessageBox()); }
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); }
public override void create() { base.create(); ImgTech=FlxG.Content.Load<Texture2D>("Mode/tech_tiles"); ImgDirtTop=FlxG.Content.Load<Texture2D>("Mode/dirt_top"); ImgDirt=FlxG.Content.Load<Texture2D>("Mode/dirt"); ImgNotch=FlxG.Content.Load<Texture2D>("Mode/notch"); ImgGibs=FlxG.Content.Load<Texture2D>("Mode/gibs"); ImgSpawnerGibs = FlxG.Content.Load<Texture2D>("Mode/spawner_gibs"); FlxG.mouse.hide(); reload = false; //get the gibs set up and out of the way _littleGibs = new FlxEmitter(); _littleGibs.delay = 3; _littleGibs.setXSpeed(-150,150); _littleGibs.setYSpeed(-200,0); _littleGibs.setRotation(-720,-720); _littleGibs.createSprites(ImgGibs,100,true,0.5f,0.65f); _bigGibs = new FlxEmitter(); _bigGibs.setXSpeed(-200,200); _bigGibs.setYSpeed(-300,0); _bigGibs.setRotation(-720,-720); _bigGibs.createSprites(ImgSpawnerGibs,50,true,0.5f,0.35f); //level generation needs to know about the spawners (and thusly the bots, players, etc) _blocks = new FlxGroup(); _decorations = new FlxGroup(); _bullets = new FlxGroup(); _player = new Player(316,300,_bullets.members,_littleGibs); _bots = new FlxGroup(); _botBullets = new FlxGroup(); _spawners = new FlxGroup(); //simple procedural level generation int i; int r = 160; FlxTileblock b; b = new FlxTileblock(0,0,640,16); b.loadGraphic(ImgTech); _blocks.add(b); b = new FlxTileblock(0,16,16,640-16); b.loadGraphic(ImgTech); _blocks.add(b); b = new FlxTileblock(640-16,16,16,640-16); b.loadGraphic(ImgTech); _blocks.add(b); b = new FlxTileblock(16,640-24,640-32,8); b.loadGraphic(ImgDirtTop); _blocks.add(b); b = new FlxTileblock(16,640-16,640-32,16); b.loadGraphic(ImgDirt); _blocks.add(b); buildRoom(r * 0, r * 0, true); buildRoom(r*1,r*0); buildRoom(r*2,r*0); buildRoom(r * 3, r * 0, true); buildRoom(r * 0, r * 1, true); buildRoom(r*1,r*1); buildRoom(r*2,r*1); buildRoom(r * 3, r * 1, true); buildRoom(r*0,r*2); buildRoom(r*1,r*2); buildRoom(r*2,r*2); buildRoom(r*3,r*2); buildRoom(r*0,r*3,true); buildRoom(r*1,r*3); buildRoom(r*2,r*3); buildRoom(r*3,r*3,true); //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(_bots); //actually create the bullets now for(i = 0; i < 50; i++) _botBullets.add(new BotBullet()); for(i = 0; i < 8; i++) _bullets.add(new Bullet()); //add player and set up scrolling camera add(_player); FlxG.follow(_player,2.5f); FlxG.followAdjust(0.5f,0.0f); FlxG.followBounds(0,0,640,640); //add gibs + bullets to scene here, so they're drawn on top of pretty much everything add(_botBullets); add(_bullets); //finally we are going to sort things into a couple of helper groups. //we don't add these to the state, we just use them for collisions later! _enemies = new FlxGroup(); _enemies.add(_botBullets); _enemies.add(_spawners); _enemies.add(_bots); _objects = new FlxGroup(); _objects.add(_botBullets); _objects.add(_bullets); _objects.add(_bots); _objects.add(_player); _objects.add(_littleGibs); _objects.add(_bigGibs); //HUD - score Vector2 ssf = new Vector2(0,0); _score = new FlxText(0,0,FlxG.width); _score.color = new Color (0xd8, 0xeb, 0xa2); _score.scale = 2; _score.alignment = FlxJustification.Center; _score.scrollFactor = ssf; _score.shadow = new Color(0x13, 0x1c, 0x1b); add(_score); if (FlxG.scores.Count < 2) { FlxG.scores.Add(0); FlxG.scores.Add(0); } //HUD - highest and last scores _score2 = new FlxText(FlxG.width/2,0,FlxG.width/2); _score2.color = new Color(0xd8, 0xeb, 0xa2); _score2.alignment = FlxJustification.Right; _score2.scrollFactor = ssf; _score2.shadow = _score.shadow; add(_score2); if (FlxG.score > FlxG.scores[0]) FlxG.scores[0] = FlxG.score; if (FlxG.scores[0] != 0) _score2.text = "HIGHEST: " + FlxG.scores[0] + "\nLAST: " + FlxG.score; FlxG.score = 0; _scoreTimer = 0; //HUD - the "number of spawns left" icons _notches = new List<FlxSprite>(); FlxSprite tmp; for(i = 0; i < 6; i++) { tmp = new FlxSprite(4+i*10,4); tmp.loadGraphic(ImgNotch,true); tmp.scrollFactor.X = tmp.scrollFactor.Y = 0; tmp.addAnimation("on", new int[] {0}); tmp.addAnimation("off",new int[] {1}); tmp.moves = false; tmp.solid = false; tmp.play("on"); _notches.Add((FlxSprite)this.add(tmp)); } //HUD - the "gun jammed" notification _jamBar = this.add((new FlxSprite(0,FlxG.height-22)).createGraphic(FlxG.width,24, new Color(0x13, 0x1c, 0x1b))) as FlxSprite; _jamBar.scrollFactor.X = _jamBar.scrollFactor.Y = 0; _jamBar.visible = false; _jamText = new FlxText(0,FlxG.height-22,FlxG.width,"GUN IS JAMMED"); _jamText.color = new Color(0xd8, 0xeb, 0xa2); _jamText.scale = 2; _jamText.alignment = FlxJustification.Center; _jamText.scrollFactor = ssf; _jamText.visible = false; add(_jamText); FlxG.playMusic(SndMode); FlxG.flash.start(new Color(0x13, 0x1c, 0x1b), 0.5f, null, false); _fading = false; }
override public void create() { base.create(); buttons = new FlxGroup(); }
/** * Creates a new <code>FlxState</code> object, * instantiating <code>screen</code> if necessary. */ public FlxState() { defaultGroup = new FlxGroup(); }
/// <summary> /// FlxHud /// </summary> /// <param name="targetLeft"></param> /// <param name="targetWidth"></param> public FlxHud(int targetLeft, int targetWidth) { _consoleRect = new Rectangle(0, 0, FlxG.spriteBatch.GraphicsDevice.Viewport.Width, FlxG.spriteBatch.GraphicsDevice.Viewport.Height); _consoleColor = new Color(0, 0, 0, 0x00); visible = false; hudGroup = new FlxGroup(); hudGroup.scrollFactor.X = 0; hudGroup.scrollFactor.Y = 0; string keys = "flixel/buttons/MapWhite"; string xbox360 = "flixel/buttons/Map360"; string ouya = "flixel/buttons/MapOuya"; if (FlxG.buildDescription == "GAMEBOY") { keys = "flixel/buttons/MapWhiteGameboy"; xbox360 = "flixel/buttons/Map360Gameboy"; ouya = "flixel/buttons/MapOuyaGameboy"; } p1OriginalPosition = new Vector2(targetLeft, 0); p2OriginalPosition = new Vector2(targetLeft, 0); p3OriginalPosition = new Vector2(targetLeft, FlxG.spriteBatch.GraphicsDevice.Viewport.Height - 20); p4OriginalPosition = new Vector2(targetLeft, FlxG.spriteBatch.GraphicsDevice.Viewport.Height - 20); //FlxG.Content.Load<SpriteFont>("flixel/initials/SpaceMarine") if (FlxG.hudFont == null) { p1HudText = new FlxText(targetLeft, 0, targetWidth, "").setFormat(null, 1, Color.White, FlxJustification.Left, Color.White); p2HudText = new FlxText(targetLeft, 0, targetWidth, "").setFormat(null, 1, Color.White, FlxJustification.Right, Color.White); p3HudText = new FlxText(targetLeft, FlxG.spriteBatch.GraphicsDevice.Viewport.Height - 20, targetWidth, "").setFormat(null, 1, Color.White, FlxJustification.Left, Color.White); p4HudText = new FlxText(targetLeft, FlxG.spriteBatch.GraphicsDevice.Viewport.Height - 20, targetWidth, "").setFormat(null, 1, Color.White, FlxJustification.Right, Color.White); } else { p1HudText = new FlxText(targetLeft, 0, targetWidth, "").setFormat(FlxG.Content.Load <SpriteFont>(FlxG.hudFont), 1, Color.White, FlxJustification.Left, Color.Black); p2HudText = new FlxText(targetLeft, 0, targetWidth, "").setFormat(FlxG.Content.Load <SpriteFont>(FlxG.hudFont), 1, Color.White, FlxJustification.Right, Color.Black); p3HudText = new FlxText(targetLeft, FlxG.spriteBatch.GraphicsDevice.Viewport.Height - 20, targetWidth, "").setFormat(FlxG.Content.Load <SpriteFont>(FlxG.hudFont), 1, Color.White, FlxJustification.Left, Color.Black); p4HudText = new FlxText(targetLeft, FlxG.spriteBatch.GraphicsDevice.Viewport.Height - 20, targetWidth, "").setFormat(FlxG.Content.Load <SpriteFont>(FlxG.hudFont), 1, Color.White, FlxJustification.Right, Color.Black); } keyboardButton = new FlxSprite(targetLeft, -1000); keyboardButton.loadGraphic(FlxG.Content.Load <Texture2D>(keys), true, false, 100, 100); keyboardButton.addAnimation("frame", new int[] { FlxButton.ControlPadA }); keyboardButton.play("frame"); keyboardButton.solid = false; keyboardButton.visible = true; keyboardButton.scrollFactor.X = 0; keyboardButton.scrollFactor.Y = 0; keyboardButton.boundingBoxOverride = false; xboxButton = new FlxSprite(targetLeft, -1000); xboxButton.loadGraphic(FlxG.Content.Load <Texture2D>(xbox360), true, false, 100, 100); xboxButton.addAnimation("frame", new int[] { FlxButton.ControlPadA }); xboxButton.play("frame"); xboxButton.solid = false; xboxButton.visible = true; xboxButton.scrollFactor.X = 0; xboxButton.scrollFactor.Y = 0; xboxButton.boundingBoxOverride = false; ouyaButton = new FlxSprite(targetLeft, -1000); ouyaButton.loadGraphic(FlxG.Content.Load <Texture2D>(ouya), true, false, 100, 100); ouyaButton.addAnimation("frame", new int[] { FlxButton.ControlPadA }); ouyaButton.play("frame"); ouyaButton.solid = false; ouyaButton.visible = true; ouyaButton.scrollFactor.X = 0; ouyaButton.scrollFactor.Y = 0; ouyaButton.boundingBoxOverride = false; keyboardDirection = new FlxSprite(targetLeft, -1000); keyboardDirection.loadGraphic(FlxG.Content.Load <Texture2D>(keys), true, false, 100, 100); keyboardDirection.addAnimation("frame", new int[] { Keyboard_Arrow_Up }); keyboardDirection.play("frame"); keyboardDirection.solid = false; keyboardDirection.visible = true; keyboardDirection.scrollFactor.X = 0; keyboardDirection.scrollFactor.Y = 0; keyboardDirection.boundingBoxOverride = false; xboxDirection = new FlxSprite(targetLeft, -1000); xboxDirection.loadGraphic(FlxG.Content.Load <Texture2D>(xbox360), true, false, 100, 100); xboxDirection.addAnimation("frame", new int[] { FlxButton.ControlPadA }); xboxDirection.play("frame"); xboxDirection.solid = false; xboxDirection.visible = true; xboxDirection.scrollFactor.X = 0; xboxDirection.scrollFactor.Y = 0; xboxDirection.boundingBoxOverride = false; ouyaDirection = new FlxSprite(targetLeft, -1000); ouyaDirection.loadGraphic(FlxG.Content.Load <Texture2D>(ouya), true, false, 100, 100); ouyaDirection.addAnimation("frame", new int[] { FlxButton.ControlPadA }); ouyaDirection.play("frame"); ouyaDirection.solid = false; ouyaDirection.visible = true; ouyaDirection.scrollFactor.X = 0; ouyaDirection.scrollFactor.Y = 0; ouyaDirection.boundingBoxOverride = false; //add(_gamePadButton, true); timeToShowButton = float.MaxValue; _elapsedSinceLastButtonNeeded = 0.0f; }
/// <summary> /// Creates a new <code>FlxState</code> object, /// instantiating <code>screen</code> if necessary. /// </summary> public FlxState() { defaultGroup = new FlxGroup(); scrollingSpritesGroup = new FlxGroup(); }
public override void create() { base.create(); FlxSprite bg = new FlxSprite(0, 0); bg.createGraphic(FlxG.width, FlxG.height, FlxG.splashBGColor); add(bg); _f = null; _poweredBy = FlxG.Content.Load <Texture2D>("flixel/poweredby"); _fSound = FlxG.Content.Load <SoundEffect>(FlxG.splashAudioWaveFlixel); _initialsLogo = FlxG.Content.Load <Texture2D>(FlxG.splashLogo); //_logo = new FlxSprite(); //_logo.loadGraphic(_initialsLogo, false, false, 216,24); //_logo.x = FlxG.width / 2 - 216 / 2; //_logo.y = FlxG.height / 2 - 24; //add(_logo); logoParts = new FlxGroup(); for (int i = 0; i < 18; i++) { for (int j = 0; j < 2; j++) { _logo = new FlxLogoSprite(i, j); _logo.loadGraphic(_initialsLogo, false, false, 12, 12); _logo.x = (FlxG.width / 2 - 216 / 2) + (i * 12); _logo.y = (FlxG.height / 2 - 24) + (j * 12); _logo.addAnimation("bugs", new int[] { 0, 1, 2, FlxU.randomInt(0, 24), FlxU.randomInt(0, 24), FlxU.randomInt(0, 24), FlxU.randomInt(0, 24), FlxU.randomInt(0, 24), FlxU.randomInt(0, 24), FlxU.randomInt(0, 24), FlxU.randomInt(0, 24), FlxU.randomInt(0, 24), FlxU.randomInt(0, 24), FlxU.randomInt(0, 24), FlxU.randomInt(0, 24), FlxU.randomInt(0, 24), FlxU.randomInt(0, 24), FlxU.randomInt(0, 24), (j * 18) + i }, FlxU.randomInt(12, 18), false); _logo.addAnimation("bugs2", new int[] { 0, 1, 2, FlxU.randomInt(0, 24), FlxU.randomInt(0, 24), FlxU.randomInt(0, 24), FlxU.randomInt(0, 24), FlxU.randomInt(0, 24), FlxU.randomInt(0, 24), FlxU.randomInt(0, 24), FlxU.randomInt(0, 24), FlxU.randomInt(0, 24), FlxU.randomInt(0, 24), FlxU.randomInt(0, 24), FlxU.randomInt(0, 24), FlxU.randomInt(0, 24), FlxU.randomInt(0, 24), FlxU.randomInt(0, 24), 0 }, FlxU.randomInt(18, 24), false); _logo.play("bugs"); logoParts.add(_logo); float offset = 25.0f; if (j >= 1) { offset *= -1.0f; } _logo.t = new Tweener((float)(_logo.y + offset), (float)_logo.y, 0.25f + (i / 18.0f), XNATweener.Quadratic.EaseInOut); _logo.t.Start(); } } add(logoParts); _logoTweener = new Tweener(-150, FlxG.height / 2 - 24, TimeSpan.FromSeconds(0.9f), Bounce.EaseOut); SndTag = FlxG.splashAudioWave; //FlxG.play(SndTag,1.0f); debugMode = new FlxText(10, 90, 200, "DEBUG MODE!"); debugMode.visible = false; add(debugMode); Console.WriteLine(" !!! Type {0} To Enter Debug Mode !!! ", FlxGlobal.titleScreenDebugMode); }